-
-
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
Deprecate +(::CartesianIndex, ::Number) #26227
Comments
Yes, that seems hard to justify. One is tempted to deprecate this to What is this used for, anyway? Could we just deprecate it to its definition |
It's used in |
That use does not justify the method, IMO. |
Yes, this seems like a good idea. I would bet that some folks might expect A slightly simpler deprecation would be
|
Argument in favour of julia> CartesianIndex((1,2))[1]
1 Argument against: julia> CartesianIndex((1,2))|>collect
ERROR: iteration is deliberately unsupported for CartesianIndex. Use `I` rather than `I...`, or use `Tuple(I)...`
Stacktrace:
[1] error at ./error.jl:33 [inlined]
[2] start at ./multidimensional.jl:157 [inlined]
[3] copyto! at ./abstractarray.jl:611 [inlined]
[4] _collect at ./array.jl:481 [inlined]
[5] collect at ./array.jl:475 [inlined]
[6] |>(::CartesianIndex{2}, ::typeof(collect)) at ./operators.jl:744
[7] top-level scope I don't have a strong feeling. (I came across it because I have code in BlockArrays.jl that mimicks |
I don't want to use broadcasting here precisely because |
Sorry I missed this discussion when real life intruded. The ability to add scalars is most often used when writing multidimensional algorithms, for example the TBH I am not entirely convinced we needed to deprecate this: since a CartesianIndex is not an iterable object, deprecating If we want to keep this deprecation, #26284 is not bad though it probably should have been |
Edit: Sorry, just saw mbauman's explanation. |
#26227 (comment). Though perhaps we could add a specially-dispatching version, i.e. Broadcast.broadcasted(::typeof(+), I::CartesianIndex, i::Integer) = CartesianIndex(Tuple(I) .+ i) and thus avoid "poisoning" them for general use in broadcasting. |
I’ve been using Perhaps this system could work here: there’d be a |
|
Hmm, the docs are imprecise about that point. It is also wrong for Sparse arrays: the behaviour of Where it comes up is that |
I agree; perhaps I'm speaking more from my original intent than what it evolved into. I'm not certain it's not actually true in practice for
I agree that behavior depends on the arguments but I don't think that's really a consequence of the I'd say this is different: you're advocating using |
This seems inconsistent:
The text was updated successfully, but these errors were encountered: