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

Concatenator update #246

Merged
merged 3 commits into from
Jun 28, 2024
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
11 changes: 1 addition & 10 deletions cascade/data/concatenator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,14 @@ def __len__(self) -> int:
"""
return sum([len(ds) for ds in self._datasets])

def __repr__(self) -> str:
"""
Mentions joined datasets in its repr in form:
Concatenator of
Dataset1
Dataset2
...
"""
rp = super().__repr__()
return f"{rp} of\n" + "\n".join(repr(ds) for ds in self._datasets)

def get_meta(self) -> Meta:
"""
Concatenator calls `get_meta()` of all its datasets
"""
meta = super().get_meta()
meta[0]["data"] = [ds.get_meta() for ds in self._datasets]
meta[0]["num_concatenated"] = len(self._datasets)
return meta

def from_meta(self, meta: Meta) -> None:
Expand Down
1 change: 1 addition & 0 deletions cascade/tests/data/test_concatenator.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_meta():

c = Concatenator([n1, n2])
assert len(c.get_meta()[0]["data"]) == 2
assert c.get_meta()[0]["num_concatenated"] == 2


def test_from_meta():
Expand Down