From: Michael Orlitzky Date: Wed, 8 Apr 2026 23:48:48 +0000 (-0400) Subject: mjo/matrix_algebra.py: support Vector "rows" in from_list() X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=526485ead564d1f651dd252e9a8ea72a81d0d6bb;p=sage.d.git 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. --- 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,