Skip to content
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

lib.is_scalar misses PEP 3141 numbers #22903

Closed
jbrockmendel opened this issue Sep 30, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@jbrockmendel
Copy link
Member

commented Sep 30, 2018

Looking at np.isscalar's docstring I see:

    NumPy supports PEP 3141 numbers:

    >>> from fractions import Fraction
    >>> isscalar(Fraction(5, 17))
    True
    >>> from numbers import Number
    >>> isscalar(Number())
    True

pandas lib.is_scalar doesn't recognize Number or Fraction.

@brute4s99

This comment has been minimized.

Copy link
Contributor

commented Sep 30, 2018

are you referring to this ?

@jbrockmendel

This comment has been minimized.

Copy link
Member Author

commented Sep 30, 2018

Same function, yes

@brute4s99

This comment has been minimized.

Copy link
Contributor

commented Oct 2, 2018

@jbrockmendel ok, the problem is something like this :-

The function is currently limited to the dtypes specified here.
This is backed by my findings upon close looks to the is_scalar definition for pandas,
So I need to simply add entries for some more dtypes, currently Number and Fraction.

As seen within CPython's codebase, the underlying functionality might be same as comparing through type function.

@brute4s99

This comment has been minimized.

Copy link
Contributor

commented Oct 2, 2018

I'll just call np.isscalar() ! 😄

@brute4s99 brute4s99 referenced this issue Oct 2, 2018

Merged

Support for PEP 3141 numbers #22952

4 of 4 tasks complete

@jreback jreback added this to the 0.24.0 milestone Oct 3, 2018

brute4s99 added a commit to brute4s99/pandas that referenced this issue Oct 8, 2018

brute4s99 added a commit to brute4s99/pandas that referenced this issue Nov 19, 2018

brute4s99 added a commit to brute4s99/pandas that referenced this issue Nov 19, 2018

@brute4s99

This comment has been minimized.

Copy link
Contributor

commented Nov 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.