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

Fix split_by_sep in multicategorical stype #395

Merged
merged 1 commit into from
May 7, 2024
Merged
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
4 changes: 2 additions & 2 deletions torch_frame/data/mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __init__(
self.index = pd.concat((self.index, (pd.Series([-1], index=[-1]))))

@staticmethod
def split_by_sep(row: str | list[Any] | None, sep: None | str) -> set[Any]:
def split_by_sep(row: str | Iterable | None, sep: None | str) -> set[Any]:
if row is None or row is np.nan:
return {-1}
elif isinstance(row, str):
Expand All @@ -151,7 +151,7 @@ def split_by_sep(row: str | list[Any] | None, sep: None | str) -> set[Any]:
return set()
else:
return {cat.strip() for cat in row.split(sep)}
elif isinstance(row, list):
elif isinstance(row, Iterable):
assert sep is None
return set(row)
else:
Expand Down
Loading