Closed nchisholm closed 7 months ago
Thanks for filing this, I guess I never use reverse on multidimensional arrays without dims
. It should totally be fixed.
As a rule anything like that this isn't exactly the same as Base AbstractArray
behavior is a bug rather than something intentional. A DimArray
should be a conforming AbstractArray
except in cases where AbstractArray
would error - e.g. by using a Dimension
in dims
for `reverse. (bugs like this exist because we add methods to try and make the dimensions do sensible things to match the array behaviour, and sometimes don't get the implementation right)
I will try to enforce this when the BaseInterfaces.jl array interface is more complete, its just hard to comprehensively test every part of the AbstractArray
interface currently.
You're welcome, and seems like a quick fix. May I submit a PR?
Absolutely!
Applying
reverse
to aDimArray
(without adims=
argument) reverses along the first dimension only. On the other hand, a regularArray
has all its dimensions reversed. Should the default behavior ofreverse(::DimArray)
be changed to act along all dimensions to be more consistent with the usual behavior? If this was instead an intentional design choice, perhaps we could add a note to the documentation somewhere.Example:
Also, note that
reverse(da, dims=:)
currently throws "ArgumentError:dims
are notDimension
s", although it works (and is the default) forArray
s. Perhaps we could support it to give an easy way to reverse along all dimensions, especially if defaulting to that behavior is problematic.