-
-
Notifications
You must be signed in to change notification settings - Fork 453
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
block_matrix reacts inconsistently with 0 #4492
Comments
comment:4
So I figured out what is going wrong here. Patch to come shortly. |
comment:6
I think that in the doctest you give there actually is insufficient information, because you can't deduce the width of the left blocks, so an exception is in my opinion the right thing to do there. In the example in this ticket, it seems to break because it tries to deduce the block dimensions in a single pass through the cells. In this pass, it only determines the size of column 2 and rows 1 and 2. It might need multiple passes to find all information. |
comment:7
Attachment: 4492_doctest_nonsquare0_block.patch.gz Robert Bradshaw suggested adding an example that explicitly shows zero blocks may be non-square. I added a patch that adds that to the docstring of |
Attachment: trac_4492.patch.gz apply only this patch (don't apply wjp's) |
comment:9
This breaks the following example: sage: B = Matrix(ZZ,3,2,[1,2,3,4,5,6]) The problem is that it turns the 0 at the top into a 2x2 zero matrix while |
comment:10
Oops, sorry for the broken formatting. Clean version:
|
comment:11
I tried to write a patch for this, but ran into some trouble with the last doctest:
In this case there are no real columns as such, and I'm not sure how we should behave if there were an extra row with My current attempt raises an exception for this doctest that the column widths are inconsistent. |
comment:12
For those interested, my current work-in-progress patch is at http://www.math.leidenuniv.nl/~wpalenst/sage/sage_WIP_block_matrix.patch |
comment:13
Further work in progress (replacing the previous patch). This also addresses #2429. http://www.math.leidenuniv.nl/~wpalenst/sage/block_matrix_2.patch |
Author: Willem Jan Palenstijn |
comment:15
The following tests failed:
|
Reviewer: Aly Deines |
comment:20
The last three, in order: Apply 4492_block_matrix.patch, trac_4492-block-matrix-reviewer.patch, 4492_typo.patch |
comment:21
The reviewer patch looks good, and passes all tests for me too. The doctests and documentation it adds are really clarifying. (I did add a very minor patch on top of it fixing two small typos.) |
comment:22
It looks good and all tests pass for me too. |
This comment has been minimized.
This comment has been minimized.
comment:24
This needs to be rebased to sage-4.6.2.alpha1 |
Work Issues: rebase |
rebased to 4.6.2.alpha1 |
comment:25
Attachment: 4492_block_matrix_rebased.patch.gz |
This comment has been minimized.
This comment has been minimized.
comment:26
Rebased patch attached. (No actual changes, just the context of one of the hunks had changed.) |
comment:27
Attachment: trac_4492-doctest-number-field.patch.gz Rebased patches apply fine and Sage builds. However 3 doctests fail. These can be traced to #10433 that snuck into 4.6.2.alpha1 while this was in-progress. ;-) Specifically one 2x2 block matrix built at line 2366 of Latest patch rearranges the block matrix construction to meet new requirements for more explicit lists for the block matrix. I've cc'ed David Loeffler if he wants to check off on just that one change. Passes all tests now in sage/rings. All work here is on 4.6.2.alpha1. Would somebody like to retest the whole package now? |
This comment has been minimized.
This comment has been minimized.
comment:29
(The change to number field code looks fine to me.) |
comment:30
I will test the patches. |
comment:31
I've also run tests with 4.6.2-alpha2 + this ticket, and all tests passed. |
Changed work issues from rebase to none |
comment:33
Yep, tests are okay. |
comment:34
David - thanks for the quick check. Jeroen, Willem - thanks for the testing. Sounds like the latest patch has been tested and everybody is OK with all of this, so I'm going to switch this back to positive review. |
Merged: sage-4.6.2.alpha3 |
Using ZZ(0) as an element of the list passed to block_matrix appears to be a special case somehow and throws an exception rather than creating the matrix seems reasonable to me.
This feels to me like a hazardous inconsistency.
Perhaps I should also add that I don't really like that it just blithely assumes I want a square matrix (although I did in my actual usage). Ticket #2429 addresses that issue more wholeheartedly.
Apply:
CC: @craigcitro @jasongrout @loefflerd
Component: linear algebra
Author: Willem Jan Palenstijn
Reviewer: Aly Deines, Rob Beezer
Merged: sage-4.6.2.alpha3
Issue created by migration from https://trac.sagemath.org/ticket/4492
The text was updated successfully, but these errors were encountered: