Skip to content

Commit 57ab13b

Browse files
committed
chore: add some notes on Eager(Namespace|Series)
1 parent a066213 commit 57ab13b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

narwhals/_compliant/namespace.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ class EagerNamespace(
3333
CompliantNamespace[EagerDataFrameT, EagerSeriesT],
3434
Protocol[EagerDataFrameT, EagerSeriesT],
3535
):
36+
# NOTE: Supporting moved ops
37+
# - `self_create_expr_from_callable` -> `self._expr._from_callable`
38+
# - `self_create_expr_from_series` -> `self._expr._from_series`
39+
@property
40+
def _expr(self) -> type[EagerExpr[EagerDataFrameT, EagerSeriesT]]: ...
41+
42+
# NOTE: Supporting moved ops
43+
# - `self._create_series_from_scalar` -> `EagerSeries()._from_scalar`
44+
# - Was dependent on a `reference_series`, so is now an instance method
45+
# - `<class>._from_iterable` -> `self._series._from_iterable`
46+
@property
47+
def _series(self) -> type[EagerSeriesT]: ...
48+
3649
def all_horizontal(
3750
self, *exprs: EagerExpr[EagerDataFrameT, EagerSeriesT]
3851
) -> EagerExpr[EagerDataFrameT, EagerSeriesT]: ...

narwhals/_compliant/series.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,19 @@ class EagerSeries(CompliantSeries, Protocol[NativeSeriesT_co]):
3939
@property
4040
def native(self) -> NativeSeriesT_co: ...
4141

42+
# NOTE: `ArrowSeries` needs to intercept `value` w/
43+
# if self._backend_version < (13,) and hasattr(value, "as_py"):
44+
# value = value.as_py() # noqa: ERA001
4245
def _from_scalar(self, value: Any) -> Self:
4346
return self._from_iterable([value], name=self.name, context=self)
4447

4548
@classmethod
4649
def _from_iterable(
4750
cls: type[Self], data: Iterable[Any], name: str, *, context: _FullContext
4851
) -> Self: ...
52+
53+
# TODO @dangotbanned: replacing `Namespace._create_compliant_series``
54+
# - All usage within `*Expr.map_batches`
55+
# - `PandasLikeExpr` uses that **once**
56+
# - `ArrowExpr` uses **twice**
57+
# - `PandasLikeDataFrame.with_row_index` uses the wrapped `utils` function once

0 commit comments

Comments
 (0)