Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Feb 2, 2025
1 parent 277d96c commit 1ad32f1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
14 changes: 6 additions & 8 deletions narwhals/_polars/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,17 +226,15 @@ def __invert__(self: Self) -> Self:

def is_nan(self: Self) -> Self:
native = self._native_series

if self._backend_version < (1, 18): # pragma: no cover
return self._from_native_series(
pl.select(pl.when(native.is_not_null()).then(native.is_nan()))[
native.name
]
)
try:
return self._from_native_series(native.is_nan())
native_is_nan = native.is_nan()
except pl.exceptions.PolarsError as e:
raise catch_polars_exception(e) from None
if self._backend_version < (1, 18): # pragma: no cover
return self._from_native_series(
pl.select(pl.when(native.is_not_null()).then(native_is_nan))[native.name]
)
return self._from_native_series(native_is_nan)

def median(self: Self) -> Any:
from narwhals.exceptions import InvalidOperationError
Expand Down
2 changes: 1 addition & 1 deletion narwhals/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class InvalidOperationError(NarwhalsError):
"""Exception raised during invalid operations."""


class InvalidIntoExprError(NarwhalsError):
class InvalidIntoExprError(TypeError, NarwhalsError):
"""Exception raised when object can't be converted to expression."""

def __init__(self: Self, message: str) -> None:
Expand Down

0 comments on commit 1ad32f1

Please sign in to comment.