-
Notifications
You must be signed in to change notification settings - Fork 185
Closed
Description
Discovered in (#3233) while porting some tests from polars.
This one is py-polars/tests/unit/test_selectors.py#L943-L956
Repro
import narwhals as nw
nw.Enum([])File narwhals/narwhals/dtypes.py:697, in Enum.__repr__(self)
696 def __repr__(self) -> str:
--> [697] return f"{type(self).__name__}(categories={list(self.categories)!r})"
File narwhals/narwhals/dtypes.py:667, in Enum.categories(self)
665 return self._cached_categories
666 msg = f"Internal structure of {type(self).__name__!r} is invalid." # pragma: no cover
--> [667] raise TypeError(msg)
TypeError: Internal structure of 'Enum' is invalid.The good news though (I guess) is it doesn't seem to get triggered when we started with pl.Enum([]):
import polars as pl
native = pl.Series([]).cast(pl.Enum)
series = nw.from_native(native, series_only=True)
series.dtypeEnum(categories=[])Having this working isn't personally of interest, but I saw the # pragma: no cover and thought it was worth showing how we can get there 😄
Reactions are currently unavailable