-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
REF: Changed ExtensionDtype inheritance #20363
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
REF: Changed ExtensionDtype inheritance #20363
Conversation
`is_extension_array_dtype(dtype)` was incorrect for dtypes that haven't implemented the new interface yet. This is because they indirectly subclassed ExtensionDtype. This PR changes the hierarchy so that PandasExtensionDtype doesn't subclass ExtensionDtype. As we implement the interface, like Categorical, we'll add ExtensionDtype as a base class. Before: ``` DatetimeTZDtype <- PandasExtensionDtype <- ExtensionDtype (wrong) CategoricalDtype <- PandasExtensionDtype <- ExtensionDtype (right) After: DatetimeTZDtype <- PandasExtensionDtype \ - _DtypeOpsMixin / ExtensionDtype ------ CategoricalDtype - PandasExtensionDtype - \ \ \ -_DtypeOpsMixin \ / ExtensionDtype ------- ``` Once all our extension dtypes have implemented the interface we can go back to the simple, linear inheritance structure.
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.
can you add a test that asserts is_extension_array (or not) for each of the current pandas extension types (and so should only be True for CategoricalDtype, but false for Interval, Period, Datetimewtz)
Codecov Report
@@ Coverage Diff @@
## master #20363 +/- ##
==========================================
+ Coverage 91.78% 91.79% +0.01%
==========================================
Files 152 152
Lines 49196 49186 -10
==========================================
- Hits 45153 45152 -1
+ Misses 4043 4034 -9
Continue to review full report at Codecov.
|
Added tests for each extension dtype. Will have to move from |
is_extension_array_dtype(dtype)
was incorrect for dtypes that haven'timplemented the new interface yet. This is because they indirectly subclassed
ExtensionDtype.
This PR changes the hierarchy so that PandasExtensionDtype doesn't subclass
ExtensionDtype. As we implement the interface, like Categorical, we'll add
ExtensionDtype as a base class.
Before:
Once all our extension dtypes have implemented the interface we can go back
to the simple, linear inheritance structure.