feat(mv): add __rtruediv__ to support scalar/Mv expressions#543
feat(mv): add __rtruediv__ to support scalar/Mv expressions#543utensil merged 2 commits intopygae:masterfrom
__rtruediv__ to support scalar/Mv expressions#543Conversation
Expressions like 1/I where I is a pseudoscalar previously raised an exception because Python's int/float types cannot handle division by an Mv object. This adds __rtruediv__ so that scalar/Mv is computed as Mv(scalar) * Mv.inv(). Fixes #1
|
Tests look good. Checked against kingdon's approach — they use the same convention ( Two minor gaps worth noting: no test with a symbolic numerator (e.g. |
__rtruediv__ to Mv to support scalar/Mv expressions
|
Thanks for the review! Added both suggested test cases:
Pushed in 5c1f0ac. |
__rtruediv__ to Mv to support scalar/Mv expressions__rtruediv__ to support scalar/Mv expressions
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #543 +/- ##
==========================================
- Coverage 78.93% 72.95% -5.98%
==========================================
Files 19 19
Lines 4452 4452
==========================================
- Hits 3514 3248 -266
- Misses 938 1204 +266 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Tests look good, thanks! The coverage drop is likely a codecov artifact. Codecov itself says all modified lines are covered. |
Groups new entries by: features, bug fixes, examples/docs, tests/maintenance. Features: Cl() kingdon interface (pygae#550, closes pygae#524), Mv.__rtruediv__ (pygae#543, closes pygae#512), shirokov_inverse/hitzer_inverse (pygae#530). Bugs: interop dual mode contamination (pygae#556, closes pygae#555), norm() Abs wrapping (pygae#554, closes pygae#522), is_versor() improvement (pygae#536, closes pygae#533). Examples/docs: sundial + cheatsheet tests (pygae#549+pygae#557, closes pygae#506), coords tutorial (pygae#551), README ops (pygae#548, closes pygae#523). Tests/maintenance: lt.matrix() regression tests (pygae#558, closes pygae#461), extra-cdot regression test (pygae#545), er_blade + ReciprocalFrame refactors (pygae#552+pygae#553), CI fix (pygae#535).
* docs: add 0.6.0 changelog entries Groups new entries by: features, bug fixes, examples/docs, tests/maintenance. Features: Cl() kingdon interface (#550, closes #524), Mv.__rtruediv__ (#543, closes #512), shirokov_inverse/hitzer_inverse (#530). Bugs: interop dual mode contamination (#556, closes #555), norm() Abs wrapping (#554, closes #522), is_versor() improvement (#536, closes #533). Examples/docs: sundial + cheatsheet tests (#549+#557, closes #506), coords tutorial (#551), README ops (#548, closes #523). Tests/maintenance: lt.matrix() regression tests (#558, closes #461), extra-cdot regression test (#545), er_blade + ReciprocalFrame refactors (#552+#553), CI fix (#535). * docs: add missing issue link for #551 entry * docs: add changelog entry for #560 (Lt callable zero fix) * docs: move Lt zero fix into bug group, use issue #540 as reference
Summary
Adds
__rtruediv__to theMvclass so that expressions like1/mvandscalar/mvwork as expected, computingscalar * mv.inv().Previously,
1/mvwould raise aTypeErrorbecause Python'sint.__truediv__doesn't know how to handleMvobjects andMvdidn't implement__rtruediv__.Fixes #512
Changes
galgebra/mv.py: Add__rtruediv__method that wraps the scalar as anMvand multiplies byself.inv()test/test_mv.py: Add tests for1/I,2/v, andS(3)/ITest plan
pytest test/ -vpasses