Change isBlade to work on degenerate metrics#162
Open
eric-wieser wants to merge 1 commit intopygae:masterfrom
Open
Change isBlade to work on degenerate metrics#162eric-wieser wants to merge 1 commit intopygae:masterfrom
isBlade to work on degenerate metrics#162eric-wieser wants to merge 1 commit intopygae:masterfrom
Conversation
eric-wieser
commented
Oct 22, 2019
Comment on lines
690
to
689
| # applying a versor (and hence an invertible blade) to a vector should | ||
| # not change the grade | ||
| if not all( | ||
| grades_present(Vhat*e*Vrev, 0.000001) == {1} | ||
| grade_cmp(grades_present(Vhat*e*Vrev, 0.000001), {1}) | ||
| for e in cf.basis_vectors(self.layout).values() | ||
| ): |
Member
Author
There was a problem hiding this comment.
This condition is relaxed when invertible=False to allow only the removal of grades, but not the addition of any new ones
Comment on lines
683
to
680
| # Test if the versor inverse (~V)/(V * ~V) is truly the inverse of the | ||
| # multivector V | ||
| if grades_present(Vhat*Vinv, 0.000001) != {0}: | ||
| if not grade_cmp(grades_present(Vhat*Vinv, 0.000001), {0}): | ||
| return False |
Member
Author
There was a problem hiding this comment.
This condition is relaxed to allow Vhat*Vinv == 0 to be considered
Comment on lines
+674
to
+675
| mag = (self*Vrev)[()] | ||
| if mag != 0: | ||
| # not strictly necessary, just scales to make eps appropriate below | ||
| Vinv = Vrev / mag | ||
| elif invertible: | ||
| return False | ||
| else: | ||
| Vinv = Vrev |
Member
Author
There was a problem hiding this comment.
Changes here are to:
- bail out early without a divide-by-zero if not allowing non-invertible blades
- avoiding the division if it is zero, since that shouldn't affect the results below significantly
- Use
[()]instead of[0], which is a little more reliable for pulling out the scalar part
isBlade to work on denegerate metricsisBlade to work on degenerate metrics
```python >>> import clifford >>> layout, _ = clifford.Cl(3, 0, 1, firstIdx=0) >>> locals().update(layout.blades) >>> e0.isBlade() True >>> e0.isBlade(invertible=True) False ```
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #162 +/- ##
==========================================
+ Coverage 70.37% 70.43% +0.05%
==========================================
Files 69 69
Lines 9025 9050 +25
Branches 1177 1182 +5
==========================================
+ Hits 6351 6374 +23
- Misses 2507 2508 +1
- Partials 167 168 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Fixes #145.
This exposes that
.factorise()and.basis()both fail on non-invertible blades. I'm not sure exactly how to fix that, other than being sure I don't want to do it in this PR.