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.
Files changed (119) hide show
  1. qplot/__init__.py +46 -0
  2. qplot/__main__.py +232 -0
  3. qplot/_auxiliary_paths.py +63 -0
  4. qplot/_metadata.py +12 -0
  5. qplot/_repair.py +14 -0
  6. qplot/_shutdown_supervisor.py +4049 -0
  7. qplot/_version.py +12 -0
  8. qplot/_windows_shutdown_job.py +1166 -0
  9. qplot/configuration/__init__.py +3 -0
  10. qplot/configuration/config.py +573 -0
  11. qplot/configuration/config_schema.json +319 -0
  12. qplot/configuration/scripts.py +255 -0
  13. qplot/configuration/themes/__init__.py +13 -0
  14. qplot/configuration/themes/_base.py +579 -0
  15. qplot/configuration/themes/blank.py +17 -0
  16. qplot/configuration/themes/dark.py +54 -0
  17. qplot/configuration/themes/light.py +54 -0
  18. qplot/datahandling/LoadFromDB.py +224 -0
  19. qplot/datahandling/__init__.py +47 -0
  20. qplot/datahandling/_trusted_live_helper.py +812 -0
  21. qplot/datahandling/_trusted_live_protocol.py +1745 -0
  22. qplot/datahandling/database.py +2330 -0
  23. qplot/datahandling/dimensions.py +43 -0
  24. qplot/datahandling/file_identity.py +461 -0
  25. qplot/datahandling/parameter_data.py +149 -0
  26. qplot/datahandling/plot_progress.py +17 -0
  27. qplot/datahandling/qcodes_cache.py +277 -0
  28. qplot/datahandling/qcodes_compat.py +14 -0
  29. qplot/datahandling/readSQL.py +2442 -0
  30. qplot/datahandling/readonly.py +2561 -0
  31. qplot/datahandling/source_activity.py +21 -0
  32. qplot/datahandling/trusted_array_preview.py +127 -0
  33. qplot/datahandling/trusted_derived_cache.py +1605 -0
  34. qplot/datahandling/trusted_derived_rendering.py +868 -0
  35. qplot/datahandling/trusted_heatmap.py +241 -0
  36. qplot/datahandling/trusted_live.py +2808 -0
  37. qplot/datahandling/trusted_live_queries.py +5907 -0
  38. qplot/datahandling/trusted_live_service.py +1894 -0
  39. qplot/datahandling/trusted_live_supervisor.py +2161 -0
  40. qplot/datahandling/trusted_plot.py +283 -0
  41. qplot/datahandling/trusted_presentation.py +1065 -0
  42. qplot/datahandling/trusted_snapshot.py +1132 -0
  43. qplot/datahandling/trusted_work_coordinator.py +2157 -0
  44. qplot/datahandling/trusted_work_scheduler.py +1204 -0
  45. qplot/diagnostics.py +241 -0
  46. qplot/resources/testdata/qplot_test_db_01_10mb.csv +11 -0
  47. qplot/resources/testdata/qplot_test_db_02_25mb.csv +14 -0
  48. qplot/resources/testdata/qplot_test_db_03_50mb.csv +17 -0
  49. qplot/resources/testdata/qplot_test_db_04_100mb.csv +20 -0
  50. qplot/resources/testdata/qplot_test_db_05_250mb.csv +23 -0
  51. qplot/resources/testdata/qplot_test_db_06_500mb.csv +26 -0
  52. qplot/resources/testdata/qplot_test_db_07_1gb.csv +29 -0
  53. qplot/resources/testdata/qplot_test_db_08_5gb.csv +32 -0
  54. qplot/resources/testdata/qplot_test_db_09_10gb.csv +35 -0
  55. qplot/resources/testdata/qplot_test_db_10_30gb.csv +38 -0
  56. qplot/testdata.py +1733 -0
  57. qplot/tools/__init__.py +13 -0
  58. qplot/tools/finite_means.py +114 -0
  59. qplot/tools/general.py +134 -0
  60. qplot/tools/heatmap_geometry.py +381 -0
  61. qplot/tools/operation_registry.py +179 -0
  62. qplot/tools/plot_tools.py +625 -0
  63. qplot/tools/sample_statistics.py +56 -0
  64. qplot/tools/worker.py +2787 -0
  65. qplot/windows/__init__.py +9 -0
  66. qplot/windows/_colorbar.py +422 -0
  67. qplot/windows/_commands.py +523 -0
  68. qplot/windows/_config_persistence.py +123 -0
  69. qplot/windows/_database_actions.py +4904 -0
  70. qplot/windows/_dataset_handle.py +221 -0
  71. qplot/windows/_dragdrop.py +71 -0
  72. qplot/windows/_export_paths.py +1167 -0
  73. qplot/windows/_help.py +169 -0
  74. qplot/windows/_native_averaging.py +173 -0
  75. qplot/windows/_native_transforms.py +389 -0
  76. qplot/windows/_plot1d_snap.py +608 -0
  77. qplot/windows/_plot1d_traces.py +2183 -0
  78. qplot/windows/_plot2d_colorbar.py +1126 -0
  79. qplot/windows/_plot2d_colorbar_dialog.py +786 -0
  80. qplot/windows/_plot2d_layers.py +2197 -0
  81. qplot/windows/_plot2d_sweeps.py +712 -0
  82. qplot/windows/_plotWin.py +1993 -0
  83. qplot/windows/_plot_actions.py +2695 -0
  84. qplot/windows/_plot_appearance.py +276 -0
  85. qplot/windows/_plot_axis_scaling.py +1485 -0
  86. qplot/windows/_plot_export.py +1445 -0
  87. qplot/windows/_plot_feedback.py +110 -0
  88. qplot/windows/_plot_marquee.py +656 -0
  89. qplot/windows/_plot_refresh.py +942 -0
  90. qplot/windows/_plot_state.py +239 -0
  91. qplot/windows/_plot_transform_labels.py +60 -0
  92. qplot/windows/_preferences.py +635 -0
  93. qplot/windows/_refresh_interval.py +70 -0
  94. qplot/windows/_run_controls.py +828 -0
  95. qplot/windows/_shortcuts.py +47 -0
  96. qplot/windows/_subplots/__init__.py +8 -0
  97. qplot/windows/_subplots/subplot1d.py +531 -0
  98. qplot/windows/_subplots/subplot2d.py +918 -0
  99. qplot/windows/_svg_export.py +209 -0
  100. qplot/windows/_trusted_derived_qt.py +1759 -0
  101. qplot/windows/_widgets/__init__.py +23 -0
  102. qplot/windows/_widgets/_run_formatting.py +387 -0
  103. qplot/windows/_widgets/details_tables.py +1119 -0
  104. qplot/windows/_widgets/dropbox.py +290 -0
  105. qplot/windows/_widgets/operations.py +460 -0
  106. qplot/windows/_widgets/preview.py +2997 -0
  107. qplot/windows/_widgets/run_list_items.py +488 -0
  108. qplot/windows/_widgets/toolbar.py +111 -0
  109. qplot/windows/_widgets/treeWidgets.py +2572 -0
  110. qplot/windows/_window_controls.py +413 -0
  111. qplot/windows/main.py +1635 -0
  112. qplot/windows/plot1d.py +311 -0
  113. qplot/windows/plot2d.py +1901 -0
  114. qplotter-1.6.0b3.dist-info/METADATA +318 -0
  115. qplotter-1.6.0b3.dist-info/RECORD +119 -0
  116. qplotter-1.6.0b3.dist-info/WHEEL +5 -0
  117. qplotter-1.6.0b3.dist-info/entry_points.txt +4 -0
  118. qplotter-1.6.0b3.dist-info/licenses/LICENSE +21 -0
  119. qplotter-1.6.0b3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,9 @@
1
+ from .main import MainWindow
2
+ from .plot1d import plot1d
3
+ from .plot2d import plot2d
4
+
5
+ __all__ = [
6
+ "plot1d",
7
+ "plot2d",
8
+ "MainWindow",
9
+ ]
@@ -0,0 +1,422 @@
1
+ import numpy as np
2
+ import pyqtgraph as pg
3
+ from PyQt6 import QtCore, QtGui
4
+ from PyQt6 import QtWidgets as qtw
5
+
6
+ _PREFERRED_COLORBAR_COLORMAPS = (
7
+ "viridis",
8
+ "plasma",
9
+ "inferno",
10
+ "magma",
11
+ "cividis",
12
+ "turbo",
13
+ "Greys",
14
+ "Purples",
15
+ "Blues",
16
+ "Greens",
17
+ "Oranges",
18
+ "Reds",
19
+ )
20
+
21
+
22
+ _DEFAULT_HIDDEN_COLORBAR_PREFIXES = ("gist",)
23
+ _DEFAULT_HIDDEN_COLORBAR_SUFFIXES = ("_r",)
24
+ _DEFAULT_HIDDEN_COLORBAR_NAMES = ("gray", "grey", "Grays")
25
+
26
+
27
+ _CET_COLORBAR_SUBTYPES = (
28
+ ("linear", "Linear"),
29
+ ("divergent", "Divergent"),
30
+ ("cyclic", "Cyclic"),
31
+ ("rainbow", "Rainbow"),
32
+ ("isoluminant", "Isoluminant"),
33
+ ("other", "Other"),
34
+ )
35
+
36
+
37
+ _MATPLOTLIB_COLORBAR_SUBTYPES = (
38
+ ("perceptual", "Perceptual"),
39
+ ("sequential", "Sequential"),
40
+ ("divergent", "Divergent"),
41
+ ("cyclic", "Cyclic"),
42
+ ("qualitative", "Qualitative"),
43
+ ("other", "Other"),
44
+ )
45
+
46
+
47
+ _MATPLOTLIB_PERCEPTUAL_COLORBAR_COLORMAPS = {
48
+ "cividis",
49
+ "inferno",
50
+ "magma",
51
+ "plasma",
52
+ "turbo",
53
+ "viridis",
54
+ }
55
+
56
+
57
+ _MATPLOTLIB_SEQUENTIAL_COLORBAR_COLORMAPS = {
58
+ "afmhot",
59
+ "autumn",
60
+ "binary",
61
+ "Blues",
62
+ "bone",
63
+ "BuGn",
64
+ "BuPu",
65
+ "cool",
66
+ "copper",
67
+ "GnBu",
68
+ "Greens",
69
+ "Greys",
70
+ "hot",
71
+ "Oranges",
72
+ "OrRd",
73
+ "pink",
74
+ "PuBu",
75
+ "PuBuGn",
76
+ "PuRd",
77
+ "Purples",
78
+ "RdPu",
79
+ "Reds",
80
+ "spring",
81
+ "summer",
82
+ "Wistia",
83
+ "winter",
84
+ "YlGn",
85
+ "YlGnBu",
86
+ "YlOrBr",
87
+ "YlOrRd",
88
+ }
89
+
90
+
91
+ _MATPLOTLIB_DIVERGENT_COLORBAR_COLORMAPS = {
92
+ "berlin",
93
+ "BrBG",
94
+ "bwr",
95
+ "coolwarm",
96
+ "managua",
97
+ "PiYG",
98
+ "PRGn",
99
+ "PuOr",
100
+ "RdBu",
101
+ "RdGy",
102
+ "RdYlBu",
103
+ "RdYlGn",
104
+ "seismic",
105
+ "Spectral",
106
+ "vanimo",
107
+ }
108
+
109
+
110
+ _MATPLOTLIB_CYCLIC_COLORBAR_COLORMAPS = {
111
+ "hsv",
112
+ "twilight",
113
+ "twilight_shifted",
114
+ }
115
+
116
+
117
+ _MATPLOTLIB_QUALITATIVE_COLORBAR_COLORMAPS = {
118
+ "Accent",
119
+ "Dark2",
120
+ "Paired",
121
+ "Pastel1",
122
+ "Pastel2",
123
+ "Set1",
124
+ "Set2",
125
+ "Set3",
126
+ "tab10",
127
+ "tab20",
128
+ "tab20b",
129
+ "tab20c",
130
+ }
131
+
132
+
133
+ _COLORBAR_COLORMAP_LABELS = {
134
+ "cividis": "Cividis",
135
+ "inferno": "Inferno",
136
+ "magma": "Magma",
137
+ "plasma": "Plasma",
138
+ "turbo": "Turbo",
139
+ "viridis": "Viridis",
140
+ }
141
+
142
+
143
+ _COLORBAR_TABLE_SORT_ROLE = QtCore.Qt.ItemDataRole.UserRole + 1
144
+
145
+
146
+ class _ColorbarColormapTableItem(qtw.QTableWidgetItem):
147
+ """
148
+ Table item that sorts by an explicit, case-insensitive key.
149
+
150
+ """
151
+
152
+ def __lt__(self, other):
153
+ left = self.data(_COLORBAR_TABLE_SORT_ROLE)
154
+ right = other.data(_COLORBAR_TABLE_SORT_ROLE)
155
+ if left is not None and right is not None:
156
+ return str(left).casefold() < str(right).casefold()
157
+ return super().__lt__(other)
158
+
159
+
160
+ _CUSTOM_COLORBAR_COLORMAPS = {
161
+ "Greys": [
162
+ (255, 255, 255),
163
+ (217, 217, 217),
164
+ (150, 150, 150),
165
+ (82, 82, 82),
166
+ (0, 0, 0),
167
+ ],
168
+ "Purples": [
169
+ (252, 251, 253),
170
+ (218, 218, 235),
171
+ (158, 154, 200),
172
+ (106, 81, 163),
173
+ (63, 0, 125),
174
+ ],
175
+ "Blues": [
176
+ (247, 251, 255),
177
+ (198, 219, 239),
178
+ (107, 174, 214),
179
+ (33, 113, 181),
180
+ (8, 48, 107),
181
+ ],
182
+ "Greens": [
183
+ (247, 252, 245),
184
+ (199, 233, 192),
185
+ (116, 196, 118),
186
+ (35, 139, 69),
187
+ (0, 68, 27),
188
+ ],
189
+ "Oranges": [
190
+ (255, 245, 235),
191
+ (253, 208, 162),
192
+ (253, 141, 60),
193
+ (217, 72, 1),
194
+ (127, 39, 4),
195
+ ],
196
+ "Reds": [
197
+ (255, 245, 240),
198
+ (252, 187, 161),
199
+ (251, 106, 74),
200
+ (203, 24, 29),
201
+ (103, 0, 13),
202
+ ],
203
+ }
204
+
205
+
206
+ def _list_pyqtgraph_colormaps(source=None):
207
+ """
208
+ Return color maps advertised by pyqtgraph for an optional source.
209
+
210
+ """
211
+ try:
212
+ return list(pg.colormap.listMaps(source=source))
213
+ except Exception:
214
+ return []
215
+
216
+
217
+ def _config_value(config_obj, key, default):
218
+ """
219
+ Read a config value, or use a default for a standalone widget.
220
+
221
+ """
222
+ if config_obj is None:
223
+ return default
224
+ return config_obj.get(key)
225
+
226
+
227
+ def _colorbar_subtype_config_key(group, subtype):
228
+ return f"user_preference.bar_colour_include_{group}_{subtype}"
229
+
230
+
231
+ def _build_colorbar_colormap_catalog():
232
+ """
233
+ Build the colorbar map list and remember which pyqtgraph source owns each.
234
+
235
+ """
236
+ colormaps = []
237
+ sources = {}
238
+ default_maps = _list_pyqtgraph_colormaps()
239
+ matplotlib_maps = _list_pyqtgraph_colormaps(source="matplotlib")
240
+
241
+ def add_colormap(name, source=None):
242
+ if name in sources:
243
+ return
244
+ colormaps.append(name)
245
+ sources[name] = source
246
+
247
+ for name in _PREFERRED_COLORBAR_COLORMAPS:
248
+ if name in _CUSTOM_COLORBAR_COLORMAPS:
249
+ add_colormap(name, "custom")
250
+ elif name in matplotlib_maps:
251
+ add_colormap(name, "matplotlib")
252
+ elif name in default_maps:
253
+ add_colormap(name)
254
+
255
+ for source, maps in ((None, default_maps), ("matplotlib", matplotlib_maps)):
256
+ for name in maps:
257
+ add_colormap(name, source)
258
+
259
+ for name in _CUSTOM_COLORBAR_COLORMAPS:
260
+ add_colormap(name, "custom")
261
+
262
+ return tuple(colormaps), sources
263
+
264
+
265
+ _COLORBAR_COLORMAPS, _COLORBAR_COLORMAP_SOURCES = _build_colorbar_colormap_catalog()
266
+
267
+
268
+ def _colorbar_colormap_group(name):
269
+ """
270
+ Return the broad group used for color-map filtering.
271
+
272
+ """
273
+ source = _COLORBAR_COLORMAP_SOURCES.get(name)
274
+ if source == "custom":
275
+ return "custom"
276
+ if name.startswith("CET-"):
277
+ return "cet"
278
+ if source == "matplotlib":
279
+ return "matplotlib"
280
+ return "pyqtgraph"
281
+
282
+
283
+ def _cet_colorbar_colormap_subtype(name):
284
+ """
285
+ Return the CET subtype used by the color-map filters.
286
+
287
+ """
288
+ if name.startswith(("CET-CBL", "CET-CBTL", "CET-L")):
289
+ return "linear"
290
+ if name.startswith(("CET-CBD", "CET-CBTD", "CET-D")):
291
+ return "divergent"
292
+ if name.startswith("CET-C"):
293
+ return "cyclic"
294
+ if name.startswith("CET-R"):
295
+ return "rainbow"
296
+ if name.startswith("CET-I"):
297
+ return "isoluminant"
298
+ return "other"
299
+
300
+
301
+ def _matplotlib_colorbar_colormap_subtype(name):
302
+ """
303
+ Return the matplotlib subtype used by the color-map filters.
304
+
305
+ """
306
+ if name in _MATPLOTLIB_PERCEPTUAL_COLORBAR_COLORMAPS:
307
+ return "perceptual"
308
+ if name in _MATPLOTLIB_SEQUENTIAL_COLORBAR_COLORMAPS:
309
+ return "sequential"
310
+ if name in _MATPLOTLIB_DIVERGENT_COLORBAR_COLORMAPS:
311
+ return "divergent"
312
+ if name in _MATPLOTLIB_CYCLIC_COLORBAR_COLORMAPS:
313
+ return "cyclic"
314
+ if name in _MATPLOTLIB_QUALITATIVE_COLORBAR_COLORMAPS:
315
+ return "qualitative"
316
+ return "other"
317
+
318
+
319
+ def _colorbar_colormap_type_label(name):
320
+ """
321
+ Return the source/type label shown in the color scale chooser.
322
+
323
+ """
324
+ group = _colorbar_colormap_group(name)
325
+ if group == "cet":
326
+ subtype = _cet_colorbar_colormap_subtype(name)
327
+ labels = dict(_CET_COLORBAR_SUBTYPES)
328
+ return f"CET - {labels.get(subtype, subtype.title())}"
329
+ if group == "matplotlib":
330
+ subtype = _matplotlib_colorbar_colormap_subtype(name)
331
+ labels = dict(_MATPLOTLIB_COLORBAR_SUBTYPES)
332
+ return f"Matplotlib - {labels.get(subtype, subtype.title())}"
333
+ if group == "custom":
334
+ return "QCoDeS Plotter - Custom"
335
+ return "PyQtGraph - Local"
336
+
337
+
338
+ def _colorbar_colormap_for_name(name):
339
+ """
340
+ Return a color map object, custom map, or special pyqtgraph map name.
341
+
342
+ """
343
+ source = _COLORBAR_COLORMAP_SOURCES.get(name)
344
+ if source == "custom":
345
+ colors = _CUSTOM_COLORBAR_COLORMAPS.get(name)
346
+ if colors is not None:
347
+ color_map = pg.ColorMap(
348
+ np.linspace(0.0, 1.0, len(colors)),
349
+ colors,
350
+ )
351
+ color_map.name = name
352
+ return color_map
353
+
354
+ try:
355
+ return pg.colormap.get(name, source=source)
356
+ except Exception:
357
+ pass
358
+
359
+ colors = _CUSTOM_COLORBAR_COLORMAPS.get(name)
360
+ if colors is None:
361
+ return name
362
+
363
+ color_map = pg.ColorMap(
364
+ np.linspace(0.0, 1.0, len(colors)),
365
+ colors,
366
+ )
367
+ color_map.name = name
368
+ return color_map
369
+
370
+
371
+ def _colorbar_colormap_preview(name, width=220, height=14):
372
+ """
373
+ Render a compact pixmap preview for a colorbar color map.
374
+
375
+ """
376
+ pixmap = QtGui.QPixmap(width, height)
377
+ pixmap.fill(QtGui.QColor("transparent"))
378
+
379
+ painter = QtGui.QPainter(pixmap)
380
+ try:
381
+ color_map = _colorbar_colormap_for_name(name)
382
+ if isinstance(color_map, pg.ColorMap):
383
+ lookup_table = color_map.getLookupTable(nPts=width, alpha=True)
384
+ for x, color in enumerate(lookup_table):
385
+ painter.setPen(QtGui.QColor(*[int(channel) for channel in color[:4]]))
386
+ painter.drawLine(x, 0, x, height - 1)
387
+ else:
388
+ painter.fillRect(0, 0, width, height, QtGui.QColor(255, 255, 255))
389
+
390
+ painter.setPen(QtGui.QColor(120, 120, 120))
391
+ painter.drawRect(0, 0, width - 1, height - 1)
392
+ finally:
393
+ painter.end()
394
+
395
+ return pixmap
396
+
397
+
398
+ def _letter_button_pixmap(letter, size=20):
399
+ """
400
+ Render a pyqtgraph-style circular letter button.
401
+
402
+ """
403
+ pixmap = QtGui.QPixmap(size, size)
404
+ pixmap.fill(QtCore.Qt.GlobalColor.transparent)
405
+
406
+ painter = QtGui.QPainter(pixmap)
407
+ try:
408
+ painter.setRenderHint(QtGui.QPainter.RenderHint.Antialiasing)
409
+ painter.setPen(QtGui.QPen(QtGui.QColor(70, 70, 70, 230), 1.2))
410
+ painter.setBrush(QtGui.QColor(235, 235, 235, 225))
411
+ painter.drawEllipse(QtCore.QRectF(1, 1, size - 2, size - 2))
412
+
413
+ font = QtGui.QFont()
414
+ font.setBold(True)
415
+ font.setPointSize(11)
416
+ painter.setFont(font)
417
+ painter.setPen(QtGui.QColor(40, 40, 40))
418
+ painter.drawText(pixmap.rect(), QtCore.Qt.AlignmentFlag.AlignCenter, letter)
419
+ finally:
420
+ painter.end()
421
+
422
+ return pixmap