Repository navigation
fix: limit index_mapping to the dataset size, reject negative values - #79
Merged
paulmueller merged 1 commit intoNov 23, 2026
Merged
Conversation
- `get_mapping_indices` has a new `size` argument. Integers and slices are limited to that size, so open-ended slices (`slice(30, None)`) and bounds beyond the dataset (`slice(30, 1000)`, `1000`) work as documented for chipstream's `--limit-events`. Lists or arrays with indices beyond the dataset raise a `ValueError`. - `HDF5Data.index_mapping_indices` holds the resolved indices and is used for all data access, while `HDF5Data.index_mapping` keeps the user-specified value for the pipeline identifier. - Negative values (`check_index_mapping`) and mappings that do not select any events raise a `ValueError` early, including when the pipeline identifier is computed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #79 +/- ##
==========================================
+ Coverage 88.13% 88.18% +0.05%
==========================================
Files 63 63
Lines 4483 4519 +36
==========================================
+ Hits 3951 3985 +34
- Misses 532 534 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
paulmueller
approved these changes
Nov 23, 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.
chipstream-cli's
--limit-eventsdocuments Python slice semantics, withnforNone, e.g.5000-n. dcnum did not support open-ended slices or bounds beyond the dataset. Results on a file with 40 events:index_mapping1000orslice(0, 1000)len()is 1000, reading fails withIndexErrorslice(30, None)NotImplementedError: Slices must have start and stop definedslice(-5, 40)len()is 45, reading fails[-1, 2]OverflowError(uint32)AssertionErrorin the runner (dtin)Changes
get_mapping_indices(index_mapping, size=None)limits integers and slices tosizewhen it is given. Lists or arrays with indices beyondsizeraise aValueError, because there is no sensible way to clamp them.check_index_mappingrejects negative values (int, slice start/stop/step, list/array) with aValueError. It is used byget_mapping_indicesandHDF5Data.get_ppid_index_mapping.HDF5Data.index_mapping_indicesholds the indices resolved againstexperiment:event count, and all data access uses them (scalar features, image caches, basins,__len__).DCNumJobRunneruses them to compute "basinmap0".HDF5Data.index_mappingstill holds the user-specified value. The pipeline identifier and "pipeline:dcnum mapping" therefore contain what the user passed (e.g.190-n-n), so DCscope comparisons are not affected.HDF5Data.__init__validates the mapping right away. A mapping that selects no events raisesValueError: The index_mapping ... does not select any events.Tests
test_index_mapping(read): new cases forslice(8, None),slice(None, 3),slice(None, None, 4),slice(8, 1000)and1000. It also checks the length, the last image, and the user value in the identifier.test_index_mapping_invalid: 11 cases covering negative values, a list beyond the dataset, and empty selections.test_ppid_encoding_dat_negative_index_mapping.test_index_mapping_pipeline_beyond_dataset:slice(190, None)andslice(190, 1000)give the same basinmap0 and features asslice(190, 200), while the attributes keep the user value.🤖 Generated with Claude Code