Skip to content

v0.2.4 - Bug Fixes for Threshold Analysis (2025-12-22)

What Changed?

This release fixes two bugs in the threshold analysis example scripts. The fit_thresholds.py script now gracefully handles channels with no valid data instead of crashing. The plot_thresholds.py script safely handles missing measurement threshold metadata. Both fixes improve robustness when working with incomplete or varied detector datasets.


What's New

Bug Fix #1: Threshold Fitting with Empty Channels

What it does: The fit_thresholds.py script now detects when channels have no valid measurement data and skips them gracefully instead of crashing with a ValueError.

How to use it: Simply run the script as before - it will now warn about channels with no data and continue processing valid channels.

Example:

# Before: Would crash with "ValueError: zero-size array to reduction operation maximum"
# After: Processes available channels and shows warnings for empty ones
uv run fit_thresholds.py ./measurements --verbose

Bug Fix #2: Plot Script with Optional Metadata

What it does: The plot_thresholds.py script now safely handles missing measurement_threshold field in the fitted results JSON, allowing visualization of threshold response curves even when optional metadata is unavailable.

How to use it: No changes needed - the script will automatically skip the measurement threshold marker line if the data is not present.

uv run plot_thresholds.py ./measurements/fitted_thresholds.json

Installation

Quick Start

# Get the release
git checkout v0.2.4

# Setup
uv sync

# Run threshold analysis
uv run examples/fit_thresholds.py ./measurements
uv run examples/plot_thresholds.py ./measurements/fitted_thresholds.json

What's Different from the Last Version?

✅ Added

  • Graceful handling of channels with no valid measurement data in fit_thresholds.py

🔧 Changed

  • fit_thresholds.py now validates channel data before processing
  • plot_thresholds.py uses safe field access for optional metadata

🐛 Fixed

  • Fixed ValueError in fit_thresholds.py when normalizing empty channel data (y.max() on empty array)
  • Fixed KeyError in plot_thresholds.py when measurement_threshold field is missing

Is It Safe to Upgrade?

Backward Compatible: Yes

  • These are bug fixes that improve robustness without changing the API
  • Existing code will continue to work as expected
  • Scripts that previously failed on empty channels will now complete successfully

Tests Passed

  • ✅ fit_thresholds.py runs successfully with test data containing channels with no measurements
  • ✅ plot_thresholds.py generates plots without measurement_threshold metadata
  • ✅ Both scripts handle verbose and non-verbose modes
  • ✅ Linting and type checking pass

Release Details

  • Date: 2025-12-22
  • Version: v0.2.4
  • Files Changed: 3 (fit_thresholds.py, plot_thresholds.py, pyproject.toml)
  • Commits: 01a5025 (fit_thresholds fix), b93501f (plot_thresholds fix), 8931638 (bump version)

Next Steps

  • Enhanced error messages for debugging data issues
  • Additional validation for detector measurement data
  • Integration tests for example scripts with various data configurations