Skip to content

Commit fa641bf

Browse files
committed
SignalObjPlotPyAdapter: adapt to new SignalObj handling of dx and dy
1 parent 7d19a54 commit fa641bf

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

datalab/adapters_plotpy/signal.py

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -223,29 +223,20 @@ def make_item(self, update_from: CurveItem | None = None) -> CurveItem:
223223
Plot item
224224
"""
225225
o = self.obj
226-
if len(o.xydata) in (2, 3, 4):
226+
if len(o.xydata) in (2, 4):
227227
assert isinstance(o.xydata, np.ndarray)
228228
if len(o.xydata) == 2: # x, y signal
229229
x, y = o.xydata
230-
assert isinstance(x, np.ndarray) and isinstance(y, np.ndarray)
231230
item = make.mcurve(x.real, y.real, label=o.title)
232-
elif len(o.xydata) == 3: # x, y, dy error bar signal
233-
x, y, dy = o.xydata
234-
assert (
235-
isinstance(x, np.ndarray)
236-
and isinstance(y, np.ndarray)
237-
and isinstance(dy, np.ndarray)
238-
)
239-
item = make.merror(x.real, y.real, dy.real, label=o.title)
240-
elif len(o.xydata) == 4: # x, y, dx, dy error bar signal
231+
else: # x, y, dx, dy error bar signal
241232
x, y, dx, dy = o.xydata
242-
assert (
243-
isinstance(x, np.ndarray)
244-
and isinstance(y, np.ndarray)
245-
and isinstance(dx, np.ndarray)
246-
and isinstance(dy, np.ndarray)
247-
)
248-
item = make.merror(x.real, y.real, dx.real, dy.real, label=o.title)
233+
if o.dx is None and o.dy is None: # x, y signal with no error
234+
item = make.mcurve(x.real, y.real, label=o.title)
235+
elif o.dx is None: # x, y, dy error bar signal with y error
236+
item = make.merror(x.real, y.real, dy.real, label=o.title)
237+
else: # x, y, dx, dy error bar signal with x error
238+
dy = np.zeros_like(y) if dy is None else dy
239+
item = make.merror(x.real, y.real, dx.real, dy.real, label=o.title)
249240
CURVESTYLES.apply_style(item.param)
250241
apply_downsampling(item, do_not_update=True)
251242
else:

0 commit comments

Comments
 (0)