Skip to content
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

Inconsistent errors with SparseArray construction (new in 1.2) #32548

Closed
sbromberger opened this issue Jul 10, 2019 · 8 comments
Closed

Inconsistent errors with SparseArray construction (new in 1.2) #32548

sbromberger opened this issue Jul 10, 2019 · 8 comments
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays

Comments

@sbromberger
Copy link
Contributor

In 1.1:

julia> a = spzeros(Float64, UInt8, 255, 255)
255×255 SparseMatrixCSC{Float64,UInt8} with 0 stored entries

julia> a = spzeros(Float64, UInt8, 0xff, 0xff)
255×255 SparseMatrixCSC{Float64,UInt8} with 0 stored entries

But in 1.2, there apparently was a change to ensure that the number of nonzero entries could fit:

julia> a = spzeros(Float64, UInt8, 255, 255)
ERROR: ArgumentError: maximal nnz+1 (m*n+1 = 65026) does not fit in Ti = UInt8

However, the check is not applied consistently:

julia> a = spzeros(Float64, UInt8, 0xff, 0xff)
255×255 SparseMatrixCSC{Float64,UInt8} with 0 stored entries
@StefanKarpinski
Copy link
Member

Note that this might be a 1.2 regression so we should take a look at it on triage.

@StefanKarpinski StefanKarpinski added the triage This should be discussed on a triage call label Jul 10, 2019
@StefanKarpinski StefanKarpinski added this to the 1.2 milestone Jul 10, 2019
@sbromberger
Copy link
Contributor Author

(Just a guess that the error checks by multiplying the dimensions together to get the maximum possible number of nnzs, and 0xff * 0xff overflows to 0x01 which, when increased by 1, is still less than typemax(UInt8).)

@KristofferC
Copy link
Member

KristofferC commented Jul 10, 2019

This was reverted for 1.2 because it was breaking (#31667). The PR introducing this was then re-merged 2 weeks ago #31724 and has not been backported so I am pretty sure this only exists on master.

@KristofferC KristofferC removed this from the 1.2 milestone Jul 10, 2019
@StefanKarpinski
Copy link
Member

This was reverted for 1.2

That's a relief. Sorry for the false alarm.

@StefanKarpinski StefanKarpinski added bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays labels Jul 10, 2019
@JeffBezanson
Copy link
Member

I believe this and #32539 were caused by the same set of changes.

@sbromberger
Copy link
Contributor Author

Thank you very much for the quick analysis.

@JeffBezanson
Copy link
Member

Fixed by #31724.

@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Aug 1, 2019
@StefanKarpinski
Copy link
Member

Seems to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior sparse Sparse arrays
Projects
None yet
Development

No branches or pull requests

4 participants