You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working with 4/5/6D arrays and I have found so many bugs caused by supplying 4 indexes to a 5D array, which just silently returns an (essentially random) element.
I think this should be considered a bug as it is very easy to do by mistake and leads to data corruption.
Is this regarded as a feature? What is the reasoning behind it, rather than requiring colons to fill out the missing indexes?
The text was updated successfully, but these errors were encountered:
Yes, it is a feature, albeit one that was inherited from other languages, and one whose utility in Julia is decreasing as time goes on. When you omit dimensions, the last index given is considered a linear index over the trailing size of the array. This is generally called linear indexing.
It's an extension of the ability to write for i=1:length(A) and index with i, regardless of the dimensionality of A. But Julia has recently gained more iteration and indexing tools that allow things like for i in eachindex(A) (which can supply very fast indices that index at the full dimensionality) and for i in CartesianRange(size(A)[3:end]) (which explicitly allows for the partial linear indexing behavior you've been accidentally running into). So, yes, there's been talk of removing at least the partial linear indexing behavior that you've been running into — I'm going to close this as a duplicate of #5396.
I am working with 4/5/6D arrays and I have found so many bugs caused by supplying 4 indexes to a 5D array, which just silently returns an (essentially random) element.
I think this should be considered a bug as it is very easy to do by mistake and leads to data corruption.
Is this regarded as a feature? What is the reasoning behind it, rather than requiring colons to fill out the missing indexes?
The text was updated successfully, but these errors were encountered: