Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Changes
removed in the next release of skrub.
:pr:`1546` by :user:`Vincent Maladiere <Vincent-Maladiere>`.

- Improved error messages when a DataOp is being sent to dispatched functions.
:pr:`1607` by :user:`Riccardo Cappuzzo<rcap107>`.

Bugfixes
--------
Expand Down
8 changes: 8 additions & 0 deletions skrub/_dataframe/_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@


def _raise(obj, kind="object"):
from .._data_ops._data_ops import DataOp

if isinstance(obj, DataOp):
raise TypeError(
"Operation not supported on DataOps. Expecting a Pandas or Polars "
Comment thread
rcap107 marked this conversation as resolved.
Outdated
f"{kind}, but got a DataOp. You may want to use `.skb.eval()` to "
"evaluate the DataOp and obtain a dataframe."
Comment thread
rcap107 marked this conversation as resolved.
Outdated
)
Comment thread
rcap107 marked this conversation as resolved.
raise TypeError(
"Operation not supported on this object. Expecting a Pandas or Polars "
f"{kind}, but got an object of type {type(obj)}."
Expand Down
7 changes: 7 additions & 0 deletions skrub/_dataframe/tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from numpy.testing import assert_array_equal
from pandas.testing import assert_frame_equal as pd_assert_frame_equal

import skrub
from skrub import selectors as s
from skrub._dataframe import _common as ns

Expand All @@ -40,6 +41,12 @@ def test_not_implemented():
params = [None] * n_params
with pytest.raises(TypeError):
func(*params)
dop = [skrub.var("a")] * n_params
with pytest.raises(
TypeError,
match=r"Operation not supported on DataOps.*Expecting a Pandas*",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to change this :)

):
func(*dop)


#
Expand Down
Loading