Timeseries chainable - #71
Conversation
|
I think that there may be a weird API now. Now ts.value returns the _get_not_indexed_data. If these data is a masked_array then we have to call ts.value.value to access the undelining numpy array. Which is ugly. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #71 +/- ##
==========================================
+ Coverage 76.49% 77.49% +1.00%
==========================================
Files 185 185
Lines 12727 13325 +598
==========================================
+ Hits 9735 10326 +591
- Misses 2992 2999 +7 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR introduces a fluent/chainable API for TimeSeries reductions and filtering, shifting statistical operations from method calls to chainable properties with a final .value extractor.
Changes:
- Add chainable reduction properties (
ensemble_*,time_*), plus.valueand NumPy interoperability (__array__,__array_ufunc__) onTimeSeries. - Add upstream filtering via
filter(**kwargs)andwith_times(...)to enable fluent chaining. - Update tests and documentation (incl. a new tutorial notebook) to cover the new fluent API and legacy
get_*deprecations.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
arte/time_series/time_series.py |
Implements fluent API properties, filtering, .value, and NumPy protocol support; adds deprecated get_* wrappers. |
arte/time_series/multi_time_series.py |
Updates docs and adds fluent ensemble-property homogeneity checks + deprecated get_* wrappers for some ensemble ops. |
test/time_series/time_series_test.py |
Updates legacy calls to get_* and adds extensive fluent API tests (chaining, .value, filtering, numpy compatibility). |
test/time_series/time_series_ma_test.py |
Migrates masked-array tests to the fluent API (.time_mean.value, etc.). |
test/time_series/multi_time_series_test.py |
Adjusts tests for fluent properties and homogeneity checks; adds deprecation-warning assertions. |
docs/tutorial.rst |
Adds a Time Series tutorial entry to the docs toctree. |
docs/time_series.rst |
Documents the new fluent API and legacy deprecations. |
docs/notebook/time_series/time_series_examples.ipynb |
Adds a notebook demonstrating the fluent API usage and migration. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
… metadata Co-authored-by: lbusoni <8113755+lbusoni@users.noreply.github.com>
Propagate parent axes through FilteredTimeSeries constructor
| Examples | ||
| -------- | ||
| >>> ts = MyTimeSeries(data) | ||
| >>> rms = ts.ensemble_rms_property # Returns TimeSeries |
There was a problem hiding this comment.
Of all things, it is the example that is wrong...
Fluent API for TimeSeries
📋 Summary
Implements a chainable fluent API for
TimeSeriesanalysis, replacing method-based operations with property-based chainable operations. All statistical reductions now returnTimeSeriesobjects that can be chained together, with a.valueproperty for final extraction.🎯 Motivation
Before:
After:
✨ Features
Chainable Properties
All reduction operations are now chainable properties returning
TimeSeries:Ensemble reductions:
ensemble_rms- RMS across ensembleensemble_mean- Mean (renamed fromensemble_average)ensemble_std- Standard deviationensemble_median- Medianensemble_ptp- Peak-to-peakTime reductions:
time_mean- Mean (renamed fromtime_average)time_std- Standard deviationtime_rms- RMStime_median- Mediantime_ptp- Peak-to-peakNew Capabilities
.valueproperty: Extract final values (like pandas.values)ts.ensemble_rms.time_meanandts.time_mean.ensemble_rmsboth workfilter(**kwargs): Generic upstream filteringmodes=,elements=,rows=,cols=,times=, etc.with_times(times): Convenient alias forfilter(times=...)📝 Examples
All reduction methods renamed with
get_prefix:ts.ensemble_rms()ts.get_ensemble_rms()ts.ensemble_rms.valuets.ensemble_average()ts.get_ensemble_average()ts.ensemble_mean.valuets.time_average()ts.get_time_average()ts.time_mean.valueMigration:
ts.method()→ts.get_method()(showsDeprecationWarning)🔄 Migration Guide
🧪 Testing
📚 Documentation
TimeSeriesdocstring updated with fluent API examplesget_*()methods🔧 Implementation Details
_create_reduced_series(): Handles ensemble reductions (preserves time axis)_create_temporal_reduced_series(): Handles time reductions (time_size=1)MaskedArrayandastropy.units📦 Next Steps
get_*()or new API