Skip to content

Commit

Permalink
gh-35405: accept plain Python types in block_matrix()
Browse files Browse the repository at this point in the history
    
<!-- Please provide a concise, informative and self-explanatory title.
-->
<!-- Don't put issue numbers in the title. Put it in the Description
below. -->
<!-- For example, instead of "Fixes #12345", use "Add a new method to
multiply two integers" -->

### 📚 Description

<!-- Describe your changes here in detail. -->
<!-- Why is this change required? What problem does it solve? -->
<!-- If this PR resolves an open issue, please link to it here. For
example "Fixes #12345". -->
<!-- If your change requires a documentation PR, please link it
appropriately. -->

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. It should be `[x]` not `[x
]`. -->

- [x] The title is concise, informative, and self-explanatory.
- [ ] The description explains in detail what this PR is about.
- [ ] I have linked a relevant issue or discussion.
- [x] I have created tests covering the changes.
- [ ] I have updated the documentation accordingly.

### ⌛ Dependencies

<!-- List all open PRs that this PR logically depends on
- #12345: short description why this is a dependency
- #34567: ...
-->

<!-- If you're unsure about any of these, don't hesitate to ask. We're
here to help! -->
    
URL: #35405
Reported by: Marc Mezzarobba
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Apr 4, 2023
2 parents 3d5a754 + bc9cb82 commit 5853e99
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sage/matrix/special.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 5853e99

Please sign in to comment.