-
-
Notifications
You must be signed in to change notification settings - Fork 698
fix the infinite loop in lie algebra #41200
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
base: develop
Are you sure you want to change the base?
Conversation
| True | ||
| Test that morphisms can be constructed (this used to fail with | ||
| RecursionError):: |
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.
Could use :exc:`RecursionError` here to create a link in the docs
| Test that morphisms can be constructed (this used to fail with | ||
| RecursionError):: | ||
| sage: gl = lie_algebras.gl(QQ, 2) |
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 one might be better in a TESTS:: block since it doesn't demonstrate the element constructor directly
| try: | ||
| if hasattr(x, 'parent') and x.parent() == self.module(): | ||
| return self.from_vector(x) | ||
| except (AttributeError, NotImplementedError): |
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.
Can these two errors really happen? We check for the .parent attribute before using it, and then we check that x belongs to a module before calling from_vector() on it...
Solutions
This fixes #40780
Add an explicit check in
_element_constructor_to handle vectors directly usingfrom_vector()before attempting to useself._assoc(x):📝 Checklist
The Infinite Loop Cycle
The infinite recursion occurs in the following cycle:
Detailed Breakdown
Morphism Construction Context:
gl.morphism({e:e for e in gl.gens()}), the morphism code (inmorphism.py) computes brackets to extend the spanning setdomain.bracket(spanning_set[i], spanning_set[j])wherespanning_setcontains vectorsBracket Computation:
bracketmethod inlie_algebras.pyline 290:lhs,rhs) to Lie algebra elements by callingself(vector)Element Constructor Issue:
LieAlgebraFromAssociative._element_constructor_(line 1246) was:xis a vector, it callsself._assoc(vector)Coercion Map Problem:
self._associs aMatrixSpaceLiftMorphismToAssociativewas set up as a coercionThe Loop Closes:
MatrixSpace(vector)uses the coercion mapVectorSpace → LieAlgebracallsgl(vector)_element_constructor_again with the same vector⌛ Dependencies