-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
add support for python ABCs #4547
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
@@ -960,6 +961,12 @@ def _can_coerce_all(dtypelist, start=0): | |||
thisind += 1 | |||
return None | |||
|
|||
def _register_types(): | |||
numbers.Integral.register(integer) |
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.
Not sure about this. Integral subtypes Rational and should have numerator and denominator properties. I don't think we have those (yet).
The two commits can be squashed into one, which should begin |
So, now we have numerator and denominator, too. |
@@ -4030,6 +4059,9 @@ initialize_numeric_types(void) | |||
PyVoidArrType_Type.tp_as_mapping = &voidtype_as_mapping; | |||
PyVoidArrType_Type.tp_as_sequence = &voidtype_as_sequence; | |||
|
|||
|
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.
One blank line would suffice ;)
That was fast. LGTM. Please add a note to the enhancements section of |
Beginning with version 2.6, python supports abstract base classes, which contain a class hierarchy for numbers. This class hierarchy is very similar to the one of numpy, so it is very easy to register the numpy type hierarchy with the python type hierarchy. This patch adds those registrations and also adds unit tests for it.
numbers.Integral types are supposed to have a numerator and denominator attribute. This adds those two trivial attributes.
Merged, thanks @tecki. |
Beginning with version 2.6, python supports abstract base classes,
which contain a class hierarchy for numbers. This class hierarchy is
very similar to the one of numpy, so it is very easy to register
the numpy type hierarchy with the python type hierarchy.
This pull request adds those registration and test cases for it.