-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
allow setting collection offsets to empty #22408
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
base: main
Are you sure you want to change the base?
Conversation
modified = mcollections.Collection( | ||
offsets=np.column_stack([[0, 1], [0, 1]]) | ||
) | ||
modified.set_offsets([[], []]) |
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 think that this should actually be column_stack
and I should get rid of the transpose in the set method. Most usage will be with column_stack
i suspect.
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.
Please check what other set_offsets
methods do. We should aim for consistency.
(np.asarray(self.convert_xunits(offsets[:, 0]), 'float'), | ||
np.asarray(self.convert_yunits(offsets[:, 1]), 'float'))) | ||
|
||
if offsets.shape == (2, 0): |
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.
if offsets.shape == (2, 0): | |
if offsets.shape == (0, 2): |
Which will require some changes to the tests.
The docs say(N, 2) so this should be the degenerate case of ((N, 2), .., (2, 2), (1, 2), (0, 2)) (the (2,) case is a special case for spelling (1, 2)).
Anyone can dismiss my review |
Fell free to move out of draft... |
Looking at this again, I think my comment is still valid. |
PR Summary
Fixes: #22401
Importantly allows this:
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).