Skip to content

fix(lt): accept ImmutableDenseMatrix in Lt.__init__ (#567)#569

Merged
utensil merged 1 commit intopygae:masterfrom
utiberious:fix/issue-567-immutable-matrix
Apr 2, 2026
Merged

fix(lt): accept ImmutableDenseMatrix in Lt.__init__ (#567)#569
utensil merged 1 commit intopygae:masterfrom
utiberious:fix/issue-567-immutable-matrix

Conversation

@utiberious
Copy link
Copy Markdown
Contributor

Closes #567.

Problem

Lt.__init__ in galgebra/lt.py accepted only Matrix (MutableDenseMatrix) but not ImmutableDenseMatrix. In SymPy 1.13, operations such as Lt.matrix() and metric tensor multiplication now return ImmutableDenseMatrix, so passing the result back to Ga.lt() raised:

TypeError: Unsupported argument type <class 'sympy.matrices.immutable.ImmutableDenseMatrix'>

Fix

Change isinstance(mat_rep, Matrix)isinstance(mat_rep, MatrixBase) at lt.py:326. MatrixBase is the common abstract base for both mutable and immutable SymPy matrices.

Test results

Passes with both sympy==1.12 (current CI) and sympy==1.13.3. flake8 clean.

Copy link
Copy Markdown
Member

@utensil utensil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 utensil merged commit 7935183 into pygae:master Apr 2, 2026
5 checks passed
utiberious added a commit to utiberious/galgebra that referenced this pull request Apr 2, 2026
Covers: Mlt component-expression constructor (pygae#578/pygae#580),
is_blade null fix (pygae#537), Macdonald PDF update (pygae#577),
dev guides (pygae#572/pygae#574), SymPy 1.13 notebook refresh (pygae#570),
Lt ImmutableDenseMatrix fix (pygae#569), Python 3.10-3.12 CI (pygae#565).
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lt does not accept ImmutableDenseMatrix from SymPy 1.13

2 participants