-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
fix #17372, only accept Int
in reshape
#17567
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
Conversation
sure we don't have any tests that use this? this is one possible decision to make on that issue but I wouldn't consider turning it into an error a "fix" |
d2ea21e
to
848e9da
Compare
It was always an error before. And I certainly hope we're not testing that passing a non- |
the issue (and at least one duplicate of it) is saying "it would be nice if this weren't an error." I agree the inconsistency here is good to fix, but a looser signature would be more convenient |
For that we would have to change a large number of places, plus many packages. |
typealias AbstractVecOrMat{T} Union{AbstractVector{T}, AbstractMatrix{T}} | ||
typealias RangeIndex Union{Int, Range{Int}, AbstractUnitRange{Int}, Colon} | ||
typealias DimOrInd Union{Integer, AbstractUnitRange} | ||
typealias IntOrInd Union{Int, AbstractUnitRange} |
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.
Maybe make it AbstractUnitRange{Int}
?
I like this solution. There are a lot of inconsistencies though. Here are some other examples where we specify the desired size of something using Lines 75 to 85 in f331e02
Line 341 in f331e02
Line 29 in f331e02
Line 166 in f331e02
Line 230 in f331e02
Lines 33 to 40 in f331e02
It would be great to come up with some kind of consistent policy for 0.6. |
Fair enough; I will drop |
Or we can go from Integer to Int; I don't really care which we choose. I think the marginal benefit of allowing Integer is pretty small. |
Hmm, though maybe 32bit systems |
x-ref #16582 as well |
Before, the definition of `reshape` that returns a `ReshapedArray` accepted any integer, but the Array->Array definition only accepted `Int`, so passing a different type of integer strangely resulted in a different type of array. This behavior was observed as part of JuliaLang#17372.
I believe this is a bug, since it's very strange that passing an
Int32
resulted in aReshapedArray
while passing anInt
resulted in anArray
.This synchronizes
DimOrInd
with other index-related types, all of which useInt
. This will also affect packages like DistributedArrays, which also assumeInt
.