Uint Series can be upcast to int64 unexpectedly #395
Replies: 4 comments
-
Thanks for posting this issue. The issue here is that with any usage of The reason I think there is no other option is that the function should not behave differently between |
Beta Was this translation helpful? Give feedback.
-
I see. I guess what I envisioned is something like this: def resolve_dtype(fill_value, dtype):
# Handle cases where fill_value fits inside the existing dtype
if isinstance(fill_value, int) and np.iinfo(dtype).min <= fill_value <= np.iinfo(dtype).max:
return dtype
.... That's what I meant by "this check might be too expensive", since you'd be forced to do a bunch of explicit examinations on the incoming value to determine where it fits. |
Beta Was this translation helpful? Give feedback.
-
That is an interesting approach, but it is quite different than the how dtype resolution is implemented in StaticFrame. This would resolve dtype by value and type, not type alone. I am not sure this more subtle approach is more intuitive than the current approach. And it would lead to interesting questions, such as: if inserting an |
Beta Was this translation helpful? Give feedback.
-
I think you could still leave the existing type resolution paradigm alone, instead extending it a bit to allow for specific edge cases (i.e. this issue). My sketch above wasn't very good, since it forced a re-write of the existing dtype resolution function. This is closer to what I was envisioning: def resolve_dtype(dtype1, dtype2, fill_value=sentinel)
# Leave all the existing logic the same, just add some additional branches to handle very specific edge cases Admittedly, I don't like this very much, because I think it adds far too much complexity to address a rather esoteric edge case that already has a solution |
Beta Was this translation helpful? Give feedback.
-
Description
When using certain operations that insert fill_values,
uint
Series can be unexpectedly upcast toint64
.Example
Discussion
If updating the code to perform more specific type checks and/or edge-case handling handling proves to be too expensive or complicated to implement, it's likely worth ignoring. I'm creating this ticket as I found it to be an interesting dtype conversion edge-case I stumbled across when working with
uint
s.Platform
Run the following function (static-frame >= 0.8.1) and provide the results to define your platform and environment:
Beta Was this translation helpful? Give feedback.
All reactions