Skip to content

Fix concat_on_disk #1855

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

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
14 changes: 11 additions & 3 deletions src/anndata/experimental/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,13 +371,13 @@


def _write_alt_mapping(groups, output_group, alt_axis_name, alt_indices, merge):
alt_mapping = merge([read_as_backed(g[alt_axis_name]) for g in groups])
alt_mapping = merge([read_as_backed(g[f"{alt_axis_name}m"]) for g in groups])
# If its empty, we need to write an empty dataframe with the correct index
if not alt_mapping:
alt_df = pd.DataFrame(index=alt_indices)
write_elem(output_group, alt_axis_name, alt_df)
write_elem(output_group, f"{alt_axis_name}m", alt_df)
else:
write_elem(output_group, alt_axis_name, alt_mapping)
write_elem(output_group, f"{alt_axis_name}m", alt_mapping)

Check warning on line 380 in src/anndata/experimental/merge.py

View check run for this annotation

Codecov / codecov/patch

src/anndata/experimental/merge.py#L380

Added line #L380 was not covered by tests


def _write_alt_annot(groups, output_group, alt_axis_name, alt_indices, merge):
Expand All @@ -402,6 +402,11 @@
write_elem(output_group, axis_name, concat_annot)


def _write_uns(groups, output_group, merge):
uns = merge([read_elem(g["uns"]) for g in groups])
write_elem(output_group, "uns", uns)


def concat_on_disk(
in_files: Collection[str | os.PathLike] | Mapping[str, str | os.PathLike],
out_file: str | os.PathLike,
Expand Down Expand Up @@ -633,6 +638,9 @@
# Write {alt_axis_name}m
_write_alt_mapping(groups, output_group, alt_axis_name, alt_index, merge)

# Write uns
_write_uns(groups, output_group, uns_merge)

# Write X

_write_concat_arrays(
Expand Down
Loading