mirror of
https://github.com/bec-project/bec_widgets.git
synced 2026-11-25 02:28:09 +01:00
fix(waveform): attribute access on stored_data_info in auto x shape-mismatch warning
This commit is contained in:
1 parent
840669618b
commit
1ad1eca05e
2 files changed
+24
-2
No files matched your search
@@ -1301,9 +1301,10 @@ class Waveform(PlotBase):
|
||||
)
|
||||
curve.setVisible(False)
|
||||
return
|
||||
if y_shape != all_devices_used.get(scan_motors[0]).get(signal_x, {}).shape[0]:
|
||||
x_shape = all_devices_used.get(scan_motors[0]).get(signal_x).shape[0]
|
||||
if y_shape != x_shape:
|
||||
logger.warning(
|
||||
f"Shape mismatch for x data '{all_devices_used.get(scan_motors[0]).get(signal_x, {}).get('shape', [0])[0]}' and y data '{y_shape}' in history curve '{curve.name()}'; scan ID: {curve.config.scan_id}."
|
||||
f"Shape mismatch for x data '{x_shape}' and y data '{y_shape}' in history curve '{curve.name()}'; scan ID: {curve.config.scan_id}."
|
||||
)
|
||||
curve.setVisible(False)
|
||||
return
|
||||
|
||||
@@ -8,6 +8,7 @@ from unittest.mock import MagicMock
|
||||
import numpy as np
|
||||
import pyqtgraph as pg
|
||||
import pytest
|
||||
from bec_lib.scan_history import ScanHistory
|
||||
from pyqtgraph.graphicsItems.DateAxisItem import DateAxisItem
|
||||
from qtpy.QtCore import QTimer
|
||||
from qtpy.QtWidgets import QApplication, QCheckBox, QDialog, QDialogButtonBox, QDoubleSpinBox
|
||||
@@ -1628,6 +1629,26 @@ def test_history_curve_auto_valid_uses_first_report_device(
|
||||
assert c.config.current_x_mode == "auto"
|
||||
|
||||
|
||||
def test_history_curve_auto_shape_mismatch_hides_curve(
|
||||
qtbot, mocked_client, scan_history_factory, suppress_message_box
|
||||
):
|
||||
"""
|
||||
For auto x-mode, a shape mismatch between the report device and y data must
|
||||
hide the curve without crashing on the pydantic stored_data_info entries.
|
||||
"""
|
||||
wf = create_widget(qtbot, Waveform, client=mocked_client)
|
||||
wf.x_mode = "auto"
|
||||
# bpm4i is stored with shape (10,); 16 points make the report device (samx) mismatch
|
||||
history_msg = scan_history_factory(scan_id="hist_auto_shape", scan_number=1, num_points=16)
|
||||
wf.client.history = ScanHistory(wf.client, False)
|
||||
wf.client.history._scan_data[history_msg.scan_id] = history_msg
|
||||
wf.client.history._scan_ids.append(history_msg.scan_id)
|
||||
wf.client.queue.scan_storage.current_scan = None
|
||||
c = wf.plot(device_y="bpm4i", signal_y="bpm4i", scan_id=history_msg.scan_id)
|
||||
assert c is not None
|
||||
assert not c.isVisible()
|
||||
|
||||
|
||||
def test_history_curve_file_not_found_returns_none(qtbot, mocked_client, scan_history_factory):
|
||||
"""
|
||||
If the history file path does not exist, plot should return None.
|
||||
|
||||
Reference in new issue
Block a user