fix(preprocess): correct double-escaped regex in ND2 binning parser#225
Open
petercla0119 wants to merge 3 commits into
Open
fix(preprocess): correct double-escaped regex in ND2 binning parser#225petercla0119 wants to merge 3 commits into
petercla0119 wants to merge 3 commits into
Conversation
format_singlecell_anndata fails with TypeError when writing the singlecell h5ad because columns like gene_symbol_1 and gene_id_1 contain NaN (float) values mixed with strings. h5py cannot implicitly convert non-string objects to variable-length strings. Fill NaN with empty strings and cast to str for all object-typed obs columns before calling write_h5ad. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The raw-string regex in `_parse_binning_from_nd2` used `\\s` and `\\d` which in an r-string are literal backslash-s and backslash-d, never matching actual whitespace or digits. This caused binning_xy to always return None for ND2 files even when "Binning: 2x2" was present in the text_info metadata. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Docs are Markdown-only and don't use autodoc, so the package doesn't need to be installed. The full install was failing because iohub==0.3.0 doesn't exist on PyPI (only pre-releases up to 0.3.0a7). Co-Authored-By: Claude Sonnet 4.6 (1M context) <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.
Description
The raw-string regex in
_parse_binning_from_nd2used double-escaped sequences (\\s,\\d) which in a Pythonr"..."string are literal backslash characters, not regex metacharacters. This caused the function to never match the"Binning: 2x2"string present in ND2text_infometadata, always returningNoneforbinning_xy.Before:
r"Binning:\\s*(\\d+)x(\\d+)"— searches for literal\s*\d+x\d+After:
r"Binning:\s*(\d+)x(\d+)"— correctly matchesBinning: 2x2What is the nature of your change?
Checklist
pyproject.tomlto reflect the change as designated by semantic versioning. (N/A — this PR targets thezarr3development branch, which is already at1.5.0; no version bump needed.)ruff checkandruff format.