Deprecate automatic flattening for tensor products#129
Conversation
|
I'm supportive of this change. How come it's marked as draft? |
Wasn't quite sure about adding that |
37ea45f to
a27cd45
Compare
43887f3 to
d46952b
Compare
There was a problem hiding this comment.
Pull request overview
This PR updates ModePy’s tensor-product abstractions to stop implicitly “simplifying” tensor products while providing an explicit .flatten() API, and begins deprecating constructor-time auto-flattening to address surprising behavior reported in #126.
Changes:
- Add
.flatten()methods forTensorProductSpaceandTensorProductShapeto recursively flatten nested tensor products (returning the single remaining base directly). - Replace
__new__-based auto-simplification with constructor-time behavior guarded by aflattenflag andDeprecationWarningwhen auto-flattening is applied. - Adjust hypercube-related implementations to avoid relying on 1D hypercubes being
Simplex, and update tests/type-check baselines accordingly.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
modepy/spaces.py |
Adds flatten constructor flag, emits deprecation warnings for auto-flattening, and introduces TensorProductSpace.flatten(). |
modepy/shapes.py |
Adds flatten constructor flag + TensorProductShape.flatten(), updates face counting, and removes 1D hypercube “becomes simplex” behavior. |
modepy/test/test_tools.py |
Removes assertions that depended on 1D tensor products/hypercubes collapsing to simplices. |
.basedpyright/baseline.json |
Removes baseline entries related to the deleted overload-based __new__ implementations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d46952b to
dc4093e
Compare
dc4093e to
4fc9ba0
Compare
|
Thanks! |
This adds a
.flatten()method to tensor products to recursively flatten them into simplices (mostly). The automatic flattening in the constructor is marked as deprecated.Fixes #126.