-
Notifications
You must be signed in to change notification settings - Fork 10
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
Implements newaxis #35
Conversation
ndindex/slice.py
Outdated
>>> idx.newshape((8, 10), axis=1) | ||
(8, 6) | ||
""" | ||
from . import Tuple |
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.
Should be this at the top?
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.
You can try it but it might fail due to circular imports.
Code looks good to me |
@asmeurer - please review and merge |
ndindex/ndindex.py
Outdated
@@ -2,6 +2,9 @@ | |||
|
|||
from numpy import ndarray | |||
|
|||
newaxis = None |
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.
This needs to be implemented as an NDIndex subclass.
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.
OK, I just went with that NumPy does. Let me know if this is what you had in mind
Also: - Add Newaxis.reduce() to the See Also of other reduce() docstrings. - Do shape checking in Newaxis.reduce(). - Move raw up to the top of the class definition.
Also adds newaxes to the Tuple and ndindices hypothesis strategies, and updates the ndindices hypothesis strategy to use filter instead of composite (which makes it just ndindices instead of ndindices()).
I've pushed updates here. This is ready for review. |
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.
This is much more complicated than I had anticipated, thanks @asmeurer , I have no objections!
Yes, getting the logic for newaxis right in the various Tuple methods was not easy. However, I've run the hypothesis test suite with lots of examples and no failures, so I'm fairly confident the code here is correct. |
Closes #24