-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change isBlade
to work on degenerate metrics
#162
base: master
Are you sure you want to change the base?
Conversation
clifford/_multivector.py
Outdated
# 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() | ||
): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is relaxed when invertible=False
to allow only the removal of grades, but not the addition of any new ones
clifford/_multivector.py
Outdated
# 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is relaxed to allow Vhat*Vinv == 0
to be considered
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ 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
Continue to review full report at Codecov.
|
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.