BUG: preserve correlogram unit axes across segments - #4767
Merged
alejoe91 merged 6 commits intoSep 14, 2026
Merged
Conversation
chrishalcrow
reviewed
Sep 8, 2026
alejoe91
requested changes
Sep 10, 2026
alejoe91
left a comment
Member
There was a problem hiding this comment.
Since correlogram_for_one_segment and auto_correlogram_for_one_segment are only used internally and not exposed at the module level, let's just make num_units mandatory to avoid any confusion
Contributor
Author
|
Done in 478f0dc. Both internal helpers now require num_units, and the unique-index fallback is removed. I also updated the docstrings to say int and adjusted the existing helper test to pass the complete unit count explicitly. The correlogram test module passed locally: 43 passed, 40 skipped. Black and git diff --check passed too. Pytest plugin autoload was disabled to avoid an unrelated DANDI plugin from the shared environment. CI is rerunning for this commit. |
alejoe91
approved these changes
Sep 11, 2026
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 #4736.
When a unit is silent in one segment, the NumPy path sizes its segment result from the number of active units. With two units this can broadcast counts into the wrong pairs; non-contiguous indices can also raise an error. Pass the complete sorting's unit count to both segment helpers so each result preserves the global unit axes, including empty segments.
The optional
num_unitsargument also affects direct calls to the exported helpers. Without it, the size is inferred asmax(unit_index) + 1(zero for empty input), leaving zero rows for missing indices. For example, labels[0, 2]now produce three auto-correlogram rows rather than two. This preserves index coordinates instead of dropping counts or raising for non-contiguous indices. I am open to using an accumulator argument instead if that is the preferred API.The regression checks exact auto- and cross-correlogram counts for two and three units across segments, including an empty segment. It runs without Numba and additionally compares both implementations when Numba is installed. Both cases fail against the corresponding functions from upstream
f03253e9cand pass with this change.Validation on Python 3.13:
test_correlograms.pymodule: 42 passed, 40 skipped.git diff --check: passed.The test environment uses the development ProbeInterface dependency required by this checkout and its declared Zarr 2 / numcodecs constraints. Pytest plugin autoload was disabled to avoid loading an unrelated DANDI plugin from the host environment.