Skip to content

B3a: Concat correctness #92

Closed
Closed

Description

@Claptar

Part of #87.

wave 1 · 0.17.4 · size L · starts after: nothing

Goal. concat never writes wrong values, and anndata 0.8 to 0.13 can read everything it writes.

Owns: core/concat.py, tests/test_concat*.py, tests/test_invariants.py (concat parts)

Approach:

  • Refuse repeated var names before the output exists, naming the duplicates. anndata refuses them too (F002).
  • Decode anndata 0.7 categoricals before merging codes (F010).
  • Text columns:
    • the masked encoding is chosen per anndata's rules, writing string-array plus a missing-value mask that older anndata can read (F028);
    • mixed encodings keep their missing values (F053);
    • mixed nullable kinds are promoted or kept, not dropped (F052, F054);
    • non-string categories keep their dtype (F051).
  • Merge rules:
    • compare strings across backends by decoded value (F057);
    • stack sparse obsm (F055);
    • recurse into nested uns for first/only (F056).
  • Also:
    • write CSR indices sorted (F115);
    • a zero-var outer join works (F117).
  • Oracle: anndata.concat on every case. Readability is checked with the integration environments for 0.8, 0.9 and 0.10.

Findings

Ref Sev Finding Where
F002 C concat silently corrupts X when var names repeat: columns are zeroed, merged or overwritten, and the command exits 0 src/adata/core/concat.py:84
F010 H concat treats anndata 0.7 (legacy v0.1.0) categorical obs/var columns as plain integers, mixing codes from different category sets src/adata/core/concat.py:217
F028 H concat --join outer writes a plain-string obs/obsm-dataframe column that some input lacks as nullable-string-array, so anndata 0.8, 0.9 and … src/adata/core/concat.py:353
F051 M concat turns non-string categorical categories into strings (int categories become '1','2',...) src/adata/core/concat.py:244
F052 M concat of a nullable-integer column with a nullable-boolean column of the same name writes nullable-string-array under either join: the … src/adata/core/concat.py:301
F053 M Mixed text encodings across inputs (categorical/nullable vs plain string) turn missing values into empty strings src/adata/core/concat.py:349
F054 M concat drops obs columns that are plain in one input and nullable in another (int64 + Int64, bool + boolean); a bool column missing from an … src/adata/core/concat.py:378
F055 M concat drops sparse obsm entries present in every input; anndata.concat stacks them src/adata/core/concat.py:711
F056 M --uns-merge first/only do not recurse into nested mappings, and same/unique leave empty dicts, unlike anndata src/adata/core/concat.py:916
F057 M --merge/--uns-merge same/unique never match string values across an h5ad and a Zarr input src/adata/core/concat.py:989
F115 L CSR concat writes unsorted column indices whenever an input's var order differs from the target order src/adata/core/concat.py:491
F117 L concat of zero-var inputs with --join outer refuses with 'Use --join outer' src/adata/core/concat.py:1056

Done when one PR on fix/b3a closes this, with a regression test against an oracle for every finding, and docs and changelog in the same PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions