Skip to content

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

Merged
merged 2 commits into from
Mar 25, 2014
Merged

add support for python ABCs #4547

merged 2 commits into from
Mar 25, 2014

Conversation

tecki
Copy link
Contributor

@tecki tecki commented Mar 25, 2014

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.

@@ -960,6 +961,12 @@ def _can_coerce_all(dtypelist, start=0):
thisind += 1
return None

def _register_types():
numbers.Integral.register(integer)
Copy link
Member

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).

@charris
Copy link
Member

charris commented Mar 25, 2014

The two commits can be squashed into one, which should begin ENH:. Otherwise, LGTM modulo the Integral type.

@tecki
Copy link
Contributor Author

tecki commented Mar 25, 2014

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;


Copy link
Member

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 ;)

@charris
Copy link
Member

charris commented Mar 25, 2014

That was fast. LGTM. Please add a note to the enhancements section of doc/release/1.9.0-notes.rst.

tecki added 2 commits March 25, 2014 16:48
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.
charris added a commit that referenced this pull request Mar 25, 2014
add support for python ABCs
@charris charris merged commit 2f0494c into numpy:master Mar 25, 2014
@charris
Copy link
Member

charris commented Mar 25, 2014

Merged, thanks @tecki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants