From 526485ead564d1f651dd252e9a8ea72a81d0d6bb Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 8 Apr 2026 19:48:48 -0400 Subject: [PATCH] mjo/matrix_algebra.py: support Vector "rows" in from_list() Something in Sage changed and now we're getting Vector "rows" in what used to be a list-of-lists resulting from a block matrix. Tweak the test to support anything with a __len__ method inside, rather than just list or tuple. --- mjo/matrix_algebra.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mjo/matrix_algebra.py b/mjo/matrix_algebra.py index affafc3..5df5c21 100644 --- a/mjo/matrix_algebra.py +++ b/mjo/matrix_algebra.py @@ -1,3 +1,5 @@ +from collections.abc import Sized + from sage.misc.table import table from sage.categories.magmatic_algebras import MagmaticAlgebras from sage.misc.cachefunc import cached_method @@ -459,7 +461,9 @@ class MatrixAlgebra(CombinatorialFreeModule): nrows = len(entries) ncols = 0 if nrows > 0: - if isinstance(entries[0], (list, tuple)): + # Support list, tuple, vector, etc. The "Sized" type class + # is what provides the __len__ we use immediately after. + if isinstance(entries[0], Sized): ncols = len(entries[0]) else: # We were given one long list of entries, -- 2.53.0