-
-
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 (again) length type match index type in sparse vectors #45937
Comments
v1.7.3 was released May 6, 2022, and back then I thought 1.8 imminent, and it would be the last 1.7 release. I realize 1.8 isn't released, so if understand correctly you want 1.7 to be fixed. If 1.8 is released (soon), does it then matter? [I see activity hours ago on "Backports for 1.8-rc2/1.8.0" on the backport branch. So rc2 might be imminent, or just 1.8.0? But I also see "backport 1.7" label being applied 4 days ago, so might not be too late (is that just done out of habit, with the others?).] Julia 1.7 will then no longer be the stable supported version (unless if made LTS...). |
If we commit to returning Int64, I'm happy to have it written somewhere, in the documentation or the release notes. |
#39645 addresses Base.length(x::SparseVector) = x.n (EDIT: just like we have a specialization Then the return type of |
Wait, can you provide an example of what you think changed or regressed? On v1.8rc1 I get julia> using SparseArrays, Test
julia> y = SparseVector(Int128(8), Int128[4], [5])
8-element SparseVector{Int64, Int128} with 1 stored entry:
[4] = 5
julia> @test y isa SparseVector{Int,Int128}
Test Passed
julia> @test @inferred size(y) == (@inferred(length(y))::Int128,)
Test Passed
julia> typeof(length(y))
Int128 Note that #39645 did not touch any |
@dkarrasch The regression is only when the size of the index is smaller than 64 bit (probably due to Julia 1.8
Julia 1.7
|
Thanks, then my proposal above should work. |
In julia 1.6,
typeof(length(SparseArray))
always returned an Int64.But in julia 1.7, after #39645 it returned the same type as the index type.
Now in julia 1.8rc1, the type is again always an Int64.
The regression was introduced by #41510, since length(array) is calculated through prod.
On the other hand, I understand that the promotion may be necessary for n-dimensional arrays, since the length may overflow the type of the individual dimensions. So, if we want to stick to Int64, maybe we could document it in the julia 1.8 release notes?
thanks
The text was updated successfully, but these errors were encountered: