-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Make length type match index type in sparse vectors #39645
Conversation
Doesn't this also affect the cases with |
I'm not sure there is something like implicit type assumptions.
Yes. Do you see any problem with that? I mean, something we should consider or test? |
I'm not sure it's a problem in the wild use cases, but the error below is essentially the same as the issue #39644. It doesn't seem to be an edge case, at least compared to the case where julia> SparseVector(1000, [0x4], [5.0])
ERROR: InexactError: trunc(UInt8, 1000) |
I see. But this is the same error we have when the length exceeds the length type. For instance, we also have currently: julia> y = SparseVector(typemax(Int32), Int32[4], [5])
2147483647-element SparseVector{Int64, Int32} with 1 stored entry:
[4 ] = 5
julia> kron(y, y)
ERROR: InexactError: trunc(Int32, 6442450945) I guess the question is whether we can have common operations that would blow up y = SparseVector(typemax(Int32), [4], [5])
A = spzeros(Int64(typemax(Int32))+1,typemax(Int32))
A*y # 2147483648-element SparseVector{Float64, Int64} with 0 stored entries The point is that there is some limit no matter if we set |
Such tricky business! |
There's #37741, which seems to suggest it should be fine to return a non- |
Yes, that PR makes it official that length does not need to be an julia> typeof(length(1:BigInt(100_000_000)^1000))
BigInt |
The "return" type doesn't matter. It can be converted to |
IMO, the following statement (from #39644 (comment)) is "false".
In other words, the type mismatch itself is not a "bug" that should be fixed. If we make a change, it is a specification change. The inability to create a sparse array larger than |
I have no preference regarding this change, but I'm also not sure I follow. If you have indices of some type |
If the problem is that the user has false expectations, then we can warn against Integer literals are interpreted as In any case, the relationship between the problem and the solution should be clear. For another problem, there may be another, better solution. |
Removed backport label since this feels a bit iffy to backport this late into the release process. |
Shall we close it together with #39644, or are there good reasons to do it? I agree that the exact implications are hard to overlook, so this might be a bit dangerous. Do we consider a PkgEval run worth it? |
Just to be on the safe side, we should do a PkgEval run and merge it if it looks good. We probably shouldn't backport it though. |
@nanosoldier |
Something went wrong when running your job:
Logs and partial data can be found here |
Oops ran the wrong one (but I suppose the benchmarks are broken currently?) @nanosoldier |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt |
Can't quite tell if the errors are related to this PR - but it may be worthwhile to rebase on master and then run pkgeval again. |
cf85344
to
c425d35
Compare
@nanosoldier |
For all I can say, I coulnd't find any failure (in the first evalpkg run) that seemed related. |
Your package evaluation job has completed - possible new issues were detected. A full report can be found here. cc @maleadt |
Again, none of the failures look related. |
This can be considered a bugfix.This change should be harmless. The type of then
field is as concrete now (Ti
) as it used to be (Int
). Marking for backport tentatively.Closes #39644.