qplotter 1.6.0b3__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.
- qplot/__init__.py +46 -0
- qplot/__main__.py +232 -0
- qplot/_auxiliary_paths.py +63 -0
- qplot/_metadata.py +12 -0
- qplot/_repair.py +14 -0
- qplot/_shutdown_supervisor.py +4049 -0
- qplot/_version.py +12 -0
- qplot/_windows_shutdown_job.py +1166 -0
- qplot/configuration/__init__.py +3 -0
- qplot/configuration/config.py +573 -0
- qplot/configuration/config_schema.json +319 -0
- qplot/configuration/scripts.py +255 -0
- qplot/configuration/themes/__init__.py +13 -0
- qplot/configuration/themes/_base.py +579 -0
- qplot/configuration/themes/blank.py +17 -0
- qplot/configuration/themes/dark.py +54 -0
- qplot/configuration/themes/light.py +54 -0
- qplot/datahandling/LoadFromDB.py +224 -0
- qplot/datahandling/__init__.py +47 -0
- qplot/datahandling/_trusted_live_helper.py +812 -0
- qplot/datahandling/_trusted_live_protocol.py +1745 -0
- qplot/datahandling/database.py +2330 -0
- qplot/datahandling/dimensions.py +43 -0
- qplot/datahandling/file_identity.py +461 -0
- qplot/datahandling/parameter_data.py +149 -0
- qplot/datahandling/plot_progress.py +17 -0
- qplot/datahandling/qcodes_cache.py +277 -0
- qplot/datahandling/qcodes_compat.py +14 -0
- qplot/datahandling/readSQL.py +2442 -0
- qplot/datahandling/readonly.py +2561 -0
- qplot/datahandling/source_activity.py +21 -0
- qplot/datahandling/trusted_array_preview.py +127 -0
- qplot/datahandling/trusted_derived_cache.py +1605 -0
- qplot/datahandling/trusted_derived_rendering.py +868 -0
- qplot/datahandling/trusted_heatmap.py +241 -0
- qplot/datahandling/trusted_live.py +2808 -0
- qplot/datahandling/trusted_live_queries.py +5907 -0
- qplot/datahandling/trusted_live_service.py +1894 -0
- qplot/datahandling/trusted_live_supervisor.py +2161 -0
- qplot/datahandling/trusted_plot.py +283 -0
- qplot/datahandling/trusted_presentation.py +1065 -0
- qplot/datahandling/trusted_snapshot.py +1132 -0
- qplot/datahandling/trusted_work_coordinator.py +2157 -0
- qplot/datahandling/trusted_work_scheduler.py +1204 -0
- qplot/diagnostics.py +241 -0
- qplot/resources/testdata/qplot_test_db_01_10mb.csv +11 -0
- qplot/resources/testdata/qplot_test_db_02_25mb.csv +14 -0
- qplot/resources/testdata/qplot_test_db_03_50mb.csv +17 -0
- qplot/resources/testdata/qplot_test_db_04_100mb.csv +20 -0
- qplot/resources/testdata/qplot_test_db_05_250mb.csv +23 -0
- qplot/resources/testdata/qplot_test_db_06_500mb.csv +26 -0
- qplot/resources/testdata/qplot_test_db_07_1gb.csv +29 -0
- qplot/resources/testdata/qplot_test_db_08_5gb.csv +32 -0
- qplot/resources/testdata/qplot_test_db_09_10gb.csv +35 -0
- qplot/resources/testdata/qplot_test_db_10_30gb.csv +38 -0
- qplot/testdata.py +1733 -0
- qplot/tools/__init__.py +13 -0
- qplot/tools/finite_means.py +114 -0
- qplot/tools/general.py +134 -0
- qplot/tools/heatmap_geometry.py +381 -0
- qplot/tools/operation_registry.py +179 -0
- qplot/tools/plot_tools.py +625 -0
- qplot/tools/sample_statistics.py +56 -0
- qplot/tools/worker.py +2787 -0
- qplot/windows/__init__.py +9 -0
- qplot/windows/_colorbar.py +422 -0
- qplot/windows/_commands.py +523 -0
- qplot/windows/_config_persistence.py +123 -0
- qplot/windows/_database_actions.py +4904 -0
- qplot/windows/_dataset_handle.py +221 -0
- qplot/windows/_dragdrop.py +71 -0
- qplot/windows/_export_paths.py +1167 -0
- qplot/windows/_help.py +169 -0
- qplot/windows/_native_averaging.py +173 -0
- qplot/windows/_native_transforms.py +389 -0
- qplot/windows/_plot1d_snap.py +608 -0
- qplot/windows/_plot1d_traces.py +2183 -0
- qplot/windows/_plot2d_colorbar.py +1126 -0
- qplot/windows/_plot2d_colorbar_dialog.py +786 -0
- qplot/windows/_plot2d_layers.py +2197 -0
- qplot/windows/_plot2d_sweeps.py +712 -0
- qplot/windows/_plotWin.py +1993 -0
- qplot/windows/_plot_actions.py +2695 -0
- qplot/windows/_plot_appearance.py +276 -0
- qplot/windows/_plot_axis_scaling.py +1485 -0
- qplot/windows/_plot_export.py +1445 -0
- qplot/windows/_plot_feedback.py +110 -0
- qplot/windows/_plot_marquee.py +656 -0
- qplot/windows/_plot_refresh.py +942 -0
- qplot/windows/_plot_state.py +239 -0
- qplot/windows/_plot_transform_labels.py +60 -0
- qplot/windows/_preferences.py +635 -0
- qplot/windows/_refresh_interval.py +70 -0
- qplot/windows/_run_controls.py +828 -0
- qplot/windows/_shortcuts.py +47 -0
- qplot/windows/_subplots/__init__.py +8 -0
- qplot/windows/_subplots/subplot1d.py +531 -0
- qplot/windows/_subplots/subplot2d.py +918 -0
- qplot/windows/_svg_export.py +209 -0
- qplot/windows/_trusted_derived_qt.py +1759 -0
- qplot/windows/_widgets/__init__.py +23 -0
- qplot/windows/_widgets/_run_formatting.py +387 -0
- qplot/windows/_widgets/details_tables.py +1119 -0
- qplot/windows/_widgets/dropbox.py +290 -0
- qplot/windows/_widgets/operations.py +460 -0
- qplot/windows/_widgets/preview.py +2997 -0
- qplot/windows/_widgets/run_list_items.py +488 -0
- qplot/windows/_widgets/toolbar.py +111 -0
- qplot/windows/_widgets/treeWidgets.py +2572 -0
- qplot/windows/_window_controls.py +413 -0
- qplot/windows/main.py +1635 -0
- qplot/windows/plot1d.py +311 -0
- qplot/windows/plot2d.py +1901 -0
- qplotter-1.6.0b3.dist-info/METADATA +318 -0
- qplotter-1.6.0b3.dist-info/RECORD +119 -0
- qplotter-1.6.0b3.dist-info/WHEEL +5 -0
- qplotter-1.6.0b3.dist-info/entry_points.txt +4 -0
- qplotter-1.6.0b3.dist-info/licenses/LICENSE +21 -0
- qplotter-1.6.0b3.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The functions in this file are addapted from qcodes to allow for thread safe
|
|
3
|
+
and single parameter loading. See:
|
|
4
|
+
qcodes.dataset.data_set_cache
|
|
5
|
+
qcodes.dataset.sqlite.queries
|
|
6
|
+
for the original functions of similar names as well as typing.
|
|
7
|
+
"""
|
|
8
|
+
from math import prod
|
|
9
|
+
from typing import TYPE_CHECKING
|
|
10
|
+
|
|
11
|
+
import numpy.typing as npt
|
|
12
|
+
from qcodes.dataset.data_set_cache import _merge_data
|
|
13
|
+
from qcodes.dataset.sqlite.queries import completed
|
|
14
|
+
|
|
15
|
+
from qplot.datahandling.parameter_data import (
|
|
16
|
+
_check_noop,
|
|
17
|
+
flatten_record_columns,
|
|
18
|
+
get_parameter_data_for_one_paramtree,
|
|
19
|
+
integer_preserving_dtype,
|
|
20
|
+
)
|
|
21
|
+
from qplot.datahandling.qcodes_cache import (
|
|
22
|
+
cache_data,
|
|
23
|
+
cache_dataset_completed,
|
|
24
|
+
cache_dataset_connection,
|
|
25
|
+
cache_dataset_run_id,
|
|
26
|
+
cache_is_live,
|
|
27
|
+
cache_lock,
|
|
28
|
+
cache_parameter_is_synchronized,
|
|
29
|
+
prepare_cache_if_empty,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
if TYPE_CHECKING:
|
|
33
|
+
from qcodes.dataset.data_set_cache import DataSetCacheWithDBBackend
|
|
34
|
+
from qcodes.dataset.descriptions.param_spec import ParamSpec
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def append_shaped_parameter_data_to_existing_arrays(
|
|
38
|
+
rundescriber,
|
|
39
|
+
meas_parameter : str,
|
|
40
|
+
write_status,
|
|
41
|
+
existing_data,
|
|
42
|
+
new_data,
|
|
43
|
+
check_cancelled=_check_noop,
|
|
44
|
+
):
|
|
45
|
+
"""
|
|
46
|
+
Append datadict to an already existing datadict and return the merged
|
|
47
|
+
data.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
rundescriber: The rundescriber that describes the run
|
|
51
|
+
write_status: Mapping from dependent parameter name to number of rows
|
|
52
|
+
written to the cache previously.
|
|
53
|
+
new_data: Mapping from dependent parameter name to mapping
|
|
54
|
+
from parameter name to numpy arrays that the data should be
|
|
55
|
+
appended to.
|
|
56
|
+
existing_data: Mapping from dependent parameter name to mapping
|
|
57
|
+
from parameter name to numpy arrays of new data.
|
|
58
|
+
|
|
59
|
+
Returns:
|
|
60
|
+
Updated write and read status, and the updated ``data``
|
|
61
|
+
|
|
62
|
+
"""
|
|
63
|
+
merged_data = {}
|
|
64
|
+
|
|
65
|
+
updated_write_status = dict(write_status)
|
|
66
|
+
|
|
67
|
+
existing_data_1_tree = existing_data.get(meas_parameter, {})
|
|
68
|
+
|
|
69
|
+
new_data_1_tree = new_data.get(meas_parameter, {})
|
|
70
|
+
|
|
71
|
+
shapes = rundescriber.shapes
|
|
72
|
+
if shapes is not None:
|
|
73
|
+
shape = shapes.get(meas_parameter, None)
|
|
74
|
+
else:
|
|
75
|
+
shape = None
|
|
76
|
+
|
|
77
|
+
overflow_count = None
|
|
78
|
+
# QCoDeS inserts shaped refreshes into existing arrays in place. Work on
|
|
79
|
+
# private copies so a concurrent worker cannot mutate the shared cache
|
|
80
|
+
# before qPlot's monotonic commit check.
|
|
81
|
+
if shape is not None:
|
|
82
|
+
# Object cells count records; shaped cache offsets count samples.
|
|
83
|
+
# Flatten only the new records so QCoDeS' usual padding and offsets
|
|
84
|
+
# still apply, including the same missing-value handling.
|
|
85
|
+
if any(values.dtype.kind == "O" for values in new_data_1_tree.values()):
|
|
86
|
+
new_data_1_tree = flatten_record_columns(new_data_1_tree, check_cancelled)
|
|
87
|
+
private_data = {}
|
|
88
|
+
for name, values in existing_data_1_tree.items():
|
|
89
|
+
check_cancelled()
|
|
90
|
+
incoming = new_data_1_tree.get(name)
|
|
91
|
+
dtype = values.dtype
|
|
92
|
+
if (
|
|
93
|
+
values.size and incoming is not None and incoming.size
|
|
94
|
+
and values.dtype.kind in "biufcO" and incoming.dtype.kind in "biufcO"
|
|
95
|
+
):
|
|
96
|
+
# QCoDeS' shaped insertion assigns into the cached dtype.
|
|
97
|
+
# Promote every numeric column before insertion, including
|
|
98
|
+
# coordinates and complex values that plot validation rejects.
|
|
99
|
+
# Empty cache placeholders must not dictate the first dtype.
|
|
100
|
+
dtype = integer_preserving_dtype((values.dtype, incoming.dtype))
|
|
101
|
+
# Shaped insertion writes through ravel(), so retain the old
|
|
102
|
+
# copy() behavior of making C-contiguous working arrays.
|
|
103
|
+
private_data[name] = values.astype(dtype, order="C", copy=True)
|
|
104
|
+
existing_data_1_tree = private_data
|
|
105
|
+
check_cancelled()
|
|
106
|
+
acquired_before = write_status.get(meas_parameter) or 0
|
|
107
|
+
incoming = new_data_1_tree.get(meas_parameter)
|
|
108
|
+
acquired_after = acquired_before + (incoming.size if incoming is not None else 0)
|
|
109
|
+
if acquired_after > prod(shape):
|
|
110
|
+
# Retain the flattened fallback for scans exceeding their plan,
|
|
111
|
+
# but append to acquired samples, never to unused cache padding.
|
|
112
|
+
existing_data_1_tree = {
|
|
113
|
+
name: values.ravel()[:acquired_before]
|
|
114
|
+
for name, values in existing_data_1_tree.items()
|
|
115
|
+
}
|
|
116
|
+
new_data_1_tree = {
|
|
117
|
+
name: values.reshape(-1) for name, values in new_data_1_tree.items()
|
|
118
|
+
}
|
|
119
|
+
shape = None
|
|
120
|
+
overflow_count = acquired_after
|
|
121
|
+
|
|
122
|
+
if shape is None:
|
|
123
|
+
# QCoDeS appends dense record columns with NumPy's usual promotion.
|
|
124
|
+
# Promote both sides first when signed/unsigned (or integer/float)
|
|
125
|
+
# records need object cells to retain every acquired integer.
|
|
126
|
+
existing_data_1_tree = dict(existing_data_1_tree)
|
|
127
|
+
new_data_1_tree = dict(new_data_1_tree)
|
|
128
|
+
for name, incoming in new_data_1_tree.items():
|
|
129
|
+
check_cancelled()
|
|
130
|
+
previous = existing_data_1_tree.get(name)
|
|
131
|
+
if previous is None or not previous.size or not incoming.size:
|
|
132
|
+
continue
|
|
133
|
+
dtype = integer_preserving_dtype((previous.dtype, incoming.dtype))
|
|
134
|
+
if dtype.kind == "O":
|
|
135
|
+
existing_data_1_tree[name] = previous.astype(dtype, copy=False)
|
|
136
|
+
new_data_1_tree[name] = incoming.astype(dtype, copy=False)
|
|
137
|
+
|
|
138
|
+
(merged_data[meas_parameter], updated_write_status[meas_parameter]) = (
|
|
139
|
+
_merge_data(
|
|
140
|
+
existing_data_1_tree,
|
|
141
|
+
new_data_1_tree,
|
|
142
|
+
shape,
|
|
143
|
+
single_tree_write_status=write_status.get(meas_parameter),
|
|
144
|
+
meas_parameter=meas_parameter,
|
|
145
|
+
)
|
|
146
|
+
)
|
|
147
|
+
if overflow_count is not None:
|
|
148
|
+
# Unshaped QCoDeS appends reset this status; planned trees still need
|
|
149
|
+
# their acquired sample extent for subsequent reads and processing.
|
|
150
|
+
updated_write_status[meas_parameter] = overflow_count
|
|
151
|
+
check_cancelled()
|
|
152
|
+
return updated_write_status, merged_data
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def load_param_data_from_db_prep(
|
|
156
|
+
cache : "DataSetCacheWithDBBackend",
|
|
157
|
+
param : "ParamSpec",
|
|
158
|
+
connection=None,
|
|
159
|
+
):
|
|
160
|
+
if cache_is_live(cache):
|
|
161
|
+
raise RuntimeError(
|
|
162
|
+
"Cannot load data into this cache from the "
|
|
163
|
+
"database because this dataset is being built "
|
|
164
|
+
"in-memory."
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
if cache_parameter_is_synchronized(cache, param.name):
|
|
168
|
+
return True, cache_dataset_completed(cache)
|
|
169
|
+
|
|
170
|
+
with cache_lock(cache):
|
|
171
|
+
is_completed = completed(
|
|
172
|
+
connection or cache_dataset_connection(cache),
|
|
173
|
+
cache_dataset_run_id(cache),
|
|
174
|
+
)
|
|
175
|
+
if cache_data(cache) == {}:
|
|
176
|
+
prepare_cache_if_empty(cache)
|
|
177
|
+
|
|
178
|
+
# The worker must load and process the final rows before publishing this
|
|
179
|
+
# database completion observation to the viewer dataset.
|
|
180
|
+
return False, is_completed
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
def load_param_data_from_db(
|
|
184
|
+
conn,
|
|
185
|
+
table_name,
|
|
186
|
+
rundescriber,
|
|
187
|
+
meas_parameter : str,
|
|
188
|
+
write_status,
|
|
189
|
+
read_status,
|
|
190
|
+
existing_data,
|
|
191
|
+
end: int | None = None,
|
|
192
|
+
*,
|
|
193
|
+
check_cancelled=_check_noop,
|
|
194
|
+
):
|
|
195
|
+
# Data fetch
|
|
196
|
+
updated_read_status: dict[str, int] = dict(read_status)
|
|
197
|
+
new_data_dict: dict[str, dict[str, npt.NDArray]] = {}
|
|
198
|
+
|
|
199
|
+
start = read_status.get(meas_parameter, 0) + 1
|
|
200
|
+
new_data, n_rows_read = get_parameter_data_for_one_paramtree(
|
|
201
|
+
conn,
|
|
202
|
+
table_name,
|
|
203
|
+
rundescriber=rundescriber,
|
|
204
|
+
output_param=meas_parameter,
|
|
205
|
+
start=start,
|
|
206
|
+
end=end,
|
|
207
|
+
check_cancelled=check_cancelled,
|
|
208
|
+
)
|
|
209
|
+
new_data_dict[meas_parameter] = new_data
|
|
210
|
+
updated_read_status[meas_parameter] = start + n_rows_read - 1
|
|
211
|
+
|
|
212
|
+
# Data Update
|
|
213
|
+
(updated_write_status, merged_data) = (
|
|
214
|
+
append_shaped_parameter_data_to_existing_arrays(
|
|
215
|
+
rundescriber, meas_parameter, write_status, existing_data, new_data_dict,
|
|
216
|
+
check_cancelled=check_cancelled,
|
|
217
|
+
)
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
return (
|
|
221
|
+
updated_read_status,
|
|
222
|
+
updated_write_status,
|
|
223
|
+
merged_data
|
|
224
|
+
)
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
__all__ = [
|
|
2
|
+
"get_runs_basic_via_sql",
|
|
3
|
+
"get_runs_via_sql",
|
|
4
|
+
"get_selected_run_setpoint_summaries",
|
|
5
|
+
"get_snapshot_selected_run_detail",
|
|
6
|
+
"find_new_runs",
|
|
7
|
+
"get_run_status",
|
|
8
|
+
"has_finished",
|
|
9
|
+
"iter_run_detail_batches_via_sql",
|
|
10
|
+
"iter_run_shape_batches_via_sql",
|
|
11
|
+
"iter_run_storage_batches_via_sql",
|
|
12
|
+
"load_param_data_from_db_prep",
|
|
13
|
+
"load_param_data_from_db",
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
_EXPORT_MODULES = {
|
|
17
|
+
"get_runs_basic_via_sql": ".readSQL",
|
|
18
|
+
"get_runs_via_sql": ".readSQL",
|
|
19
|
+
"get_selected_run_setpoint_summaries": ".readSQL",
|
|
20
|
+
"get_snapshot_selected_run_detail": ".readSQL",
|
|
21
|
+
"find_new_runs": ".readSQL",
|
|
22
|
+
"get_run_status": ".readSQL",
|
|
23
|
+
"has_finished": ".readSQL",
|
|
24
|
+
"iter_run_detail_batches_via_sql": ".readSQL",
|
|
25
|
+
"iter_run_shape_batches_via_sql": ".readSQL",
|
|
26
|
+
"iter_run_storage_batches_via_sql": ".readSQL",
|
|
27
|
+
"load_param_data_from_db_prep": ".LoadFromDB",
|
|
28
|
+
"load_param_data_from_db": ".LoadFromDB",
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def __getattr__(name):
|
|
33
|
+
module_name = _EXPORT_MODULES.get(name)
|
|
34
|
+
if module_name is None:
|
|
35
|
+
raise AttributeError(
|
|
36
|
+
f"module 'qplot.datahandling' has no attribute {name!r}"
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
from importlib import import_module
|
|
40
|
+
|
|
41
|
+
value = getattr(import_module(module_name, __name__), name)
|
|
42
|
+
globals()[name] = value
|
|
43
|
+
return value
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def __dir__():
|
|
47
|
+
return sorted(set(globals()) | set(__all__))
|