-
-
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 CartesianRange an AbstractArray and deprecate sub2ind and ind2sub #25113
Conversation
OK, thanks! I was contemplating giving this a gentle bump today, but you beat me to it :) Just to be sure: the addition of the |
I'm OK with it, and nothing dramatically better occurs to me either. |
The name seems clear enough to me. Would it be at all helpful to have a |
|
Or the other option would be to rename |
But its main role is as an iterator, where |
Ok, then |
I kind of like |
Change to |
Though the problem is that neither of those captures the notion that you're not allowed to skip entries (this is the main distinction with the more general product iterator). |
Since they both are arrays, maybe |
OK, let's go with |
So the doc string for this starts with
So maybe |
Those sound fine too, except that I'm not convinced renaming |
I have meetings over the next couple of hours, but if some consensus emerges I'll implement the changes this evening. |
Even though |
Since |
Another idea: |
Fundamentally it is a product of |
I think the usage is fairly limited and we can femtoclean this fairly easily, so let's just focus on getting the name right. To be honest, I think this is really useful functionality, but the concepts are a little difficult to wrap your head around – which is precisely the kind of situation where nailing the terminology and naming really helps. For me, understanding that these are objects that capture the transformation done by So let me see if I can explain it correctly... A Well, I'm not sure that was helpful but I can see why naming this is hard... |
OK, so what about |
|
Those work for me. I can polish this up (or @barche can take it over again, whoever gets to it first). |
Makes sense... |
116ae09
to
cd67176
Compare
cd67176
to
e261a40
Compare
circleci seems hung. I'll merge this shortly barring objections. |
Unless I'm not seeing this properly on my phone, I think news is not updated with the latest rename? |
Good catch, thanks! |
@barche, I also just wanted to say that I'm unreasonably happy about this change 🙂. This change just feels right, thanks for doing it! |
@timholy Thanks, though I must say most improvements happened thanks to the useful comments after the initial PR, so for me this illustrates the value of collaborative development. |
To help ancient Julia users migrate The following expression is equivalent to CartesianIndices((10, 10))[18] The following expression is equivalent to LinearIndices((10, 10))[2, 6] =============== Modification Note =============== |
If you use julia-0.7 you get deprecation warnings that tell you this. But there are also easier syntaxes to remember: cartind = CartesianIndices(A) # A is your array
inds = cartind[18]
linind = LinearIndices(A)
i = linind[2, 6] See also https://discourse.julialang.org/t/psa-replacement-of-ind2sub-sub2ind-in-julia-0-7/14666 |
And you can also omit the CartesianIndices((10, 10))[18] |
A squashed and
indices
->axes
version of #24715. CC @barche