Skip to content

Commit

Permalink
refactor(core): use object syntax for bool_and/or
Browse files Browse the repository at this point in the history
  • Loading branch information
f4t4nt committed Feb 5, 2025
1 parent de181ff commit c8a6bd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions daft/expressions/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3268,16 +3268,16 @@ def bool_and(self) -> Expression:
>>> df.with_column("result", df["values"].list.bool_and()).collect()
╭───────────────┬─────────╮
│ values ┆ result │
│ --- ┆ --- │
│ --- ┆ --- │
│ List[Boolean] ┆ Boolean │
╞═══════════════╪═════════╡
│ [true, true] ┆ true │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ [true, false] ┆ false │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ [null, null] ┆ null
│ [None, None] ┆ None
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ [] ┆ null
│ [] ┆ None
╰───────────────┴─────────╯
"""
return Expression._from_pyexpr(native.list_bool_and(self._expr))
Expand All @@ -3296,16 +3296,16 @@ def bool_or(self) -> Expression:
>>> df.with_column("result", df["values"].list.bool_or()).collect()
╭───────────────┬─────────╮
│ values ┆ result │
│ --- ┆ --- │
│ --- ┆ --- │
│ List[Boolean] ┆ Boolean │
╞═══════════════╪═════════╡
│ [true, false] ┆ true │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ [false, false]┆ false │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ [null, null] ┆ null
│ [None, None] ┆ None
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌┤
│ [] ┆ null
│ [] ┆ None
╰───────────────┴─────────╯
"""
return Expression._from_pyexpr(native.list_bool_or(self._expr))
Expand Down
8 changes: 4 additions & 4 deletions src/daft-core/src/series/ops/agg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ impl Series {
DataType::Boolean => {
let downcasted = self.bool()?;
Ok(match groups {
Some(groups) => DaftBoolAggable::grouped_bool_and(downcasted, groups)?,
None => DaftBoolAggable::bool_and(downcasted)?,
Some(groups) => downcasted.grouped_bool_and(groups)?,
None => downcasted.bool_and()?,
}
.into_series())
}
Expand All @@ -309,8 +309,8 @@ impl Series {
DataType::Boolean => {
let downcasted = self.bool()?;
Ok(match groups {
Some(groups) => DaftBoolAggable::grouped_bool_or(downcasted, groups)?,
None => DaftBoolAggable::bool_or(downcasted)?,
Some(groups) => downcasted.grouped_bool_or(groups)?,
None => downcasted.bool_or()?,
}
.into_series())
}
Expand Down

0 comments on commit c8a6bd6

Please sign in to comment.