Skip to content

BUG?: should ComplexBlock._can_hold_element/should_store check itemsize? #32878

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 Mar 21, 2020 · 3 comments · Fixed by #45285
Closed

BUG?: should ComplexBlock._can_hold_element/should_store check itemsize? #32878

jbrockmendel opened this issue Mar 21, 2020 · 3 comments · Fixed by #45285
Labels
Bug Complex Complex Numbers Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@jbrockmendel
Copy link
Member

jbrockmendel commented Mar 21, 2020

arr = np.arange(5).astype("c8")
ser = pd.Series(arr)
val = np.finfo(np.float64).max
val = val.astype("c16")

>>> val
(1.7976931348623157e+308+0j)

ser[0] = val

>>> ser
0             inf+0.000000e+00j
1    1.000000e+00+0.000000e+00j
2    2.000000e+00+0.000000e+00j
3    3.000000e+00+0.000000e+00j
4    4.000000e+00+0.000000e+00j
dtype: complex64

For IntBlock we check the itemsize to avoid overflows, but for FloatBlock and ComplexBlock we do not, so we get the inf here. Should we instead be upcasting?

@jbrockmendel
Copy link
Member Author

@jorisvandenbossche when convenient, i'd like to get your thoughts on this, #33469, and #33830

@jorisvandenbossche
Copy link
Member

For this issue, can you show a similar example using int?

@jbrockmendel
Copy link
Member Author

Welp I was wrong about IntegerBlock avoiding overflows:

arr = np.arange(5).astype("i4")
ser = pd.Series(arr)
val = np.int64(np.iinfo(np.int64).max)

ser[0] = val

>>> ser
0   -1
1    1
2    2
3    3
4    4
dtype: int32

@jbrockmendel jbrockmendel added API Design Complex Complex Numbers labels Oct 12, 2020
@mroeschke mroeschke added Bug Indexing Related to indexing on series/frames, not to indexes themselves and removed API Design labels Jul 30, 2021
@jreback jreback added this to the 1.5 milestone Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Complex Complex Numbers Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants