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
BUG: sparse: Propagate dtype through CSR/CSC constructors #13403
BUG: sparse: Propagate dtype through CSR/CSC constructors #13403
Conversation
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.
@perimosocordiae When I run this feature branch with the original example code in the matching issue I still get a traceback (below). Is there still something off in the original reproducer from @matteodellamico?
scipy.__version__: 1.7.0.dev0+7185d00
Traceback (most recent call last):
File "test.py", line 21, in <module>
assert v == data[i], (i, data[i], v)
AssertionError: (4, 14115858573662012539, 14115858573662013440)
Did you use the fixed reproducer? The original version could have duplicate entries. |
I thought I did--I believe the author edited the code and I copy-pasted from there. |
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.
The test passes in the master branch, because 2**63
happens to be a number that survives the round trip through floating point. The big value used in the test should be changed to, say, 2**63 + 1
.
The test will then fail, because the fix is not complete. The dtype
has to be passed to the array
function that is eventually called at
Line 159 in 01838d2
self.data = np.array(obj, copy=copy) |
Thanks for the double-checking @tylerjereddy and the explanation @WarrenWeckesser. I learned something new about the way numpy does dtype inference today:
With my latest commit, this bug should actually now be fixed. |
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.
One small PEP-8 change, otherwise looks good.
Co-authored-by: Warren Weckesser <warren.weckesser@gmail.com>
Merged, thanks @perimosocordiae! |
Propagate the dtype parameter through the intermediate COO format constructor, so the given dtype is preserved throughout the intermediate stages of creating a sparse matrix. Closes scipygh-13329.
Propagate the dtype parameter through the intermediate COO format constructor, so the given dtype is preserved throughout the intermediate stages of creating a sparse matrix. Closes scipygh-13329.
Reference issue
Fixes gh-13329
What does this implement/fix?
Propagates the
dtype
parameter through the intermediate COO format constructor.