Skip to content

API: register_extension_dtype class decorator #22666

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 4 commits into from
Sep 13, 2018

Conversation

TomAugspurger
Copy link
Contributor

Closes #22664

@TomAugspurger TomAugspurger added the ExtensionArray Extending pandas with custom dtypes or arrays. label Sep 11, 2018
@TomAugspurger TomAugspurger added this to the 0.24.0 milestone Sep 11, 2018
@pep8speaks
Copy link

Hello @TomAugspurger! Thanks for submitting the PR.

@@ -51,10 +50,6 @@ def test_eq_with_numpy_object(self, dtype):
def test_array_type(self, data, dtype):
assert dtype.construct_array_type() is type(data)

def test_array_type_with_arg(self, data, dtype):
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test could never pass or fail correctly. It would always raise a TypeError since the method doesn't take an argument.

@@ -77,9 +77,7 @@ def data_for_grouping():


class TestDtype(base.BaseDtypeTests):

def test_array_type_with_arg(self, data, dtype):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is a legit test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's it testing? That code wasn't ever run on master.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean with "That code wasn't ever run on master." ? That the test is never run, or that what it is testing is never used anywhere in the code?

Those tests are certainly running, but it is true that the base class test is not very useful (and also wrong with the string argument).
But I think it is still potentially useful to assert that the dtypes construct_array_type is giving an ExtensionArray class object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test was overridden by every subclass. Note that we still have https://github.com/pandas-dev/pandas/pull/22666/files/9b646e28656ca3c61ee8a221e16ad74bba2610c3#diff-32e4b328fc01507825a6249caac0cb21R50, which tests this properly.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that we still have .., which tests this properly.

Ah, yes, that is indeed what the other overridden ones were also doing, but then manually.

@jreback
Copy link
Contributor

jreback commented Sep 12, 2018

also can you change the registration of the pandas EA types to use the new register function (e.g. Categorical, Interval etc)

@codecov
Copy link

codecov bot commented Sep 12, 2018

Codecov Report

Merging #22666 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #22666      +/-   ##
==========================================
+ Coverage   92.17%   92.17%   +<.01%     
==========================================
  Files         169      169              
  Lines       50708    50717       +9     
==========================================
+ Hits        46740    46749       +9     
  Misses       3968     3968
Flag Coverage Δ
#multiple 90.58% <100%> (ø) ⬆️
#single 42.36% <100%> (ø) ⬆️
Impacted Files Coverage Δ
pandas/core/dtypes/base.py 100% <ø> (ø) ⬆️
pandas/core/dtypes/dtypes.py 96.08% <100%> (+0.03%) ⬆️
pandas/core/arrays/integer.py 94.53% <100%> (-0.03%) ⬇️
pandas/api/extensions/__init__.py 100% <100%> (ø) ⬆️
pandas/core/indexes/base.py 96.45% <0%> (ø) ⬆️
pandas/core/indexes/multi.py 95.41% <0%> (ø) ⬆️
pandas/io/formats/style.py 96.43% <0%> (ø) ⬆️
pandas/core/common.py 97.39% <0%> (+0.05%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 73dd6ec...2a21f7c. Read the comment docs.

@TomAugspurger
Copy link
Contributor Author

Updated for categorical and interval. Couldn't do the same for the various Integer dtypes, since they're generated dynamically.

@jreback
Copy link
Contributor

jreback commented Sep 12, 2018

Couldn't do the same for the various Integer dtypes, since they're generated dynamically.

https://github.com/pandas-dev/pandas/blob/master/pandas/core/arrays/integer.py#L621

just a 1-liner to change

@TomAugspurger
Copy link
Contributor Author

Right... fixed.

@TomAugspurger
Copy link
Contributor Author

All green (this was split from the SparseArray PR fyi. I think I have one or two more things to split before)

@jreback
Copy link
Contributor

jreback commented Sep 13, 2018

lgtm

though i think should re-evaluate the test (could be that wasn’t testing anything), but this should have a test

@TomAugspurger TomAugspurger merged commit 857515f into pandas-dev:master Sep 13, 2018
@TomAugspurger TomAugspurger deleted the ea-register branch September 13, 2018 11:27
aeltanawy pushed a commit to aeltanawy/pandas that referenced this pull request Sep 20, 2018
Sup3rGeo pushed a commit to Sup3rGeo/pandas that referenced this pull request Oct 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants