Skip to content

lib.is_scalar misses PEP 3141 numbers #22903

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

Closed
jbrockmendel opened this issue Sep 30, 2018 · 5 comments · Fixed by #22952
Closed

lib.is_scalar misses PEP 3141 numbers #22903

jbrockmendel opened this issue Sep 30, 2018 · 5 comments · Fixed by #22952
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@jbrockmendel
Copy link
Member

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.

@tm9k1
Copy link
Contributor

tm9k1 commented Sep 30, 2018

are you referring to this ?

@jbrockmendel
Copy link
Member Author

Same function, yes

@sinhrks sinhrks added Numeric Operations Arithmetic, Comparison, and Logical operations Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff labels Oct 1, 2018
@tm9k1
Copy link
Contributor

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

@tm9k1
Copy link
Contributor

tm9k1 commented Oct 2, 2018

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

@jreback jreback added this to the 0.24.0 milestone Oct 3, 2018
tm9k1 added a commit to tm9k1/pandas that referenced this issue Oct 8, 2018
tm9k1 added a commit to tm9k1/pandas that referenced this issue Nov 19, 2018
tm9k1 added a commit to tm9k1/pandas that referenced this issue Nov 19, 2018
@tm9k1
Copy link
Contributor

tm9k1 commented Nov 20, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants