Skip to content

Fix empty cross sections, anti-aliasing kernel TypeError and About AttributeError - #90

Merged
PierreRaybaut merged 4 commits into
developfrom
fix/89-csection-aa-about
Oct 30, 2026
Merged

PierreRaybaut merged 4 commits into
developfrom
fix/89-csection-aa-about

Conversation

@PierreRaybaut

Copy link
Copy Markdown
Contributor

Summary

Fixes #89: three independent bugs found while reviewing PlotPy before the 2.12.0 release.

1. Cross sections of images added or shown again

Root cause

BaseCrossSectionPlot.items_changed created the cross-section curves of new images after update_plot(refresh=False), and never computed them. With a marker or shape already active, the curves of an image added to the plot stayed empty, and since commit 9a221b7 (unreleased, curves kept for visible images only) so did the curves of an image shown again (they previously showed the cross section at a former marker position). The shade of the curves was also divided by the number of all images, hidden ones included.

Changes

  • Curves of added or shown again images are created before updating the plot, then only these new curves are computed from the last marker/shape (so the gain of 9a221b7 is kept), unless the auto-refresh mode is disabled.
  • The shade is computed from the number of visible images.

2. Anti-aliasing kernel data type

Root cause

The C++ scaling functions require the anti-aliasing kernel to have the data type of the data they scale (TypeError: AA Mask data type must be ...):

  • export_roi(apply_lut=False, apply_interpolation=True) with the Z-axis log scale exported the raw data (e.g. uint16) with the float64 kernel of its logarithm (already the case in 2.11.1), e.g. with the rectangle snapshot tool;
  • after set_data with data of another type, the kernel kept the former type: drawing the image then failed, which aborts the application with PyQt5 (0xC0000409 on Windows), as well as exporting it.

Changes

  • BaseImageItem._get_interpolation_for(data): returns the interpolation with a kernel of the data type of data, used by the 4 export_roi implementations (BaseImageItem, ImageItem, XYImageItem, TrImageItem; masked items inherit them).
  • BaseImageItem._sync_interpolation_dtype(): keeps the kernel in the data type of the data drawn; it replaces the inline code of set_zaxis_log_state and is now also called by set_data.

3. AttributeError in get_python_libs_info

Root cause

The "infos" → "info" renaming of commit 6fc54bd (PlotPy 2.8.0) also renamed the call to guidata's get_python_libs_infos, which does not exist as get_python_libs_info.

Changes

  • plotpy.widgets.about.get_python_libs_info calls guidata.widgets.about.get_python_libs_infos.
  • The plotpy-benchmarks header uses PlotPy's get_python_libs_info (which also gives the PlotPy version).

Release notes

Three entries in the 2.12.0 bug fixes.

Tests

  • New tests, which fail without the fixes and pass with them:
    • test_cross_section_visible_items.py: cross sections of an image shown again (after the marker was moved while it was hidden) and of an added image, and shade ignoring hidden images. A fourth test checks that, with the auto-refresh mode disabled, the curve is only computed on the next refresh (behavior kept).
    • test_image_aa_kernel.py: export with the AA interpolation for 5 image kinds × 4 data types × log scale on/off × LUT on/off, and draw + export after set_data with another data type.
    • test_about.py: get_python_libs_info, about and the benchmark header.
  • The cross-section test helpers now flush pending events before creating a window: in unattended mode, leaving a qt_app_context schedules the closing of all top-level widgets, which otherwise closed the next test's window and hid its cross-section panels.
  • Full suite: 460 passed, 16 skipped (Windows, PyQt5, Python 3.11). Ruff passes, Pylint no longer reports E1101.
  • DataLab develop with this branch: image tools and profile tests pass (10 passed).

When an image was added to the plot, or shown again after having been
hidden, while a cross-section marker or shape was active, its X/Y
cross-section curves stayed empty until the marker was moved:
items_changed created the curves after updating the plot, and never
computed them.

- Create the curves of added or shown again images before updating the
  plot, then compute these new curves only (unless the auto-refresh mode
  is disabled), so that the other curves are not computed again
- Compute the shade of the curves from the number of visible images,
  instead of all images (hidden ones included)
- Flush the closing of the previous test windows in the tests, which
  would otherwise hide the cross-section panels

Refs #89

Assisted-by: Claude Opus 5.5
The scaling functions require the anti-aliasing kernel to have the data
type of the data they scale, which was not the case:

- when exporting an image area without the LUT but with the
  interpolation while the Z-axis log scale was enabled: the raw data was
  exported with the float64 kernel of its logarithm;
- after set_data with data of another type: the kernel kept the former
  type, so that drawing the image failed (aborting the application with
  PyQt5), as well as exporting it.

Add BaseImageItem._get_interpolation_for, which gives the kernel the data
type of the data to be scaled, used by all export_roi implementations,
and _sync_interpolation_dtype, which keeps the kernel in the data type of
the data drawn, now also called by set_data.

Refs #89

Assisted-by: Claude Opus 5.5
plotpy.widgets.about.get_python_libs_info and the plotpy-benchmarks
header called guidata.widgets.about.get_python_libs_info, which does not
exist (renamed by mistake with the "infos" to "info" renaming of PlotPy's
own functions), and raised AttributeError.

The benchmark header now uses PlotPy's get_python_libs_info, which also
gives the version of PlotPy.

Refs #89

Assisted-by: Claude Opus 5.5
@PierreRaybaut
PierreRaybaut merged commit 615a4f8 into develop Oct 30, 2026
7 checks passed
@PierreRaybaut
PierreRaybaut deleted the fix/89-csection-aa-about branch October 30, 2026 09:07
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