Skip to content

docs: clarify in-place string conversion during writes - #2626

Open
rastagan-git wants to merge 1 commit into
scverse:mainfrom
rastagan-git:docs/clarify-write-string-conversion-side-effects
Open

rastagan-git wants to merge 1 commit into
scverse:mainfrom
rastagan-git:docs/clarify-write-string-conversion-side-effects

Conversation

@rastagan-git

Copy link
Copy Markdown

Summary

Clarify that convert_strings_to_categoricals=True modifies obs, var, and raw.var in place before write_h5ad() and write_zarr() serialize the object.

The updated parameter documentation also points users to convert_strings_to_categoricals=False when they need to preserve the in-memory dtypes.

Context

Both writers call the in-place AnnData.strings_to_categoricals() helper before writing. This behavior is longstanding, and #1474 made it optional, but the public method documentation currently says only “Convert string columns to categorical,” which does not make the side effect clear.

This PR documents the current contract only. It does not change the default, serialization behavior, or on-disk format.

Validation

  • python -m pytest tests/test_readwrite.py::test_write_categorical -q — 6 passed
  • ruff check src/anndata/_core/anndata.py
  • ruff format --check src/anndata/_core/anndata.py
  • git diff --check

AI assistance disclosure: I used Codex to help trace the write paths, inspect the history, and draft the documentation. I manually reproduced the behavior, reviewed the final diff, and ran the listed checks.

@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.84%. Comparing base (d2cc7ee) to head (0adcc4e).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2626      +/-   ##
==========================================
- Coverage   87.68%   85.84%   -1.84%     
==========================================
  Files          49       49              
  Lines        8102     8102              
==========================================
- Hits         7104     6955     -149     
- Misses        998     1147     +149     
Files with missing lines Coverage Δ
src/anndata/_core/anndata.py 86.40% <ø> (ø)

... and 8 files with indirect coverage changes

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Side effect when writing string columns to zarr

1 participant