Repository navigation
Empty cross-section curves, anti-aliasing kernel TypeError and About AttributeError #89
Description
Describe the bugs
Three independent bugs, found while reviewing PlotPy before the 2.12.0 release.
1. Cross-section curve stays empty for an image added or shown again
With the X/Y cross-section panels enabled and a cross-section marker (or shape) already active, the cross-section curve of an image is empty (dataSize() == 0) when:
- the image is shown again after having been hidden (e.g. from the item list panel, or with
plot.set_item_visible(item, True)); - the image is added to the plot.
The curve is only computed once the marker is moved again.
BaseCrossSectionPlot.items_changed (plotpy/panels/csection/csplot.py) creates the cross-section items of the new images after calling update_plot(refresh=False), and never computes their data. Before commit 9a221b7 ("only keep cross-section curves for visible images", not released yet), the curve of an image shown again was kept while hidden: it was not empty, but it showed the cross section at a former marker position. For an image added to the plot, the curve has always been empty.
Besides, the shade of the cross-section curves is SHADE / len(new_sources), where new_sources includes hidden images, so that the curves become almost transparent when many images are hidden.
2. TypeError: AA Mask data type must be ... with the anti-aliasing interpolation
The C++ scaling functions (_scale_rect, _scale_xy, _scale_tr) require the anti-aliasing kernel (item.interpolate[1]) to have the same data type as the array they scale. This is not the case:
- when exporting an image area without the LUT but with the interpolation (
export_roi(..., apply_lut=False, apply_interpolation=True), e.g. with the rectangle snapshot tool, "Apply contrast settings" unchecked and "Apply interpolation algorithm" checked) while the Z-axis logarithmic scale is enabled: the kernel has the type of the logarithm of the data (float64), whereas the raw data (e.g.uint16) is exported; - after
set_datawith data of another type (e.g.uint16replaced byfloat32): the kernel keeps the former type. Both exporting the image and drawing it then fail. When drawing, the exception is raised in a Qt virtual method, which aborts the application with PyQt5 (exit code0xC0000409on Windows).
This affects ImageItem, XYImageItem, TrImageItem and their masked variants.
3. AttributeError in plotpy.widgets.about.get_python_libs_info and plotpy-benchmarks
plotpy.widgets.about.get_python_libs_info() and the benchmark banner (plotpy-benchmarks GUI script) call guidata.widgets.about.get_python_libs_info, which does not exist: the guidata function is get_python_libs_infos. Both raise:
AttributeError: module 'guidata.widgets.about' has no attribute 'get_python_libs_info'
This was introduced by the "info"/"infos" renaming of commit 6fc54bd (PlotPy 2.8.0), which also renamed the call to the guidata function. Pylint reports it as E1101.
To Reproduce
import numpy as np
from guidata.qthelpers import qt_app_context
from qtpy import QtCore as QC
from plotpy.builder import make
from plotpy.items import assemble_imageitems
with qt_app_context(exec_loop=False):
# 1. Empty cross section
win = make.dialog(type="image", show_xsection=True, show_ysection=True)
win.show()
plot = win.manager.get_plot()
xcs = win.manager.get_xcs_panel().cs_plot
img1 = make.image(np.arange(256, dtype=float).reshape(16, 16))
img2 = make.image(np.full((16, 16), 42.0))
plot.add_item(img1)
plot.add_item(img2)
marker = make.marker(position=(5, 5))
plot.add_item(marker)
xcs.register_shape(plot, marker)
print(xcs.known_items[img1].dataSize()) # 16
plot.set_item_visible(img1, False)
plot.set_item_visible(img1, True)
print(xcs.known_items[img1].dataSize()) # 0
# 2. Anti-aliasing kernel data type
rect = QC.QRectF(0, 0, 6, 4)
item = make.image(np.arange(1, 25, dtype=np.uint16).reshape(4, 6))
item.set_interpolation(2, 3) # INTERP_AA
item.set_zaxis_log_state(True)
assemble_imageitems([item], rect, 6, 4, apply_lut=False, apply_interpolation=True)
# TypeError: AA Mask data type must be 4
# 3. About
from plotpy.widgets.about import get_python_libs_info
get_python_libs_info() # AttributeErrorExpected behavior
- The cross-section curve of an image added or shown again is computed as soon as the image is shown (unless the auto-refresh of the cross-section panel is disabled), and the shade of the curves depends on the number of visible images only.
- Exporting and drawing images with the anti-aliasing interpolation work whatever the Z-axis scale and the data type changes.
get_python_libs_inforeturns the Python and libraries information, andplotpy-benchmarksruns.
Activity
PierreRaybaut commentedon Oct 30, 2026
Fixed by #90 (merged into develop, part of PlotPy 2.12.0).
fix(csection): compute cross sections of images added or shown again
fix(image): match the anti-aliasing kernel to the scaled data type
fix(about): call guidata's get_python_libs_infos
docs: add release notes for the cross-section, anti-aliasing and abou…