-
Notifications
You must be signed in to change notification settings - Fork 21
Return type of pow #174
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
Comments
I think we should refer to the array API standard's description for For the examples given, that spec says, for
In this particular case I think the Polars choice isn't completely unreasonable, because it's the other choice that could be made to extrapolate Python's builtin behavior for scalars to a column: >>> 2**2
4
>>> 2**-1
0.5
>>> type(2**2)
<class 'int'>
>>> type(2**-1)
<class 'float'> But it's the opposite choice made by all array libraries and by Pandas, and makes it harder to work with lower-precision dtypes when everything ends up being >>> import polars as pl
>>> col = pl.Series([1, 2, 3], dtype=pl.Int32)
>>> col**2
shape: (3,)
Series: '' [f64]
[
1.0
4.0
9.0
]
>>> col.pow(2).dtype
Float64
>>> (col**2).dtype
Float64 I don't see any documented casting rules in the Polars docs, although it seems dtype-preserving in general with I haven't checked all the other dataframe libraries yet, would be good to check that first. If it's not possible to make the |
We can always work around this in the standard, no big deal - following the Array API looks good to me |
As another data point: the pyarrow.compute |
thanks @jorisvandenbossche ! I like that, I'd suggest standardising to that |
in the last call we went for following the pyarrow behaviour |
Seems like there's some inconsistencies:
polars always returns floats, whereas pandas returns either integers or floats, and may error based on the value of the exponent
What do we want to do here?
The text was updated successfully, but these errors were encountered: