-
-
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
Dot syntax involving CartesianIndex and Tuple #29597
Comments
The error message says to use |
Thanks, I am fixing the code locally. I guess my question is more on the lines of how useful this restriction with |
AFAIK the error is there because it would be very slow anyway? Better throw than trap people. Cc: @timholy |
Not quite sure what to do here. #26227 has the most nuanced thinking I know of on this topic. |
Looking at this again, I should have pointed out the obvious: why do you need to offset with a tuple? Just convert it to a julia> i2 = CartesianIndex(3,5)
CartesianIndex(3, 5)
julia> i1 = CartesianIndex(1,1)
CartesianIndex(1, 1)
julia> i1+i2
CartesianIndex(4, 6) The case of what we should do about scalar increments is harder to figure out. |
Hi Tim,
In many cases we offset with Dims objects. I could convert them to
CartesianIndex but I was wondering why we dont have methods to do this
conversion for the user?
Is there any penalty in converting tuples to CartesianIndex or in using
idx.I?
…On Fri, Oct 12, 2018, 06:40 Tim Holy ***@***.***> wrote:
Looking at this again, I should have pointed out the obvious: why do you
need to offset with a tuple? Just convert it to a CartesianIndex:
julia> i2 = CartesianIndex(3,5)CartesianIndex(3, 5)
julia> i1 = CartesianIndex(1,1)CartesianIndex(1, 1)
julia> i1+i2CartesianIndex(4, 6)
The case of what we should do about scalar increments is harder to figure
out.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#29597 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADMLbYgO4EU16z6v3M0BfEvwXCI7vaZIks5ukGOdgaJpZM4XXaXK>
.
|
If you're worried about penalties, instead of asking others just try benchmarking yourself. As far as methods to do conversions, CartesianIndex is conceptually a scalar and tuple is a container. That makes it unclear what to do: should you generate 3 CartesianIndexes, each with a broadcasted scalar-add? Or add them elementwise? |
I would like to understand how this operation should be done instead?
It is often the case that we need to offset from a
CartesianIndex
with aDims
orTuple
object. I could convert theTuple
to aCartesianIndex
and avoid the dot syntax, or I could do@. start.I + offset
to get access to the underlying Tuple. It is not that elegant though to have to think aboutTuple
vs.CartesianIndex
.Should the syntax above be allowed?
The text was updated successfully, but these errors were encountered: