Repository navigation
X and layers round-trip enhancement - #362
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #361
Writing and reading
Xand layers changed data according to heuristics that we want to drop due to recurrence in our usecases. Codes like"007"became7.0, the text"nan"became missing, and the zeros of a zero-filled sparse COO, such as OMOP counts, becameNaN. The writer encoded object arrays lossily, and the readers guessed their way back, and the guessing did not prove alltogether very helpful. The columns of.obs/.var/.temwere already exact (#304); nowXand layers are too.Encoding (on-disk version 0.3.0)
objectarray whose values are all numbers or missing is written as float64, as before. Bools andDecimalcount as numbers.uint8array of each value's kind (text / number / missing) in.obsm["_ed_ondisk_kinds_X"]or.obsm["_ed_ondisk_kinds_layers_<name>"]. This uses the same mechanism as the reserved 3D keys, for 2D and 3D,.h5ed,.zarrandwrite_elem. Slight overhead, but the compression keeps extra disk usage at bay and the userfriendlyness is quite an improvement..obsmkeys starting with_ed_ondisk_are rejected.Reading
"007","nan"), numbers come back as float and missing values asNaN. String arrays come back asobjectfrom both formats.harmonize_missing_valuesandcast_variables_to_floatare nowbool | None = None.Noneapplies them only to files written before 0.3.0 and to plain anndata files, which therefore read as before.Trueapplies them to every file.Falseapplies them to none.harmonize_missing_values=Truefor it.XraisesNotImplementedError.Compatibility
.obsm, backed reading of 3D data fails, and their heuristics apply to the string-encoded arrays.Tests
tests/io/test_ondisk.pyruns over.h5ed,.zarrandwrite_elem/read_elem. It covers:"nan", missing values, numbers next to text,Decimal, bools, big integers, 3D,Xas object vsNone;