Skip to content

add option to set data_type in patch_function decorator#702

Open
d-chambers wants to merge 1 commit into
masterfrom
patch_attrs_data_type
Open

add option to set data_type in patch_function decorator#702
d-chambers wants to merge 1 commit into
masterfrom
patch_attrs_data_type

Conversation

@d-chambers

@d-chambers d-chambers commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a data_type argument to patch_function so patch methods can declare a constant output data_type in the decorator. The decorator batches this update with history so it does not need an extra update_attrs
call when both are applied.

This also moves constant data_type assignments for strain-rate, FBE, STA/LTA, and kurtosis transforms into their decorators, and registers the new snake_case transform data types in VALID_DATA_TYPES.

Summary by CodeRabbit

  • New Features

    • Added support for three new data types: frequency_band_energy, kurtosis, and stalta.
  • Improvements

    • Standardized how transforms declare and report their output data types, ensuring consistent data type naming across all transforms.
    • Frequency Band Energy, Kurtosis, and STA/LTA transforms now properly register their output data types.

@coderabbitai

coderabbitai Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f90c2c86-31e2-41dd-89f7-b6a41b7fa7a1

📥 Commits

Reviewing files that changed from the base of the PR and between 6e6ea41 and f81df7d.

📒 Files selected for processing (10)
  • dascore/constants.py
  • dascore/transform/fbe.py
  • dascore/transform/kurtosis.py
  • dascore/transform/stalta.py
  • dascore/transform/strain.py
  • dascore/utils/patch.py
  • tests/test_transform/test_fbe.py
  • tests/test_transform/test_kurtosis.py
  • tests/test_transform/test_stalta.py
  • tests/test_utils/test_patch_utils.py

📝 Walkthrough

Walkthrough

Refactor transforms to declare output data type via decorator parameter instead of inline attribute updates. Enhance patch_function with optional data_type parameter, register new data types in constants, migrate FBE, kurtosis, stalta, and strain transforms to use the decorator, and update test expectations across multiple transform and utility tests.

Changes

Patch Function Enhancement and Transform Data Type Centralization

Layer / File(s) Summary
Decorator enhancement with data_type parameter
dascore/utils/patch.py
patch_function accepts optional data_type parameter, applies it unconditionally to output patch, combines data_type and history updates into single update_attrs call, and includes parameter docstring and usage example.
Data type validation and limits
dascore/constants.py
Add "frequency_band_energy", "kurtosis", and "stalta" to VALID_DATA_TYPES tuple; increase max_lens["data_type"] from 20 to 21 characters.
Transform migrations to decorator-based data_type
dascore/transform/fbe.py, dascore/transform/kurtosis.py, dascore/transform/stalta.py, dascore/transform/strain.py
FBE, kurtosis, stalta, and strain transforms migrate from inline data_type attribute assignment to @patch_function(data_type=...) decorator parameter; function bodies remove redundant explicit data_type metadata updates, keeping only other required attribute changes.
Test coverage for data_type behavior and transform outputs
tests/test_utils/test_patch_utils.py, tests/test_transform/test_fbe.py, tests/test_transform/test_kurtosis.py, tests/test_transform/test_stalta.py
Add tests verifying decorator data_type override behavior, single-call history and data_type batching, and existing behavior preservation; update all transform test assertions to expect lowercase data_type strings from decorator outputs.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding a data_type option to the patch_function decorator.
Description check ✅ Passed The description covers the purpose and implementation details, but lacks documentation of testing and issue references.
Docstring Coverage ✅ Passed Docstring coverage is 90.63% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch patch_attrs_data_type

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f81df7d901

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dascore/transform/fbe.py


@patch_function()
@patch_function(data_type="frequency_band_energy")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore FBE default colormap after renaming data_type

For FBE outputs, this new frequency_band_energy value no longer matches the existing DEFAULT_COLORMAPS key ("frequency-band energy"), while waterfall(cmap="default") lowercases the patch data_type and looks it up directly before falling back to "bwr". As a result, any FBE patch plotted with the default waterfall colormap now silently loses its prior Spectral_r coloring; please update the colormap key alongside the data_type rename.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.93%. Comparing base (27c8121) to head (f81df7d).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #702   +/-   ##
=======================================
  Coverage   99.93%   99.93%           
=======================================
  Files         138      138           
  Lines       11881    11890    +9     
=======================================
+ Hits        11873    11882    +9     
  Misses          8        8           
Flag Coverage Δ
unittests 99.93% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant