Skip to content

BUG: inspect.getmembers(Series) #38782

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 9 commits into from
Feb 7, 2021

Conversation

topper-123
Copy link
Contributor

@topper-123 topper-123 commented Dec 29, 2020

Make inspect.getmembers(Series) work, previously raised an AbstractMethodError.

xref: #38740

@topper-123 topper-123 changed the title TST: test inspect.getmembers(Series) BUG: inspect.getmembers(Series) Dec 29, 2020
@@ -302,7 +302,7 @@ ExtensionArray
Other
^^^^^

-
- ``inspect.getmembers(Series)`` no longer raises an ``AbstractMethodError`` (:issue:`38782`).
Copy link
Contributor

Choose a reason for hiding this comment

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

note we backported the other issue. ok for this too.

Copy link
Contributor

Choose a reason for hiding this comment

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

remove from here

@jreback jreback added Bug Compat pandas objects compatability with Numpy or Python functions labels Dec 29, 2020
original, such as DataFrame single columns slicing.
"""
raise AbstractMethodError(self)

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 isn't used on Series. Calling it on a Series should just result in an AttributeError.

@topper-123 topper-123 force-pushed the test_getmembers_series branch from 1e46304 to eeef0ef Compare December 29, 2020 16:54
@@ -302,7 +302,7 @@ ExtensionArray
Other
^^^^^

-
- ``inspect.getmembers(Series)`` no longer raises an ``AbstractMethodError`` (:issue:`38782`).
Copy link
Contributor

Choose a reason for hiding this comment

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

remove from here

@jreback jreback added this to the 1.2.1 milestone Dec 29, 2020
@jorisvandenbossche
Copy link
Member

Note there was quite some discussion about this on #31549 (it is also reported as a bug in python itself), and in the and this was fixed for _constructor_expanddim differently in #33628

I don't care much about how it is folved, but probably good to be consistent for _constructor_expanddim and _constructor_sliced ?

note we backported the other issue. ok for this too.

I would just leave it for 1.3 (it's not a regression like the other issue). You never know how some subclass might be using this method (or relying on the exact error class)

@jreback
Copy link
Contributor

jreback commented Dec 29, 2020

I would just leave it for 1.3 (it's not a regression like the other issue). You never know how some subclass might be using this method (or relying on the exact error class)

makes sense.

@jreback jreback modified the milestones: 1.2.1, 1.3 Dec 29, 2020
@topper-123
Copy link
Contributor Author

topper-123 commented Dec 30, 2020

I don't care much about how it is folved, but probably good to be consistent for _constructor_expanddim and _constructor_sliced ?

I've made a new version, where they're the same: _constructor_sliced is only for DataFrame (it doesn't make sense for Series) and _constructor_expanddim is only available on Series (doesn't make sense for DataFrame, now that NDFrame higher than 2 is gone).

``_constructor_sliced`` ``NotImplementedError`` ``Series``
``_constructor_expanddim`` ``DataFrame`` ``NotImplementedError``
=========================== ======================= =============
* ``DataFrame/Series._constructor``: Used when a manipulation result has the same (sub-)class as the original.
Copy link
Member

Choose a reason for hiding this comment

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

I would keep the "same dimension as the original", because it doesn't necessarily need to return the same class (eg a subclass' _constructor can return a non-subclassed DataFrame in certain cases)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't like "same dimension as the original" because it could be understood like e.g. an array could be used, which would be wrong. By using "(sub-)class" is is implied that for e.g. for Series you have to supply a Series or a subclass of a Series (but not a DataFrame or a 1-dim array).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this ok? My opinion is that it’s better to emphazise the type Here, rather than the dimensionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I’ve changed this to say dimension rather than subclass. IDT the next gwo lines shares this issue, but let me know.

@topper-123 topper-123 force-pushed the test_getmembers_series branch from 5f71dc3 to af40a78 Compare January 16, 2021 09:05
@topper-123 topper-123 modified the milestones: 1.3, 1.2.1 Jan 16, 2021
@topper-123 topper-123 force-pushed the test_getmembers_series branch from 2850242 to ed8528a Compare January 29, 2021 23:41
@topper-123
Copy link
Contributor Author

Ping.

@topper-123 topper-123 force-pushed the test_getmembers_series branch from ed8528a to 1b1bf16 Compare February 5, 2021 22:29
@jreback jreback merged commit 4e7151b into pandas-dev:master Feb 7, 2021
@jreback
Copy link
Contributor

jreback commented Feb 7, 2021

thanks @topper-123

CyberQin pushed a commit to CyberQin/pandas that referenced this pull request Feb 8, 2021
@topper-123 topper-123 deleted the test_getmembers_series branch February 8, 2021 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Compat pandas objects compatability with Numpy or Python functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants