bec-widgets 0.55.0__py3-none-any.whl → 0.56.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. .gitlab-ci.yml +113 -8
  2. CHANGELOG.md +34 -28
  3. PKG-INFO +3 -1
  4. bec_widgets/examples/jupyter_console/jupyter_console_window.py +28 -38
  5. bec_widgets/examples/motor_movement/motor_control_compilations.py +1 -7
  6. bec_widgets/utils/__init__.py +1 -0
  7. bec_widgets/utils/crosshair.py +13 -9
  8. bec_widgets/utils/ui_loader.py +58 -0
  9. bec_widgets/widgets/motor_control/motor_table/motor_table.py +44 -43
  10. bec_widgets/widgets/motor_control/movement_absolute/movement_absolute.py +25 -23
  11. bec_widgets/widgets/motor_control/movement_relative/movement_relative.py +51 -48
  12. bec_widgets/widgets/spiral_progress_bar/ring.py +5 -5
  13. {bec_widgets-0.55.0.dist-info → bec_widgets-0.56.1.dist-info}/METADATA +3 -1
  14. {bec_widgets-0.55.0.dist-info → bec_widgets-0.56.1.dist-info}/RECORD +22 -43
  15. docs/user/apps.md +1 -26
  16. pyproject.toml +2 -1
  17. tests/end-2-end/test_bec_dock_rpc_e2e.py +1 -1
  18. tests/unit_tests/test_client_utils.py +2 -2
  19. tests/unit_tests/test_crosshair.py +5 -5
  20. tests/unit_tests/test_motor_control.py +49 -45
  21. bec_widgets/examples/eiger_plot/__init__.py +0 -0
  22. bec_widgets/examples/eiger_plot/eiger_plot.py +0 -307
  23. bec_widgets/examples/eiger_plot/eiger_plot.ui +0 -207
  24. bec_widgets/examples/mca_readout/__init__.py +0 -0
  25. bec_widgets/examples/mca_readout/mca_plot.py +0 -159
  26. bec_widgets/examples/mca_readout/mca_sim.py +0 -28
  27. bec_widgets/examples/modular_app/___init__.py +0 -0
  28. bec_widgets/examples/modular_app/modular.ui +0 -92
  29. bec_widgets/examples/modular_app/modular_app.py +0 -197
  30. bec_widgets/examples/motor_movement/config_example.yaml +0 -17
  31. bec_widgets/examples/motor_movement/csax_bec_config.yaml +0 -10
  32. bec_widgets/examples/motor_movement/csaxs_config.yaml +0 -17
  33. bec_widgets/examples/motor_movement/motor_example.py +0 -1344
  34. bec_widgets/examples/stream_plot/__init__.py +0 -0
  35. bec_widgets/examples/stream_plot/line_plot.ui +0 -155
  36. bec_widgets/examples/stream_plot/stream_plot.py +0 -337
  37. docs/user/apps/modular_app.md +0 -6
  38. docs/user/apps/motor_app.md +0 -34
  39. docs/user/apps/motor_app_10fps.gif +0 -0
  40. docs/user/apps/plot_app.md +0 -6
  41. tests/unit_tests/test_eiger_plot.py +0 -115
  42. tests/unit_tests/test_stream_plot.py +0 -158
  43. {bec_widgets-0.55.0.dist-info → bec_widgets-0.56.1.dist-info}/WHEEL +0 -0
  44. {bec_widgets-0.55.0.dist-info → bec_widgets-0.56.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,158 +0,0 @@
1
- # pylint: disable = no-name-in-module,missing-class-docstring, missing-module-docstring
2
- import threading
3
- from unittest import mock
4
-
5
- import numpy as np
6
- import pytest
7
- from bec_lib import messages
8
- from bec_lib.redis_connector import RedisConnector
9
- from pytestqt import qtbot
10
-
11
- from bec_widgets.examples.stream_plot.stream_plot import StreamPlot
12
-
13
-
14
- @pytest.fixture(scope="function")
15
- def stream_app(qtbot):
16
- """Helper function to set up the StreamPlot widget."""
17
- client = mock.MagicMock()
18
- widget = StreamPlot(client=client)
19
- qtbot.addWidget(widget)
20
- qtbot.waitExposed(widget)
21
- yield widget
22
- widget.close()
23
-
24
-
25
- def test_roi_signals_emitted(qtbot, stream_app):
26
- region = (0.1, 0.9)
27
- with qtbot.waitSignal(stream_app.roi_signal, timeout=1000) as blocker:
28
- stream_app.roi_signal.emit(region)
29
- assert blocker.signal_triggered
30
- assert blocker.args == [region]
31
-
32
-
33
- def test_update_signals_emitted(qtbot, stream_app):
34
- # Mimic data coming from the data stream
35
- stream_app.plotter_data_x = [list(range(10))] # Replace with the actual x data
36
- stream_app.plotter_data_y = [list(range(10))] # Replace with the actual y data
37
-
38
- # Initialize curves
39
- stream_app.init_curves()
40
-
41
- with qtbot.waitSignal(stream_app.update_signal, timeout=1000) as blocker:
42
- stream_app.update_signal.emit()
43
- assert blocker.signal_triggered
44
-
45
-
46
- def test_ui_initialization(qtbot, stream_app):
47
- """Checking the UI creation."""
48
-
49
- # Check if UI elements are initialized correctly
50
- assert stream_app.label_plot is not None
51
- assert stream_app.label_plot_moved is not None
52
- assert stream_app.label_plot_clicked is not None
53
- assert stream_app.label_image_moved is not None
54
- assert stream_app.label_image_clicked is not None
55
-
56
- # Check if plots are initialized correctly
57
- assert stream_app.plot is not None
58
- assert stream_app.plot_image is not None
59
-
60
- # Check if ROI selector is initialized correctly
61
- assert stream_app.roi_selector is not None
62
-
63
-
64
- def test_1d_plotting_data(qtbot, stream_app):
65
- # Set up some mock data
66
- x_data = [list(range(10))]
67
- y_data = [list(range(10))]
68
-
69
- # Manually set the data attributes
70
- stream_app.plotter_data_x = x_data
71
- stream_app.plotter_data_y = y_data
72
- stream_app.y_value_list = ["Curve 1"]
73
-
74
- # Initialize curves and update the plot
75
- stream_app.init_curves()
76
- stream_app.update() # This should update the plot with the new data
77
-
78
- # Check the data on the plot
79
- for idx, curve in enumerate(stream_app.curves):
80
- np.testing.assert_array_equal(curve.xData, x_data[0]) # Access the first list of x_data
81
- np.testing.assert_array_equal(
82
- curve.yData, y_data[idx]
83
- ) # Access the list of y_data for each curve without additional indexing
84
-
85
-
86
- def test_flip_even_rows(qtbot, stream_app):
87
- # Create a numpy array with some known data
88
- original_array = np.array(
89
- [[1, 2, 3, 4, 5], [6, 7, 8, 9, 10], [11, 12, 13, 14, 15], [16, 17, 18, 19, 20]]
90
- )
91
-
92
- # Call flip_even_rows on the original array
93
- flipped_array = stream_app.flip_even_rows(original_array)
94
-
95
- # Expected array flipped along the rows with even indices
96
- expected_array = np.array(
97
- [[1, 2, 3, 4, 5], [10, 9, 8, 7, 6], [11, 12, 13, 14, 15], [20, 19, 18, 17, 16]]
98
- )
99
-
100
- # Check that flip_even_rows returned the expected result
101
- np.testing.assert_array_equal(flipped_array, expected_array)
102
-
103
-
104
- def test_on_dap_update(qtbot, stream_app):
105
- """2D image rendering by dap update"""
106
- # Create some mock data to be "received" by the slot
107
- data_dict = {"data": {"z": np.random.rand(10, 10)}}
108
- metadata_dict = {}
109
-
110
- # Trigger the slot
111
- stream_app.on_dap_update(data_dict, metadata_dict)
112
-
113
- # Apply the same transformation to the test data
114
- expected_data = stream_app.flip_even_rows(data_dict["data"]["z"])
115
-
116
- # Now check the state of the StreamPlot object
117
- # For example, check the data of the image plot:
118
- np.testing.assert_array_equal(stream_app.img.image, expected_data)
119
-
120
-
121
- ####################
122
- # Until Here
123
- ####################
124
-
125
- # def test_new_proj(qtbot, stream_app): #TODO this test is not working, does it make sense testing even?
126
- # # Create some mock content to be "received" by the slot
127
- # content_dict = {"signals": {"proj_nr": 1}}
128
- # metadata_dict = {}
129
- #
130
- # # Manually create some mock data that new_proj would work with
131
- # # This step may need to be adjusted to fit the actual behavior of new_proj
132
- # mock_data = {
133
- # "q": np.array([1, 2, 3, 4, 5]),
134
- # "norm_sum": np.array([6, 7, 8, 9, 10]),
135
- # "metadata": "some_metadata",
136
- # }
137
- #
138
- # # Assume the RedisConnector client would return this data when new_proj is called
139
- # mock_message = mock.MagicMock(spec=messages.DeviceMessage)
140
- # mock_message.__getitem__.side_effect = lambda key: mock_data[key]
141
- # stream_app.client.producer.get = mock.MagicMock(return_value=mock_message.dumps())
142
- #
143
- # # Trigger the slot
144
- # stream_app.new_proj(content_dict, metadata_dict)
145
- #
146
- # # Now check the state of the StreamPlot object
147
- # # For example, check that the plotter_data_x attribute was updated correctly:
148
- # np.testing.assert_array_equal(stream_app.plotter_data_x, [mock_data["q"]])
149
- # assert stream_app._current_proj == 1
150
- # assert stream_app._current_q == mock_data["q"]
151
- # assert stream_app._current_norm == mock_data["norm_sum"]
152
- # assert stream_app._current_metadata == mock_data["metadata"]
153
-
154
-
155
- # def test_connection_creation(qtbot, stream_app): #TODO maybe test connections in a different way?
156
- # assert isinstance(stream_app.producer, RedisConnector)
157
- # assert isinstance(stream_app.data_retriever, threading.Thread)
158
- # assert stream_app.data_retriever.is_alive()