Skip to content

Commit 95045c1

Browse files
author
Release Manager
committed
gh-39557: Fixed issue where insert_row in dense integer matrices would not accept python integers. Fixes #11328. Fixes issue where when you put python integers into the insert_row function of dense matrices it caused a crash. Fixed the issue by adding a try catch block and converting the entries to sage integers directly if the try block fails. Does not add any more insert_row functions anywhere else or change the behavior of insert_row as suggested in the comments of #11328. ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> - [X] The title is concise and informative. - [X] The description explains in detail what this PR is about. - [X] I have linked a relevant issue or discussion. - [X] I have created tests covering the changes. - [X] I have updated the documentation and checked the documentation preview. ### ⌛ Dependencies URL: #39557 Reported by: Noel-Roemmele Reviewer(s): Noel-Roemmele, Travis Scrimshaw
2 parents 3b849e6 + 5e04ccc commit 95045c1

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/sage/matrix/matrix_integer_dense.pyx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5423,6 +5423,16 @@ cdef class Matrix_integer_dense(Matrix_dense):
54235423
[ 3 4 5]
54245424
[ 6 7 8]
54255425
[ 1 5 -10]
5426+
5427+
TESTS:
5428+
5429+
Ensure that :issue:`11328` is fixed::
5430+
5431+
sage: m = matrix([[int(1),int(1)],[int(1),int(1)]])
5432+
sage: m.insert_row(1,[int(2),int(3)])
5433+
[1 1]
5434+
[2 3]
5435+
[1 1]
54265436
"""
54275437
cdef Matrix_integer_dense res = self._new(self._nrows + 1, self._ncols)
54285438
cdef Py_ssize_t j
@@ -5438,7 +5448,8 @@ cdef class Matrix_integer_dense(Matrix_dense):
54385448
for i from 0 <= i < index:
54395449
fmpz_init_set(fmpz_mat_entry(res._matrix,i,j), fmpz_mat_entry(self._matrix,i,j))
54405450

5441-
z = row[j]
5451+
z = ZZ(row[j])
5452+
54425453
fmpz_set_mpz(zflint,z.value)
54435454
fmpz_init_set(fmpz_mat_entry(res._matrix,index,j), zflint)
54445455

0 commit comments

Comments
 (0)