forked from scipy/scipy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: sparse: 'diagonal' of sparse matrices fixed to match numpy's dia…
…gonal behaviour (scipy#11970) * BUG: sparse: Added check for size in method 'diagonal' of sparse matrices to deal with matrices of size 0 'diagonal' raise ValueError if a sparse matrix size is 0, but equivalent function 'numpy.diagonal' return an empty array, as mentioned in issue scipy#11949. 'diagonal' check if k is less than size, but in case of an empty matrix, k is equal to the size and ValueError rises. Added check so if any of sizes is 0, 'diagonal' return an empty array, like 'numpy.diagonal'. * BUG: sparse: Removed raising a ValueError from `diagonal` method and fixed type of returned array To match the behaviour of `numpy.diagonal` replaced raising ValueError when passed a value exceeds the number of rows or columns with returning an empty array. Also changed dtype of a returned empty array to match dtype of a sparse matrix. * TST: sparse: added tests to cover offset in `diagonal` greater than the size of a matrix New test cover that and few more shapes of an empty sparse matrix(when one of the sizes is 0 and other not) * MAINT: Fixed typo in comments Co-authored-by: Warren Weckesser <[email protected]> Co-authored-by: Warren Weckesser <[email protected]>
- Loading branch information
1 parent
787efe4
commit b887d9e
Showing
5 changed files
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters