Skip to content

Fix crashes on modern NumPy/Matplotlib and low logging-rate logs#58

Open
deliphop wants to merge 1 commit into
Plasmatree:masterfrom
deliphop:master
Open

Fix crashes on modern NumPy/Matplotlib and low logging-rate logs#58
deliphop wants to merge 1 commit into
Plasmatree:masterfrom
deliphop:master

Conversation

@deliphop

@deliphop deliphop commented Jul 4, 2026

Copy link
Copy Markdown

Summary

The project pins numpy 1.11/scipy 1.0/matplotlib 2.0 (2017-2018 era), which have no wheels for current Python, so this fixes compatibility with recent releases instead:

  • np.histogram/histogram2d: normed= was removed, use density=
  • hist2d(): bin count must be an int, not a float from Python 3 division
  • pcolormesh(): explicit shading= is now required; one call mixed bin edges with sample centers across axes, which newer Matplotlib rejects outright (fixed by aligning the smaller axis to centers)
  • plt.cm.get_cmap() was removed, use plt.colormaps[...]
  • get_shared_x_axes().join(...) was removed, use ax.sharex(...)

Also fixes two crashes specific to logs recorded at a low effective rate (e.g. FCs logging to internal flash with blackbox_rate 1/4, rather than a full-rate SD card log):

  • winstacker(): the window count formula can overrun the data array by a few samples on the last window when flen isn't a clean multiple of shift*superpos, producing a ragged array and crashing np.array(). Now clamps the window count to what actually fits.
  • plot_all_noise(): sparse analysis windows can leave NaN in the noise spectra, which crashes the LogNorm colorbar. NaNs are now sanitized to 0 before computing color limits, which correctly falls through to the existing "no data" default range.

Test plan

  • Ran against the bundled good_tune.BBL / stock_tune.BFL example logs — PID response and noise plots generate correctly
  • Ran against a real-world log recorded at blackbox_rate 1/4 on internal flash (126 Hz effective rate, 75% frame decimation) — previously crashed on both fixed issues, now completes and produces sane plots
  • Verified with numpy 2.x / scipy 1.x / matplotlib 3.x on Python 3.14

The project pins numpy 1.11/scipy 1.0/matplotlib 2.0 (2017-2018 era)
but those versions have no wheels for current Python, so this fixes
compatibility with recent releases instead:

- np.histogram/histogram2d: normed= was removed, use density=
- hist2d(): bin count must be an int, not a float from Python 3 division
- pcolormesh(): explicit shading= is now required; one call mixed bin
  edges with sample centers across axes, which newer Matplotlib
  rejects outright (fixed by aligning the smaller axis to centers)
- plt.cm.get_cmap() was removed, use plt.colormaps[...]
- get_shared_x_axes().join(...) was removed, use ax.sharex(...)

Also fixes two crashes specific to logs recorded at a low effective
rate (e.g. FCs logging to internal flash with blackbox_rate 1/4,
rather than a full-rate SD card log):

- winstacker(): the window count formula can overrun the data array
  by a few samples on the last window when flen isn't a clean
  multiple of shift*superpos, producing a ragged array and crashing
  np.array(). Now clamps the window count to what actually fits.
- plot_all_noise(): sparse analysis windows can leave NaN in the
  noise spectra, which crashes the LogNorm colorbar. NaNs are now
  sanitized to 0 before computing color limits, which correctly
  falls through to the existing "no data" default range.
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