-
Notifications
You must be signed in to change notification settings - Fork 323
Add insert/remove_axis_inplace for IxDyn arrays #533
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
Conversation
Without these methods, users must have ownership of dynamic-dimensional arrays to insert/remove axes, which is unnecessarily restrictive.
90f65d6
to
228a15e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
let len = self.len_of(axis); | ||
assert_ne!(len, 0, "Length of removed axis must be nonzero."); | ||
self.dim = self.dim.remove_axis(axis); | ||
self.strides = self.strides.remove_axis(axis); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess removing an axis can never make us lose the first element (at index [0, 0, ..]) right, so we don't need to recompute the array's pointer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's correct. We need to assert that the axis length is nonzero for a similar reason.
Remove is surprising, maybe just make it clear to the user that it's like an in place slice, we hide some elements and can't get them back. Weird for owned arrays, but we already have the same thing in slicing, so it makes sense. |
I can certainly document this, but I agree it's still weird. I've always thought that The question remains, though, what to do with
The problem with this is that changing A workaround for the difficult-to-catch breaking change issue is the following. I prefer this naming scheme anyway because it's more similar to the
What do you think? |
Sounds good! I guess |
See #537, which does the renames mentioned above, except using |
Closing in favor of #537. |
Without these methods, users must have ownership of dynamic-dimensional arrays to insert/remove axes, which is unnecessarily restrictive.
This is motivated by #528.