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

FrozenNDArray cannot repr scalars #9031

Closed
behzadnouri opened this issue Dec 7, 2014 · 4 comments · Fixed by #23396
Closed

FrozenNDArray cannot repr scalars #9031

behzadnouri opened this issue Dec 7, 2014 · 4 comments · Fixed by #23396
Labels
Compat pandas objects compatability with Numpy or Python functions Internals Related to non-user accessible pandas implementation
Milestone

Comments

@behzadnouri
Copy link
Contributor

on master:

>>> from pandas.core.base import FrozenNDArray
>>> a = FrozenNDArray(1)
>>> a
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.4/site-packages/pandas-0.15.1_192_g7bd1b24-py3.4-linux-x86_64.egg/pandas/core/base.py", line 65, in __repr__
    return str(self)
  File "/usr/lib/python3.4/site-packages/pandas-0.15.1_192_g7bd1b24-py3.4-linux-x86_64.egg/pandas/core/base.py", line 44, in __str__
    return self.__unicode__()
  File "/usr/lib/python3.4/site-packages/pandas-0.15.1_192_g7bd1b24-py3.4-linux-x86_64.egg/pandas/core/base.py", line 268, in __unicode__
...
...
RuntimeError: maximum recursion depth exceeded while calling a Python object

keeps going back and forth between __str__ and __unicode__. a workaround would be to change self on this line to self if self.ndim else self.item().

I ran into this bug while taking .max on the array:

>>> xs
FrozenNDArray([1, 2, 3], dtype='int64')
>>> xs.max()
RuntimeError: maximum recursion depth exceeded while calling a Python object

it is kind of unusual to me that here .max returns a zero dimensional array, whereas numpy returns a scalar:

>>> xs
FrozenNDArray([1, 2, 3], dtype='int64')
>>> type(xs.max())
<class 'pandas.core.base.FrozenNDArray'>
>>> type(np.array([1, 2, 3]).max())
<class 'numpy.int64'>

in particular, np.isscalar returns differently for the two:

>>> np.isscalar(np.array([1, 2, 3]).max())
True
>>> np.isscalar(FrozenNDArray([1, 2, 3]).max())
False
@jreback
Copy link
Contributor

jreback commented Dec 7, 2014

this whole notion of a FrozenNDarray can be taken out actually
it's only used in 1 place and u can just substitute a ndarray there

this was originally was needed to make index immutable but that's handled elsewhere now

@jreback jreback added Compat pandas objects compatability with Numpy or Python functions Internals Related to non-user accessible pandas implementation labels Dec 7, 2014
@dsm054
Copy link
Contributor

dsm054 commented Jun 7, 2017

Can we yank FrozenNDArray now, then? I guess we'd need to make sure that pickles would still work, but apart from that, as you note, all the references seem very shallow now.

@jreback
Copy link
Contributor

jreback commented Jun 7, 2017

@dsm054 yes as I said a while back its not necessary. pickle compat is 'easy', just follow the pattern in pandas.compat.pickle_compat.py (might need a slight modification as this is not a rename but shouldn't be too hard).

@jreback
Copy link
Contributor

jreback commented Jun 7, 2017

xref #15477 and this #15506 (last was reverted, something odd changed in making the doc build take way longer).

@jreback jreback added this to the Next Major Release milestone Jun 7, 2017
gfyoung added a commit to forking-repos/pandas that referenced this issue Oct 28, 2018
gfyoung added a commit to forking-repos/pandas that referenced this issue Oct 28, 2018
gfyoung added a commit to forking-repos/pandas that referenced this issue Oct 28, 2018
@jreback jreback modified the milestones: Contributions Welcome, 0.24.0 Oct 30, 2018
jreback pushed a commit that referenced this issue Oct 30, 2018
tm9k1 pushed a commit to tm9k1/pandas that referenced this issue Nov 19, 2018
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
Pingviinituutti pushed a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019
@mspacek mspacek mentioned this issue May 13, 2020
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Compat pandas objects compatability with Numpy or Python functions Internals Related to non-user accessible pandas implementation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants