EllipsisNotation.jl icon indicating copy to clipboard operation
EllipsisNotation.jl copied to clipboard

"end" indexing not working properly

Open Sixzero opened this issue 4 years ago • 7 comments

I believe there is something wrong with indexing. Code:

using EllipsisNotation
A = randn(2,3,4);
@show size(A[.., 1:end]);

Output:

julia> using EllipsisNotation

julia> A = randn(2,3,4);

julia> @show size(A[.., 1:end]);
size(A[.., 1:end]) = (2, 3, 3)

The output should size should be (2, 3, 4) not (2, 3, 3).

I believe this is a critical issue and should be noted somewhere.

What is happeneing is that end will be equal to size(A, 2), which is 3 and not size(A, 3) which is 4 what is the real position of the "end" in this case.

Also worth noting: @show size(A[.., 1:end-1]) # outputs: (2, 3, 2)

So basically at least the problem is with indexing positions and nothing more.

Sixzero avatar Sep 10 '20 11:09 Sixzero

Thanks the best thing to do would be to try and fix this. @mbauman might have ideas?

ChrisRackauckas avatar Sep 11 '20 02:09 ChrisRackauckas

This is effectively the same as https://github.com/JuliaLang/julia/issues/35681 and won't be fixable until that one is.

mbauman avatar Sep 15 '20 19:09 mbauman

Can we add a note of this in the Readme? Like a warning admonition.

cossio avatar Jun 09 '22 19:06 cossio

Yeah, it's worth mentioning.

ChrisRackauckas avatar Jun 09 '22 21:06 ChrisRackauckas

https://github.com/ChrisRackauckas/EllipsisNotation.jl/pull/44

cossio avatar Jun 10 '22 07:06 cossio

Would it make sense to add a pointer to EndpointRanges.jl in the README note? Using iend seems to be working correctly:

julia> using EllipsisNotation

julia> using EndpointRanges

julia> A = randn(2,3,4);

julia> @show size(A[.., 1:iend]);
size(A[.., 1:iend]) = (2, 3, 4)

julia> A[.., 1:iend] == A
true

Socob avatar Mar 22 '23 23:03 Socob

Sounds like a good idea, please submit a PR

jishnub avatar May 25 '23 06:05 jishnub