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

Comments

Projects
None yet
3 participants
@behzadnouri
Copy link
Contributor

commented Dec 7, 2014

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

This comment has been minimized.

Copy link
Contributor

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

@dsm054

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

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 added a commit that referenced this issue Oct 30, 2018

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

Pingviinituutti added a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019

Pingviinituutti added a commit to Pingviinituutti/pandas that referenced this issue Feb 28, 2019

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.