Skip to content

Commit

Permalink
fixing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan committed Jan 10, 2025
1 parent 5644531 commit 1f9d382
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/datachain/func/conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,13 @@ def case(
"""
Returns the case function that produces case expression which has a list of
conditions and corresponding results. Results can only be python primitives
like string, numbes or booleans. Result type is inferred from condition results.
like string, numbers or booleans. Result type is inferred from condition results.
Args:
args (tuple((ColumnElement, Func), (str | int | float | complex | bool, Func))):
- Tuple of condition and values pair
else_ (str | int | float | complex | bool, Func): else value in case expression
Tuple of condition and values pair.
else_ (str | int | float | complex | bool, Func): else value in case
expression.
Returns:
Func: A Func object that represents the case function.
Expand Down Expand Up @@ -128,7 +129,7 @@ def _get_type(val):
arg_type = _get_type(arg[1])
if type_ and arg_type != type_:
raise DataChainParamsError(
f"Statement values must be of the same type, got {type_} amd {arg_type}"
f"Statement values must be of the same type, got {type_} and {arg_type}"
)
type_ = arg_type

Expand All @@ -152,11 +153,11 @@ def ifelse(
Result type is inferred from the values.
Args:
condition: (ColumnElement, Func) - condition which is evaluated
if_val: (str | int | float | complex | bool, Func): value for true
condition outcome
else_val: (str | int | float | complex | bool, Func): value for false condition
outcome
condition (ColumnElement, Func): Condition which is evaluated.
if_val (str | int | float | complex | bool, Func): Value for true
condition outcome.
else_val (str | int | float | complex | bool, Func): Value for false condition
outcome.
Returns:
Func: A Func object that represents the ifelse function.
Expand All @@ -174,6 +175,7 @@ def ifelse(
def isnone(col: Union[str, Column]) -> Func:
"""
Returns True if column value is None, otherwise False
Args:
col (str | Column): Column to check if it's None or not.
If a string is provided, it is assumed to be the name of the column.
Expand All @@ -183,7 +185,7 @@ def isnone(col: Union[str, Column]) -> Func:
Example:
```py
dc.mutate(test=ifelse(isnone("col"), "NONE", "NOT_NONE"))
dc.mutate(test=ifelse(isnone("col"), "EMPTY", "NOT_EMPTY"))
```
"""
from datachain import C
Expand All @@ -192,4 +194,4 @@ def isnone(col: Union[str, Column]) -> Func:
# if string, it is assumed to be the name of the column
col = C(col)

return case((col == None, True), else_=False) # type: ignore [arg-type] # noqa: E711
return case((col == None, True), else_=False) # noqa: E711

0 comments on commit 1f9d382

Please sign in to comment.