docs: clarify in-place string conversion during writes - #2626
Open
rastagan-git wants to merge 1 commit into
Open
rastagan-git wants to merge 1 commit into
rastagan-git wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes Side effect when writing string columns to zarr #2610
Tests added
Release note not necessary because: this clarifies existing API behavior without changing runtime behavior.
Summary
Clarify that
convert_strings_to_categoricals=Truemodifiesobs,var, andraw.varin place beforewrite_h5ad()andwrite_zarr()serialize the object.The updated parameter documentation also points users to
convert_strings_to_categoricals=Falsewhen 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 passedruff check src/anndata/_core/anndata.pyruff format --check src/anndata/_core/anndata.pygit diff --checkAI 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.