Open etiennebacher opened 5 days ago
Note that the same thing happens if I pass a NaN
as lower bound:
import polars as pl
import numpy as np
pl.DataFrame({"a": [1.0]}).select(pl.col("a").clip(np.nan))
shape: (1, 1)
┌─────┐
│ a │
│ --- │
│ f64 │
╞═════╡
│ 1.0 │
└─────┘
run ProjectionExec
thread '<unnamed>' panicked at /home/etienne/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.19/src/lib.rs:423:5:
min must not be NAN
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Traceback (most recent call last):
File "/home/etienne/Desktop/Git/polars/foo.py", line 7, in <module>
print(pl.DataFrame({"a": [1.0]}).select(pl.col("a").clip(np.nan))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/etienne/Desktop/Git/polars/py-polars/polars/dataframe/frame.py", line 9024, in select
return self.lazy().select(*exprs, **named_exprs).collect(_eager=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/etienne/Desktop/Git/polars/py-polars/polars/lazyframe/frame.py", line 2021, in collect
return wrap_df(ldf.collect(callback))
^^^^^^^^^^^^^^^^^^^^^
pyo3_runtime.PanicException: min must not be NAN
Seems related to rust-num/num-traits#134
Checks
Reproducible example
Log output
Issue description
I'm not sure whether this is a bug or not but depending on the build profile,
clip()
either works or panicks whenlower_bound > upper_bound
:dev
profile (aftermake build
), using for instance.clip(lower_bound=10, upper_bound=0)
panicks with the message displayed abovepolars
withpip
), it returns this:My issue here is that I contribute to
r-polars
and when I want to test this behavior (in dev profile) I get a panick instead of a proper error. This issue disappears once I compile the package with release profile but then I can't run tests anymore. Therefore, I'd like to know if this is expected.Expected behavior
Unsure, I'd say the behavior should be the same in dev and release profiles (but should it error or return 10 as in the release profile?).
Installed versions