fix(lt): accept ImmutableDenseMatrix in Lt.__init__ (#567)#569
Merged
utensil merged 1 commit intopygae:masterfrom Apr 2, 2026
Merged
fix(lt): accept ImmutableDenseMatrix in Lt.__init__ (#567)#569utensil merged 1 commit intopygae:masterfrom
utensil merged 1 commit intopygae:masterfrom
Conversation
utensil
approved these changes
Apr 2, 2026
Member
utensil
left a comment
There was a problem hiding this comment.
Thanks for catching this. Using MatrixBase is the right call — it's the common base for both mutable and immutable SymPy matrices, and Matrix_to_dictionary only uses indexing and .rows/.cols, so the widening is safe.
There's one other isinstance(g, Matrix) in metric.py that has the same narrowness — user-supplied metric input, so not triggered by the same regression, but worth a follow-up.
utensil
pushed a commit
that referenced
this pull request
Apr 3, 2026
* docs: add 0.6.1 changelog entries Covers: Mlt component-expression constructor (#578/#580), is_blade null fix (#537), Macdonald PDF update (#577), dev guides (#572/#574), SymPy 1.13 notebook refresh (#570), Lt ImmutableDenseMatrix fix (#569), Python 3.10-3.12 CI (#565). * docs(changelog): fix is_blade entry reference from issue to PR The is_blade entry incorrectly referenced issue 537 but should reference PR 582 to match the convention used in other entries. --------- Co-authored-by: utiberious <utiberious@users.noreply.github.com>
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.
Closes #567.
Problem
Lt.__init__ingalgebra/lt.pyaccepted onlyMatrix(MutableDenseMatrix) but notImmutableDenseMatrix. In SymPy 1.13, operations such asLt.matrix()and metric tensor multiplication now returnImmutableDenseMatrix, so passing the result back toGa.lt()raised:Fix
Change
isinstance(mat_rep, Matrix)→isinstance(mat_rep, MatrixBase)atlt.py:326.MatrixBaseis the common abstract base for both mutable and immutable SymPy matrices.Test results
Passes with both
sympy==1.12(current CI) andsympy==1.13.3. flake8 clean.