-
-
Notifications
You must be signed in to change notification settings - Fork 649
Fix GF(2) matrix transpose with subdivisions #40423
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for the fix. Could you also fix the code for "empty" input matrices, i.e. when
|
I have checked other matrix classes as well and fixed other instances of the zero matrix subdivision problem: |
You should add a doctest to show that the bug is indeed fixed. |
Doc tests are added now, checking for transposes of both 0-row and 0-column matrices. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments.
Apart for this, the ticket looks good to me.
I've updated the doctests now. All instances of _subdivisions should be replaced with subdivisions() |
Failures look unrelated to this PR. I give a positive review. |
sagemathgh-40423: Fix GF(2) matrix transpose with subdivisions <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 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. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. A small bug I noticed when looking at the code for transposing matrices. GF(2) does not properly transpose its subdivisions, meaning transposed matrices can have incorrect subdivisions or cause errors if the indices fall out of range. sage: M = matrix.random(GF(2),3,3) sage: N = matrix.block([[M,M,M]]) sage: M [1 0 0] [0 0 1] [0 1 0] sage: N [1 0 0|1 0 0|1 0 0] [0 0 1|0 0 1|0 0 1] [0 1 0|0 1 0|0 1 0] sage: N.transpose() <repr(<sage.matrix.matrix_mod2_dense.Matrix_mod2_dense at 0x7f1eb7f0c1c0>) failed: IndexError: list index out of range> This also adds subdivision handling to transposes of matrix_complex_ball_dense, matrix_gap, and fixes subdivisions for transposes of empty matrices of type matrix_mod2_dense, matrix_numpy_dense URL: sagemath#40423 Reported by: Biffo89 Reviewer(s): Xavier Caruso
sagemathgh-40423: Fix GF(2) matrix transpose with subdivisions <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 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. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. A small bug I noticed when looking at the code for transposing matrices. GF(2) does not properly transpose its subdivisions, meaning transposed matrices can have incorrect subdivisions or cause errors if the indices fall out of range. sage: M = matrix.random(GF(2),3,3) sage: N = matrix.block([[M,M,M]]) sage: M [1 0 0] [0 0 1] [0 1 0] sage: N [1 0 0|1 0 0|1 0 0] [0 0 1|0 0 1|0 0 1] [0 1 0|0 1 0|0 1 0] sage: N.transpose() <repr(<sage.matrix.matrix_mod2_dense.Matrix_mod2_dense at 0x7f1eb7f0c1c0>) failed: IndexError: list index out of range> This also adds subdivision handling to transposes of matrix_complex_ball_dense, matrix_gap, and fixes subdivisions for transposes of empty matrices of type matrix_mod2_dense, matrix_numpy_dense URL: sagemath#40423 Reported by: Biffo89 Reviewer(s): Xavier Caruso
sagemathgh-40423: Fix GF(2) matrix transpose with subdivisions <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 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. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. A small bug I noticed when looking at the code for transposing matrices. GF(2) does not properly transpose its subdivisions, meaning transposed matrices can have incorrect subdivisions or cause errors if the indices fall out of range. sage: M = matrix.random(GF(2),3,3) sage: N = matrix.block([[M,M,M]]) sage: M [1 0 0] [0 0 1] [0 1 0] sage: N [1 0 0|1 0 0|1 0 0] [0 0 1|0 0 1|0 0 1] [0 1 0|0 1 0|0 1 0] sage: N.transpose() <repr(<sage.matrix.matrix_mod2_dense.Matrix_mod2_dense at 0x7f1eb7f0c1c0>) failed: IndexError: list index out of range> This also adds subdivision handling to transposes of matrix_complex_ball_dense, matrix_gap, and fixes subdivisions for transposes of empty matrices of type matrix_mod2_dense, matrix_numpy_dense URL: sagemath#40423 Reported by: Biffo89 Reviewer(s): Xavier Caruso
sagemathgh-40423: Fix GF(2) matrix transpose with subdivisions <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 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. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. A small bug I noticed when looking at the code for transposing matrices. GF(2) does not properly transpose its subdivisions, meaning transposed matrices can have incorrect subdivisions or cause errors if the indices fall out of range. sage: M = matrix.random(GF(2),3,3) sage: N = matrix.block([[M,M,M]]) sage: M [1 0 0] [0 0 1] [0 1 0] sage: N [1 0 0|1 0 0|1 0 0] [0 0 1|0 0 1|0 0 1] [0 1 0|0 1 0|0 1 0] sage: N.transpose() <repr(<sage.matrix.matrix_mod2_dense.Matrix_mod2_dense at 0x7f1eb7f0c1c0>) failed: IndexError: list index out of range> This also adds subdivision handling to transposes of matrix_complex_ball_dense, matrix_gap, and fixes subdivisions for transposes of empty matrices of type matrix_mod2_dense, matrix_numpy_dense URL: sagemath#40423 Reported by: Biffo89 Reviewer(s): Xavier Caruso
sagemathgh-40423: Fix GF(2) matrix transpose with subdivisions <!-- ^ Please provide a concise and informative title. --> <!-- ^ Don't put issue numbers in the title, do this in the PR description below. --> <!-- ^ For example, instead of "Fixes sagemath#12345" use "Introduce new method to calculate 1 + 2". --> <!-- v Describe your changes below in detail. --> <!-- v Why is this change required? What problem does it solve? --> <!-- v If this PR resolves an open issue, please link to it here. For example, "Fixes sagemath#12345". --> ### 📝 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. - [ ] I have linked a relevant issue or discussion. - [ ] I have created tests covering the changes. - [ ] I have updated the documentation and checked the documentation preview. A small bug I noticed when looking at the code for transposing matrices. GF(2) does not properly transpose its subdivisions, meaning transposed matrices can have incorrect subdivisions or cause errors if the indices fall out of range. sage: M = matrix.random(GF(2),3,3) sage: N = matrix.block([[M,M,M]]) sage: M [1 0 0] [0 0 1] [0 1 0] sage: N [1 0 0|1 0 0|1 0 0] [0 0 1|0 0 1|0 0 1] [0 1 0|0 1 0|0 1 0] sage: N.transpose() <repr(<sage.matrix.matrix_mod2_dense.Matrix_mod2_dense at 0x7f1eb7f0c1c0>) failed: IndexError: list index out of range> This also adds subdivision handling to transposes of matrix_complex_ball_dense, matrix_gap, and fixes subdivisions for transposes of empty matrices of type matrix_mod2_dense, matrix_numpy_dense URL: sagemath#40423 Reported by: Biffo89 Reviewer(s): Xavier Caruso
📝 Checklist
A small bug I noticed when looking at the code for transposing matrices. GF(2) does not properly transpose its subdivisions, meaning transposed matrices can have incorrect subdivisions or cause errors if the indices fall out of range.
sage: M = matrix.random(GF(2),3,3)
sage: N = matrix.block([[M,M,M]])
sage: M
[1 0 0]
[0 0 1]
[0 1 0]
sage: N
[1 0 0|1 0 0|1 0 0]
[0 0 1|0 0 1|0 0 1]
[0 1 0|0 1 0|0 1 0]
sage: N.transpose()
<repr(<sage.matrix.matrix_mod2_dense.Matrix_mod2_dense at 0x7f1eb7f0c1c0>) failed: IndexError: list index out of range>
This also adds subdivision handling to transposes of matrix_complex_ball_dense, matrix_gap, and fixes subdivisions for transposes of empty matrices of type matrix_mod2_dense, matrix_numpy_dense