Repository navigation
fix: PMT crashes in a single-channel Simulation (float() on a (1, 1, 1, 1) exposure) - #159
Merged
tlambert03 merged 1 commit intoOct 13, 2026
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #159 +/- ##
=======================================
Coverage 88.15% 88.15%
=======================================
Files 48 48
Lines 3292 3292
=======================================
Hits 2902 2902
Misses 390 390 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
Simulation.digital_image()crashes with aPMTdetector when the simulation has a single channel:The exposure time is a single number, but by the time it reaches the PMT it is a 4-d array.
Call chain:
Simulation.digital_image(): called withoutexposure_ms, it builds one exposure per channel as aDataArrayoverc(shape(1,)) and passes it todetector.render()→_Detector.simulate()._Detector.simulate():exposure_s = exposure_ms / 1000 * n_avg(still(1,)), then_per_channel(exposure_s, ndim)from_detector.pyadds trailing axes so that it broadcasts against the(C, Z, Y, X)image: shape(1, 1, 1, 1). This goes to_after_multiplication()astime_s.PMT._after_multiplication(): passestime_s(saturation, ifmax_output_current_uais set) ordwell_s(amplifier bandwidth, iftime_constant_us > 0) asdtto the_per_channelin_point.py. That is a different helper with the same name._per_channel()in_point.py:dt.size == 1is true, so it callsfloat(dt)on the(1, 1, 1, 1)array.float()on an array withndim > 0has been deprecated since NumPy 1.25, and it raises in NumPy 2.4 (tested with 2.4.6).Why the tests didn't catch it: the crash needs all four of these at once:
exposure_msis never reshaped in step 2, and every test intest_point_detectors.pycallsrender()with a float.elsebranch runs, and it flattensdtwithdt.ravel().max_output_current_ua.HyDand the cameras don't use this helper.DeprecationWarning.Changes
_per_channel()in_point.py:float(dt)→float(dt.item())..item()returns the single value whatever the number of axes.🤖 Generated with Claude Code