From bc9cb827518e1fe1c43c0ea0d7988cb561788ae2 Mon Sep 17 00:00:00 2001 From: Marc Mezzarobba Date: Fri, 31 Mar 2023 17:13:13 +0200 Subject: [PATCH] accept plain Python types in block_matrix() --- src/sage/matrix/special.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/sage/matrix/special.py b/src/sage/matrix/special.py index 5d3bb13445b..41a48c0e99f 100644 --- a/src/sage/matrix/special.py +++ b/src/sage/matrix/special.py @@ -66,7 +66,7 @@ from sage.rings.ring import is_Ring import sage.matrix.matrix_space as matrix_space from sage.modules.free_module_element import vector -from sage.structure.element import is_Matrix +from sage.structure.element import is_Matrix, parent from sage.structure.sequence import Sequence from sage.rings.integer_ring import ZZ from sage.rings.rational_field import QQ @@ -1905,6 +1905,12 @@ def block_matrix(*args, **kwds): sage: block_matrix(A) [ 3 5] [ 8 13] + sage: block_matrix([[A, 0r], [1r, A]]) + [ 3 5| 0 0] + [ 8 13| 0 0] + [-----+-----] + [ 1 0| 3 5] + [ 0 1| 8 13] """ args = list(args) sparse = kwds.get('sparse', None) @@ -2020,7 +2026,7 @@ def block_matrix(*args, **kwds): ring = ZZ for row in sub_matrices: for M in row: - R = M.base_ring() if is_Matrix(M) else M.parent() + R = M.base_ring() if is_Matrix(M) else parent(M) if R is not ZZ: ring = sage.categories.pushout.pushout(ring, R)