Skip to content

Commit 8ca8a79

Browse files
committed
wip expr.filter trying to address ci errors
1 parent 5bb2afd commit 8ca8a79

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

narwhals_daft/expr.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import operator as op
4+
from functools import partial
45
from typing import TYPE_CHECKING, Any, Literal, TypeAlias, cast
56

67
import daft.functions as F
@@ -371,6 +372,33 @@ def _with_alias_output_names(self, func: AliasNames | None, /) -> DaftExpr:
371372
version=self._version,
372373
)
373374

375+
def _reuse_series(
376+
self, method_name: str, *, returns_scalar: bool = False, **kwargs: Any
377+
) -> DaftExpr:
378+
"""Reuse Series implementation for expression.
379+
380+
If Series.foo is already defined, and we'd like Expr.foo to be the same, we can
381+
leverage this method to do that for us.
382+
383+
Arguments:
384+
method_name: name of method.
385+
returns_scalar: whether the Series version returns a scalar. In this case,
386+
the expression version should return a 1-row Series.
387+
kwargs: keyword arguments to pass to function.
388+
"""
389+
func = partial(
390+
self._reuse_series_inner,
391+
method_name=method_name,
392+
returns_scalar=returns_scalar,
393+
**kwargs,
394+
)
395+
return self._from_callable(
396+
func,
397+
evaluate_output_names=self._evaluate_output_names,
398+
alias_output_names=self._alias_output_names,
399+
context=self,
400+
)
401+
374402
def __and__(self, other: DaftExpr) -> DaftExpr:
375403
return self._with_binary(lambda expr, other: (expr & other), other=other)
376404

0 commit comments

Comments
 (0)