Skip to content

Commit

Permalink
Add range to list support
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaLingWeng committed Oct 25, 2023
1 parent defb839 commit 1f86ae3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions altair/utils/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -957,11 +957,15 @@ def to_dict(
if kwds.get(k, Undefined) is Undefined
}
)
kwds = {
k: v.to_list() if isinstance(v, (pd.Series, pd.Index)) else v
for k, v in kwds.items()
if k not in list(ignore) + ["shorthand"]
}
for k, v in list(kwds.items()):
if k not in (list(ignore) + ["shorthand"]):
if isinstance(v, (pd.Series, pd.Index)):
kwds[k] = v.to_list()
elif isinstance(v, range):
kwds[k] = list(v)
else:
kwds.pop(k, None)

if "mark" in kwds and isinstance(kwds["mark"], str):
kwds["mark"] = {"type": kwds["mark"]}
result = _todict(
Expand Down
14 changes: 9 additions & 5 deletions tools/schemapi/schemapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,11 +955,15 @@ def to_dict(
if kwds.get(k, Undefined) is Undefined
}
)
kwds = {
k: v.to_list() if isinstance(v, (pd.Series, pd.Index)) else v
for k, v in kwds.items()
if k not in list(ignore) + ["shorthand"]
}
for k, v in list(kwds.items()):
if k not in (list(ignore) + ["shorthand"]):
if isinstance(v, (pd.Series, pd.Index)):
kwds[k] = v.to_list()
elif isinstance(v, range):
kwds[k] = list(v)
else:
kwds.pop(k, None)

if "mark" in kwds and isinstance(kwds["mark"], str):
kwds["mark"] = {"type": kwds["mark"]}
result = _todict(
Expand Down

0 comments on commit 1f86ae3

Please sign in to comment.