File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,6 +21,9 @@ Changes
2121 removed in the next release of skrub.
2222 :pr: `1546 ` by :user: `Vincent Maladiere <Vincent-Maladiere> `.
2323
24+ - Improved error messages when a DataOp is being sent to dispatched functions.
25+ :pr: `1607 ` by :user: `Riccardo Cappuzzo<rcap107> `.
26+
2427Bugfixes
2528--------
2629
Original file line number Diff line number Diff line change 119119
120120
121121def _raise (obj , kind = "object" ):
122+ from .._data_ops ._data_ops import DataOp
123+
124+ if isinstance (obj , DataOp ):
125+ raise TypeError (
126+ """Expected a Pandas or Polars DataFrame, but got a skrub DataOp.
127+ A function that expects an actual value cannot be applied directly to a DataOp;
128+ you may want to (i) use op.skb.eval() or op.skb.preview() to evaluate the
129+ dataop and turn it into an actual value or (ii) use op.skb.apply_func() or
130+ op.skb.apply() to schedule the operation for later execution (when the dataop is
131+ evaluated) rather than computing it immediately.
132+ """
133+ )
122134 raise TypeError (
123135 "Operation not supported on this object. Expecting a Pandas or Polars "
124136 f"{ kind } , but got an object of type { type (obj )} ."
Original file line number Diff line number Diff line change 1515from numpy .testing import assert_array_equal
1616from pandas .testing import assert_frame_equal as pd_assert_frame_equal
1717
18+ import skrub
1819from skrub import selectors as s
1920from skrub ._dataframe import _common as ns
2021
@@ -40,6 +41,12 @@ def test_not_implemented():
4041 params = [None ] * n_params
4142 with pytest .raises (TypeError ):
4243 func (* params )
44+ dop = [skrub .var ("a" )] * n_params
45+ with pytest .raises (
46+ TypeError ,
47+ match = r"Expected a Pandas or Polars DataFrame, but got a skrub DataOp" ,
48+ ):
49+ func (* dop )
4350
4451
4552#
You can’t perform that action at this time.
0 commit comments