Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: when-then-otherwise examples #3492

Merged
merged 18 commits into from
Jul 29, 2024
Merged
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: Add __repr__ for When, ChainedWhen
  • Loading branch information
dangotbanned committed Jul 26, 2024
commit 0e7b49f45807aac494861465b9a734ea8e74def0
10 changes: 10 additions & 0 deletions altair/vegalite/v5/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@ class When(_BaseWhen):
def __init__(self, condition: _ConditionType, /) -> None:
self._condition = condition

def __repr__(self) -> str:
return f"{type(self).__name__}({self._condition!r})"

@overload
def then(self, statement: str, /, **kwds: Any) -> Then[_Condition]: ...
@overload
Expand Down Expand Up @@ -1057,6 +1060,13 @@ def __init__(
self._condition = condition
self._conditions = conditions

def __repr__(self) -> str:
return (
f"{type(self).__name__}(\n"
f" {self._conditions!r},\n {self._condition!r}\n"
")"
)

def then(self, statement: _StatementType, /, **kwds: Any) -> Then[_Conditions]:
"""
Attach a statement to this predicate.
Expand Down