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

Aliases for ImputeParams and TitleParams #2732

Merged
merged 7 commits into from
Jan 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 2 additions & 0 deletions altair/vegalite/v5/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def _prepare_data(data, context=None):
# ------------------------------------------------------------------------
# Aliases & specializations
Bin = core.BinParams
Impute = core.ImputeParams
Title = core.TitleParams
ChristopherDavisUCI marked this conversation as resolved.
Show resolved Hide resolved


@utils.use_signature(core.LookupData)
Expand Down
21 changes: 21 additions & 0 deletions tests/vegalite/v5/tests/test_alias.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import pytest

import altair.vegalite.v5 as alt


def test_aliases():
"""Ensure that any aliases defined in `api.py` aren't colliding with names already defined in `core.py` or `channels.py`."""
for alias in ["Bin", "Impute", "Title"]:
# this test pass if the alias can resolve to its real name
try:
getattr(alt, alias)
except AttributeError as e:
assert False, f"cannot resolve '{alias}':, {e}"

# this test fails if the alias match a colliding name in core
with pytest.raises(AttributeError):
getattr(alt.core, alias)

# this test fails if the alias match a colliding name in channels
with pytest.raises(AttributeError):
getattr(alt.channels, alias)