Skip to content

Commit

Permalink
fix mistakes making tests fail
Browse files Browse the repository at this point in the history
  • Loading branch information
finn-rudolph committed Dec 14, 2024
1 parent 5cd1077 commit e1d57e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 28 deletions.
20 changes: 10 additions & 10 deletions src/pydiverse/transform/_internal/backend/polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,24 +583,24 @@ def _dt_day_of_week(x):
def _dt_day_of_year(x):
return x.dt.ordinal_day().cast(pl.Int64)

@impl(ops.dt_days)
def _dt_days(x):
@impl(ops.dur_days)
def _dur_days(x):
return x.dt.total_days()

@impl(ops.dt_hours)
def _dt_hours(x):
@impl(ops.dur_hours)
def _dur_hours(x):
return x.dt.total_hours()

@impl(ops.dt_minutes)
def _dt_minutes(x):
@impl(ops.dur_minutes)
def _dur_minutes(x):
return x.dt.total_minutes()

@impl(ops.dt_seconds)
def _dt_seconds(x):
@impl(ops.dur_seconds)
def _dur_seconds(x):
return x.dt.total_seconds()

@impl(ops.dt_milliseconds)
def _dt_milliseconds(x):
@impl(ops.dur_milliseconds)
def _dur_milliseconds(x):
return x.dt.total_milliseconds()

@impl(ops.row_number)
Expand Down
18 changes: 0 additions & 18 deletions src/pydiverse/transform/_internal/tree/col_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ def func(accessor):


class ColExpr(Generic[T]):
__slots__ = ["_dtype", "_ftype"]

__contains__ = None
__iter__ = None

Expand All @@ -79,10 +77,6 @@ def __bool__(self):
"converted to a boolean or used with the and, or, not keywords"
)

def __setstate__(self, d): # to avoid very annoying AttributeErrors
for slot, val in d[1].items():
setattr(self, slot, val)

def _repr_html_(self) -> str:
return f"<pre>{html.escape(repr(self))}</pre>"

Expand Down Expand Up @@ -1064,8 +1058,6 @@ def seconds(self: ColExpr[Duration]) -> ColExpr[Int]:


class Col(ColExpr):
__slots__ = ["name", "_ast", "_uuid"]

def __init__(
self, name: str, _ast: AstNode, _uuid: UUID, _dtype: Dtype, _ftype: Ftype
):
Expand Down Expand Up @@ -1097,8 +1089,6 @@ def __hash__(self) -> int:


class ColName(ColExpr):
__slots__ = ["name"]

def __init__(
self, name: str, dtype: Dtype | None = None, ftype: Ftype | None = None
):
Expand All @@ -1111,8 +1101,6 @@ def __repr__(self) -> str:


class LiteralCol(ColExpr):
__slots__ = ["val"]

def __init__(self, val: Any, dtype: types.Dtype | None = None):
self.val = val
if dtype is None:
Expand All @@ -1125,8 +1113,6 @@ def __repr__(self):


class ColFn(ColExpr):
__slots__ = ("op", "args", "context_kwargs")

def __init__(self, op: Operator, *args: ColExpr, **kwargs: list[ColExpr | Order]):
self.op = op
# While building the expression tree, we have to allow markers.
Expand Down Expand Up @@ -1265,8 +1251,6 @@ def __repr__(self) -> str:


class CaseExpr(ColExpr):
__slots__ = ["cases", "default_val"]

def __init__(
self,
cases: Iterable[tuple[ColExpr, ColExpr]],
Expand Down Expand Up @@ -1409,8 +1393,6 @@ def otherwise(self, value: ColExpr) -> CaseExpr:


class Cast(ColExpr):
__slots__ = ["val", "target_type"]

def __init__(self, val: ColExpr, target_type: Dtype):
if target_type.const:
raise TypeError("cannot cast to `const` type")
Expand Down

0 comments on commit e1d57e3

Please sign in to comment.