Restore ResampledTSDF intermediate object to prevent invalid post-resample operations#461
Open
R7L208 wants to merge 7 commits intov0.2-integrationfrom
Open
Restore ResampledTSDF intermediate object to prevent invalid post-resample operations#461R7L208 wants to merge 7 commits intov0.2-integrationfrom
R7L208 wants to merge 7 commits intov0.2-integrationfrom
Conversation
…ample operations (#458) Introduces a ResampledTSDF composition-based wrapper (like Spark's GroupedData) that only exposes valid post-resample operations (interpolate, as_tsdf, show), preventing chained operations like .filter() from silently invalidating resample context. Removes mutable resample_freq/resample_func attributes from TSDF. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add TYPE_CHECKING import for TSDF in resampled.py to resolve forward-reference lint errors, and apply black formatting to 30 files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Fix mypy no-untyped-def errors for df and ts_schema properties. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v0.2-integration #461 +/- ##
====================================================
- Coverage 85.46% 78.55% -6.92%
====================================================
Files 6 31 +25
Lines 757 2840 +2083
Branches 156 469 +313
====================================================
+ Hits 647 2231 +1584
- Misses 92 450 +358
- Partials 18 159 +141 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Disambiguate the confusingly similar resample.py and resampled.py file names by renaming the wrapper class module to resample_result.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Cover property accessors, show(), repr completeness, interpolate branches (zero, ffill, bfill, null, target_cols, show_interpolated warning), and as_tsdf() usability. Adds shared interpolation test data to resample_tests.json. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Covers the method="linear" branch (line 103) and the else fallback for unknown method strings (line 113) in resample_result.py. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Introduces a
ResampledTSDFcomposition-based wrapper (like Spark'sGroupedData) that only exposes valid post-resample operations (interpolate,as_tsdf,show). This prevents chained operations like.filter()after.resample()from silently invalidating resample context while metadata travels forward to.interpolate(), producing wrong results.Key changes:
ResampledTSDFclass (tempo/resampled.py): read-only wrapper withinterpolate(),as_tsdf(),show(), and__repr__TSDF.__init__/__withTransformedDF: removed mutableresample_freq/resample_funcattributesTSDF.resample()andresample.resample(): now returnResampledTSDFinstead ofTSDFTSDF.interpolate(): simplified to delegate throughself.resample(...).interpolate(...)calc_bars()in bothtsdf.pyandstats.py: calls.as_tsdf()after eachresample()__init__.py: exportsResampledTSDFLinked issues
Resolves #458
Functionality
TSDF.__init__,TSDF.__withTransformedDF,TSDF.resample,TSDF.interpolate,TSDF.calc_barsresample.resample,stats.calc_barsTests
test_resample_returns_resampled_tsdf— verifies return type andas_tsdf()escape hatchtest_tsdf_resample_returns_resampled_tsdf— verifiesTSDF.resample()return typetest_resampled_tsdf_blocks_invalid_operations— verifiesAttributeErroron.filter(),.withColumn(), etc.test_resampled_tsdf_repr— verifies descriptive__repr__test_resample_then_interpolate_chain— verifiestsdf.resample(freq, func).interpolate(method)works end-to-end