Skip to content

fix(preprocess): correct double-escaped regex in ND2 binning parser#225

Open
petercla0119 wants to merge 3 commits into
cheeseman-lab:zarr3from
petercla0119:fix/binning-regex-escape
Open

fix(preprocess): correct double-escaped regex in ND2 binning parser#225
petercla0119 wants to merge 3 commits into
cheeseman-lab:zarr3from
petercla0119:fix/binning-regex-escape

Conversation

@petercla0119

@petercla0119 petercla0119 commented Jun 26, 2026

Copy link
Copy Markdown

Description

The raw-string regex in _parse_binning_from_nd2 used double-escaped sequences (\\s, \\d) which in a Python r"..." string are literal backslash characters, not regex metacharacters. This caused the function to never match the "Binning: 2x2" string present in ND2 text_info metadata, always returning None for binning_xy.

Before: r"Binning:\\s*(\\d+)x(\\d+)" — searches for literal \s*\d+x\d+
After: r"Binning:\s*(\d+)x(\d+)" — correctly matches Binning: 2x2

What is the nature of your change?

  • Bug fix (fixes an issue).
  • Enhancement (adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • This change requires a documentation update.

Checklist

  • My code follows the conventions of this project.
  • I have updated the pyproject.toml to reflect the change as designated by semantic versioning. (N/A — this PR targets the zarr3 development branch, which is already at 1.5.0; no version bump needed.)
  • I have checked linting and formatting with ruff check and ruff format.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have deleted all non-relevant text in this pull request template.

Claire Peterson and others added 3 commits June 8, 2026 18:27
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>
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.

1 participant