Skip to content

Commit 1a5899a

Browse files
committed
Fixed ImageItem.get_stats patch (PlotPy compat.)
1 parent 5efe09a commit 1a5899a

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

cdl/patch.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
from plotpy.panels.csection import csplot, cswidget
2626
from qtpy import QtCore as QC
2727
from qtpy.QtWidgets import QApplication, QMainWindow
28-
from qwt import QwtLinearScaleEngine
28+
from qwt import QwtLinearScaleEngine, QwtScaleDraw
2929
from qwt import QwtLogScaleEngine as QwtLog10ScaleEngine
30-
from qwt import QwtScaleDraw
3130

3231
from cdl.config import APP_NAME, _
3332
from cdl.core.model.signal import create_signal
@@ -92,12 +91,29 @@ def select(self):
9291

9392
# Adding centroid parameter to the image stats tool
9493
@monkeypatch_method(plotpy.items.BaseImageItem, "ImageItem")
95-
def get_stats(self, x0, y0, x1, y1):
94+
def get_stats(
95+
self,
96+
x0: float,
97+
y0: float,
98+
x1: float,
99+
y1: float,
100+
show_surface: bool = False,
101+
show_integral: bool = False,
102+
) -> str:
96103
"""Return formatted string with stats on image rectangular area
97-
(output should be compatible with AnnotatedShape.get_infos)"""
104+
(output should be compatible with AnnotatedShape.get_infos)
105+
106+
Args:
107+
x0: X0
108+
y0: Y0
109+
x1: X1
110+
y1: Y1
111+
show_surface: Show surface (Default value = False)
112+
show_integral: Show integral (Default value = False)
113+
"""
98114
with warnings.catch_warnings():
99115
warnings.simplefilter("ignore", UserWarning)
100-
txt = self._old_ImageItem_get_stats(x0, y0, x1, y1)
116+
txt = self._old_ImageItem_get_stats(x0, y0, x1, y1, show_surface, show_integral)
101117
ix0, iy0, ix1, iy1 = self.get_closest_index_rect(x0, y0, x1, y1)
102118
data = self.data[iy0:iy1, ix0:ix1]
103119

0 commit comments

Comments
 (0)