logqbit 0.7__tar.gz → 0.7.2__tar.gz

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 (64) hide show
  1. {logqbit-0.7 → logqbit-0.7.2}/.gitignore +1 -0
  2. {logqbit-0.7 → logqbit-0.7.2}/PKG-INFO +4 -5
  3. {logqbit-0.7 → logqbit-0.7.2}/README.md +2 -3
  4. {logqbit-0.7 → logqbit-0.7.2}/pyproject.toml +11 -11
  5. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/cli/shortcuts.py +2 -1
  6. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/detail/view.py +2 -1
  7. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/plot/manager.py +49 -4
  8. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/startup.py +33 -6
  9. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_cli.py +2 -1
  10. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_detail.py +23 -70
  11. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_plot.py +82 -78
  12. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_startup.py +23 -1
  13. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_window.py +3 -129
  14. {logqbit-0.7 → logqbit-0.7.2}/LICENSE +0 -0
  15. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/__init__.py +0 -0
  16. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/assets/browser.svg +0 -0
  17. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/assets/live_plotter.svg +0 -0
  18. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/catalog.py +0 -0
  19. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/cli/__init__.py +0 -0
  20. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/cli/__main__.py +0 -0
  21. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/cli/demo.py +0 -0
  22. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/cli/main.py +0 -0
  23. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/cli/svg2ico.py +0 -0
  24. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/dataframe.py +0 -0
  25. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/file_version.py +0 -0
  26. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/__init__.py +0 -0
  27. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/__init__.py +0 -0
  28. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/__main__.py +0 -0
  29. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/about.py +0 -0
  30. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/detail/__init__.py +0 -0
  31. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/detail/data.py +0 -0
  32. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/detail/files.py +0 -0
  33. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/detail/yaml.py +0 -0
  34. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/plot/__init__.py +0 -0
  35. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/plot/cursor.py +0 -0
  36. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/plot/fitting.py +0 -0
  37. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/plot/grouping.py +0 -0
  38. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/plot/mesh.py +0 -0
  39. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/window/__init__.py +0 -0
  40. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/window/merge.py +0 -0
  41. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/window/model.py +0 -0
  42. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/window/preferences.py +0 -0
  43. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/browser/window/view.py +0 -0
  44. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/gui/live_plotter.py +0 -0
  45. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/logfolder.py +0 -0
  46. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/metadata.py +0 -0
  47. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/registry.py +0 -0
  48. {logqbit-0.7 → logqbit-0.7.2}/src/logqbit/templates/move_from_labrad.py +0 -0
  49. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_browser_launcher.py +0 -0
  50. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_dataframe.py +0 -0
  51. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_log_catalog.py +0 -0
  52. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_logfolder.py +0 -0
  53. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_metadata.py +0 -0
  54. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_public_api.py +0 -0
  55. {logqbit-0.7 → logqbit-0.7.2}/tests/core/test_registry.py +0 -0
  56. {logqbit-0.7 → logqbit-0.7.2}/tests/for_all_pythons.ps1 +0 -0
  57. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/conftest.py +0 -0
  58. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_catalog.py +0 -0
  59. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_data.py +0 -0
  60. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_list.py +0 -0
  61. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_preferences.py +0 -0
  62. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/browser/test_yaml.py +0 -0
  63. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/conftest.py +0 -0
  64. {logqbit-0.7 → logqbit-0.7.2}/tests/gui/test_live_plotter.py +0 -0
@@ -2,6 +2,7 @@
2
2
  AGENTS.md
3
3
  /logqbit_example/
4
4
  /src/logqbit/assets/*.ico
5
+ *.lnk
5
6
 
6
7
  # Python bytecode and native extensions
7
8
  __pycache__/
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: logqbit
3
- Version: 0.7
4
- Summary: Simple data logger and live plotter for lab-scale experiments.
3
+ Version: 0.7.2
4
+ Summary: A lightweight, directory-based toolkit for logging and organizing lab experiment data.
5
5
  Project-URL: Homepage, https://github.com/Qiujv/logqbit
6
6
  Author-email: Qiujv <qiujv@outlook.com>
7
7
  License-File: LICENSE
@@ -88,7 +88,6 @@ logqbit browser-demo
88
88
  更多内容:
89
89
 
90
90
  - 文档首页:https://qiujv.github.io/logqbit/
91
- - LogBrowser:https://qiujv.github.io/logqbit/browser/
91
+ - LogFolder:https://qiujv.github.io/logqbit/core/
92
+ - 数据浏览器:https://qiujv.github.io/logqbit/browser/
92
93
  - 命令行工具:https://qiujv.github.io/logqbit/cli/
93
- - LabRAD 迁移:https://qiujv.github.io/logqbit/migration_guide/
94
- - Python API:https://qiujv.github.io/logqbit/api/
@@ -65,7 +65,6 @@ logqbit browser-demo
65
65
  更多内容:
66
66
 
67
67
  - 文档首页:https://qiujv.github.io/logqbit/
68
- - LogBrowser:https://qiujv.github.io/logqbit/browser/
68
+ - LogFolder:https://qiujv.github.io/logqbit/core/
69
+ - 数据浏览器:https://qiujv.github.io/logqbit/browser/
69
70
  - 命令行工具:https://qiujv.github.io/logqbit/cli/
70
- - LabRAD 迁移:https://qiujv.github.io/logqbit/migration_guide/
71
- - Python API:https://qiujv.github.io/logqbit/api/
@@ -1,7 +1,7 @@
1
1
  [project]
2
2
  name = "logqbit"
3
3
  dynamic = ["version"]
4
- description = "Simple data logger and live plotter for lab-scale experiments."
4
+ description = "A lightweight, directory-based toolkit for logging and organizing lab experiment data."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
7
7
  authors = [{ name = "Qiujv", email = "qiujv@outlook.com" }]
@@ -14,6 +14,16 @@ dependencies = [
14
14
  "typing-extensions>=4.15.0",
15
15
  ]
16
16
 
17
+ [project.optional-dependencies]
18
+ gui = [
19
+ "numba>=0.65.0",
20
+ "pygments>=2.19.2",
21
+ "pyqtgraph>=0.14.0",
22
+ "pyside6>=6.9.3",
23
+ "scipy>=1.16.0",
24
+ "send2trash>=1.8.3",
25
+ ]
26
+
17
27
  [dependency-groups]
18
28
  dev = [
19
29
  "ipykernel>=6.30.1",
@@ -26,16 +36,6 @@ dev = [
26
36
  "ruff>=0.15.12",
27
37
  ]
28
38
 
29
- [project.optional-dependencies]
30
- gui = [
31
- "numba>=0.65.0",
32
- "pygments>=2.19.2",
33
- "pyqtgraph>=0.14.0",
34
- "pyside6>=6.9.3",
35
- "scipy>=1.16.0",
36
- "send2trash>=1.8.3",
37
- ]
38
-
39
39
  [project.urls]
40
40
  Homepage = "https://github.com/Qiujv/logqbit"
41
41
 
@@ -77,7 +77,8 @@ def create_shortcuts(output_dir: Path | None = None) -> int:
77
77
  $WshShell = New-Object -ComObject WScript.Shell
78
78
  $Shortcut = $WshShell.CreateShortcut({_powershell_single_quoted(shortcut_path)})
79
79
  $Shortcut.TargetPath = {_powershell_single_quoted(browser_entrypoint)}
80
- $Shortcut.IconLocation = {_powershell_single_quoted(browser_ico)}
80
+ $Shortcut.Arguments = '--foreground'
81
+ $Shortcut.IconLocation = {_powershell_single_quoted(f"{browser_ico},0")}
81
82
  $Shortcut.Save()
82
83
  """
83
84
  result = subprocess.run(
@@ -304,7 +304,8 @@ class RecordDetailView(QWidget):
304
304
  self._clear_detail_watcher()
305
305
 
306
306
  def _schedule_detail_refresh(self) -> None:
307
- self._refresh_timer.start()
307
+ if not self._refresh_timer.isActive():
308
+ self._refresh_timer.start()
308
309
 
309
310
  def _create_detail_watcher(self) -> QFileSystemWatcher:
310
311
  watcher = QFileSystemWatcher(self)
@@ -41,7 +41,7 @@ from logqbit.gui.browser.plot.grouping import iter_plot_groups
41
41
  from logqbit.gui.browser.plot.mesh import build_plot_mesh
42
42
 
43
43
  PLOT_EXPORT_SCALE = 2
44
- PLOT_AUTO_RANGE_PADDING = 0.02
44
+ PLOT_AUTO_RANGE_PADDING = 0.01
45
45
  COLOR_BAR_HEIGHT_FACTOR = 0.9
46
46
  PLOT_COLORS = (
47
47
  "#1E90FF",
@@ -78,12 +78,13 @@ class TagBar(QWidget):
78
78
  self._list.setDefaultDropAction(Qt.MoveAction)
79
79
  self._list.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
80
80
  self._list.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
81
+ self._list.setToolTip("Click to toggle field. Drag to reorder.")
81
82
  row_height = self._list.fontMetrics().height() + 4
82
83
  self._list.setFixedHeight(row_height + self._list.frameWidth() * 2)
83
84
  self._list.installEventFilter(self)
84
85
  self._list.setContextMenuPolicy(Qt.CustomContextMenu)
85
86
  self._list.customContextMenuRequested.connect(self._show_context_menu)
86
- self._list.itemClicked.connect(lambda _: self._list.clearSelection())
87
+ self._list.itemClicked.connect(self._toggle_item_role)
87
88
 
88
89
  model = self._list.model()
89
90
  model.rowsInserted.connect(lambda *_: self._on_model_changed())
@@ -132,6 +133,39 @@ class TagBar(QWidget):
132
133
  menu.addAction("Save", self.save_clicked.emit)
133
134
  menu.exec(self._list.mapToGlobal(pos))
134
135
 
136
+ def _toggle_item_role(self, item: QListWidgetItem) -> None:
137
+ item_index = self._list.row(item)
138
+ separators = [
139
+ index
140
+ for index in range(self._list.count())
141
+ if self._list.item(index).text() == self._SEP
142
+ ]
143
+ if item.text() == self._SEP or len(separators) < 2:
144
+ self._list.clearSelection()
145
+ return
146
+ if item_index < separators[0]:
147
+ self._list.clearSelection()
148
+ return
149
+
150
+ was_field = separators[0] < item_index < separators[1]
151
+ self._loading = True
152
+ try:
153
+ item = self._list.takeItem(item_index)
154
+ separator_indices = [
155
+ index
156
+ for index in range(self._list.count())
157
+ if self._list.item(index).text() == self._SEP
158
+ ]
159
+ second_separator = separator_indices[1]
160
+ self._list.insertItem(
161
+ second_separator + 1 if was_field else second_separator,
162
+ item,
163
+ )
164
+ finally:
165
+ self._loading = False
166
+ self._list.clearSelection()
167
+ self._on_model_changed()
168
+
135
169
  def eventFilter(self, obj, event):
136
170
  if obj is self._list and event.type() == QEvent.Wheel:
137
171
  bar = self._list.horizontalScrollBar()
@@ -455,20 +489,31 @@ class PlotManager:
455
489
  previous_title = title_label.text
456
490
  previous_options = dict(title_label.opts)
457
491
  title_was_visible = title_label.isVisible()
492
+ previous_text_width = title_label.item.textWidth()
458
493
  record = self._plot_record
459
494
  if record is not None:
495
+ available_width = max(1.0, plot_item.vb.width())
496
+ title_label.item.setTextWidth(available_width)
497
+ title = html.escape(record.title)
498
+ path = html.escape(str(record.path)).replace("/", "/<wbr>")
460
499
  plot_item.setTitle(
461
- html.escape(str(record.path)),
500
+ f"{title} — {path}",
462
501
  color="k",
463
- size="9pt",
464
502
  )
503
+ title_height = title_label.item.boundingRect().height()
504
+ title_label.setMaximumHeight(title_height)
505
+ plot_item.layout.setRowFixedHeight(0, title_height)
465
506
  plot_item.layout.activate()
466
507
  try:
467
508
  yield plot_item
468
509
  finally:
469
510
  if title_was_visible:
470
511
  plot_item.setTitle(previous_title, **previous_options)
512
+ title_label.item.setTextWidth(previous_text_width)
513
+ title_label.updateMin()
471
514
  else:
515
+ title_label.item.setTextWidth(previous_text_width)
516
+ title_label.setText("")
472
517
  plot_item.setTitle(None)
473
518
  plot_item.layout.activate()
474
519
 
@@ -13,10 +13,12 @@ from pathlib import Path, PureWindowsPath
13
13
  from typing import TYPE_CHECKING
14
14
 
15
15
  if TYPE_CHECKING:
16
+ from PySide6.QtGui import QIcon
16
17
  from PySide6.QtWidgets import QApplication, QSplashScreen
17
18
 
18
19
  _FOREGROUND_OPTION = "--foreground"
19
20
  _STARTUP_MODULE = "logqbit.gui.browser.startup"
21
+ _WINDOWS_APP_USER_MODEL_ID = "Qiujv.LogQbit.Browser"
20
22
 
21
23
 
22
24
  def launch_browser(directory: str | Path | None = None) -> None:
@@ -96,6 +98,30 @@ def _windows_gui_launch(executable: str) -> tuple[str, dict[str, str]]:
96
98
  return gui_executable, environment
97
99
 
98
100
 
101
+ def _set_windows_app_user_model_id() -> None:
102
+ """Give the browser a stable Windows taskbar identity."""
103
+ if platform.system() != "Windows":
104
+ return
105
+
106
+ import ctypes
107
+
108
+ ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID( # type: ignore[attr-defined]
109
+ _WINDOWS_APP_USER_MODEL_ID
110
+ )
111
+
112
+
113
+ def _browser_window_icon() -> QIcon:
114
+ """Load the native Windows icon, falling back to the source SVG."""
115
+ from PySide6.QtGui import QIcon
116
+
117
+ assets = files("logqbit") / "assets"
118
+ for filename in ("browser.ico", "browser.svg"):
119
+ icon = QIcon(str(assets / filename))
120
+ if not icon.isNull():
121
+ return icon
122
+ return QIcon()
123
+
124
+
99
125
  def _show_startup_splash(app: QApplication) -> QSplashScreen:
100
126
  from PySide6.QtCore import Qt
101
127
  from PySide6.QtGui import QColor, QPixmap
@@ -134,24 +160,25 @@ def _show_startup_error(error: Exception) -> None:
134
160
 
135
161
  def run_browser_application(argv: Sequence[str]) -> int:
136
162
  """Show a lightweight splash before importing the full browser window."""
137
- from PySide6.QtGui import QIcon
138
163
  from PySide6.QtWidgets import QApplication
139
164
 
165
+ _set_windows_app_user_model_id()
140
166
  app = QApplication.instance()
141
167
  if app is None:
142
168
  app = QApplication(sys.argv)
169
+ app.setApplicationName("LogQbit Log Browser")
170
+ icon = _browser_window_icon()
171
+ if not icon.isNull():
172
+ app.setWindowIcon(icon)
143
173
  splash = _show_startup_splash(app)
144
174
 
145
175
  try:
146
176
  from logqbit.gui.browser.window.view import LogBrowserWindow
147
177
 
148
- app.setApplicationName("LogQbit Log Browser")
149
- icon = QIcon(str(files("logqbit") / "assets" / "browser.svg"))
150
- if not icon.isNull():
151
- app.setWindowIcon(icon)
152
-
153
178
  directory = Path(argv[0]).expanduser().resolve() if argv else None
154
179
  window = LogBrowserWindow(directory)
180
+ if not icon.isNull():
181
+ window.setWindowIcon(icon)
155
182
  window.show()
156
183
  splash.finish(window)
157
184
  return app.exec()
@@ -117,5 +117,6 @@ def test_shortcuts_create_only_browser_shortcut(
117
117
  assert len(commands) == 1
118
118
  powershell_script = commands[0][2]
119
119
  assert str(gui_entrypoint) in powershell_script
120
- assert "$Shortcut.Arguments" not in powershell_script
120
+ assert "$Shortcut.Arguments = '--foreground'" in powershell_script
121
+ assert f"{icon_path},0" in powershell_script
121
122
  assert "live_plotter" not in powershell_script
@@ -41,6 +41,29 @@ def scan_catalog(directory: Path) -> list[LogRecord]:
41
41
 
42
42
 
43
43
  class TestRecordDetailWidgets:
44
+ def test_continuous_file_events_do_not_postpone_refresh_forever(self) -> None:
45
+ view = RecordDetailView()
46
+ starts: list[bool] = []
47
+
48
+ class FakeTimer:
49
+ active = True
50
+
51
+ def isActive(self) -> bool:
52
+ return self.active
53
+
54
+ def start(self) -> None:
55
+ starts.append(True)
56
+
57
+ timer = FakeTimer()
58
+ view._refresh_timer = timer # type: ignore[assignment]
59
+
60
+ view._schedule_detail_refresh()
61
+ assert starts == []
62
+
63
+ timer.active = False
64
+ view._schedule_detail_refresh()
65
+ assert starts == [True]
66
+
44
67
  def test_image_tab_copies_image_file(self, sample_logfolder: Path) -> None:
45
68
  app = _create_application()
46
69
  record = scan_catalog(sample_logfolder)[0]
@@ -279,52 +302,6 @@ class TestRecordDetailWidgets:
279
302
  assert plot_item.getViewBox().viewRange()[0] == pytest.approx(expected_range)
280
303
  assert view.plot_manager.exponential_fit_button.isChecked()
281
304
 
282
- def test_sync_detail_watcher_keeps_unchanged_paths(
283
- self,
284
- sample_logfolder: Path,
285
- monkeypatch: pytest.MonkeyPatch,
286
- ) -> None:
287
- record = scan_catalog(sample_logfolder)[0]
288
- view = RecordDetailView()
289
- view.load_record(record)
290
- clear_calls = 0
291
-
292
- def count_clear() -> None:
293
- nonlocal clear_calls
294
- clear_calls += 1
295
-
296
- monkeypatch.setattr(view, "_clear_detail_watcher", count_clear)
297
-
298
- view._sync_detail_watcher()
299
-
300
- assert clear_calls == 0
301
-
302
- def test_data_refresh_does_not_rebuild_tag_bar(
303
- self, sample_logfolder: Path, monkeypatch: pytest.MonkeyPatch
304
- ) -> None:
305
- record = scan_catalog(sample_logfolder)[0]
306
- view = RecordDetailView()
307
- view.load_record(record)
308
- view.set_current_tab(TAB_PLOT)
309
- set_columns_calls: list[tuple] = []
310
- monkeypatch.setattr(
311
- view.plot_manager.tag_bar,
312
- "set_columns",
313
- lambda *args: set_columns_calls.append(args),
314
- )
315
-
316
- pd.DataFrame({"x": range(5), "y": range(5), "z": range(5)}).to_feather(
317
- record.data_path
318
- )
319
- view.refresh_current_record()
320
-
321
- assert set_columns_calls == []
322
-
323
- record.meta.update(plot_axes=["y"], plot_fields=["z"])
324
- view.refresh_current_record()
325
-
326
- assert len(set_columns_calls) == 1
327
-
328
305
  def test_data_table_unique_values_use_full_column(self) -> None:
329
306
  manager = DataViewManager()
330
307
  frame = pd.DataFrame({"value": [1, 2, 1, None, 2]})
@@ -485,30 +462,6 @@ class TestRecordDetailWidgets:
485
462
  first_view.close()
486
463
  second_view.close()
487
464
 
488
- def test_detail_views_own_independent_dataframe_caches(
489
- self, sample_logfolder: Path
490
- ) -> None:
491
- record = scan_catalog(sample_logfolder)[0]
492
- first_view = RecordDetailView()
493
- second_view = RecordDetailView()
494
- try:
495
- first_view.load_record(record)
496
- second_view.load_record(record)
497
-
498
- first_frame = first_view._data_cache.dataframe
499
- second_frame = second_view._data_cache.dataframe
500
- assert first_frame is not None
501
- assert second_frame is not None
502
- assert first_frame is not second_frame
503
-
504
- first_view.refresh_current_record(force=True)
505
-
506
- assert first_view._data_cache.dataframe is not first_frame
507
- assert second_view._data_cache.dataframe is second_frame
508
- finally:
509
- first_view.close()
510
- second_view.close()
511
-
512
465
  def test_detail_window_has_file_watcher_and_tab_shortcuts(
513
466
  self, sample_logfolder: Path
514
467
  ) -> None:
@@ -9,8 +9,7 @@ import numpy as np
9
9
  import pandas as pd
10
10
  import pytest
11
11
  from PySide6.QtCore import QRectF, Qt
12
- from PySide6.QtGui import QKeySequence
13
- from PySide6.QtWidgets import QSizePolicy, QToolButton
12
+ from PySide6.QtWidgets import QSizePolicy
14
13
 
15
14
  from logqbit.catalog import PlotColumns, resolve_plot_columns
16
15
  from logqbit.gui.browser.plot.fitting import fit_exponential, fit_quadratic
@@ -22,7 +21,6 @@ from logqbit.gui.browser.plot.mesh import (
22
21
  warmup_plotter_jit,
23
22
  )
24
23
  from logqbit.gui.browser.plot.manager import (
25
- COLOR_BAR_HEIGHT_FACTOR,
26
24
  PLOT_AUTO_RANGE_PADDING,
27
25
  PlotManager,
28
26
  TagBar,
@@ -120,6 +118,78 @@ class TestTagBar:
120
118
  assert tag_bar.groupby == []
121
119
  assert tag_bar.groupby_button.text() == "group by"
122
120
 
121
+ def test_clicking_field_moves_it_to_start_of_ignored_columns(self) -> None:
122
+ tag_bar = TagBar()
123
+ tag_bar.set_columns(
124
+ ["x", "signal", "reference", "note"],
125
+ ["x"],
126
+ ["signal", "reference"],
127
+ [],
128
+ )
129
+ changes: list[None] = []
130
+ tag_bar.changed.connect(lambda: changes.append(None))
131
+
132
+ tag_bar._toggle_item_role(tag_bar._list.item(2))
133
+
134
+ assert tag_bar.axes == ["x"]
135
+ assert tag_bar.fields == ["reference"]
136
+ assert tag_bar._split()[2] == ["signal", "note"]
137
+ assert changes == [None]
138
+
139
+ def test_clicking_axis_does_not_change_roles(self) -> None:
140
+ tag_bar = TagBar()
141
+ tag_bar.set_columns(["x", "signal"], ["x"], ["signal"], [])
142
+ changes: list[None] = []
143
+ tag_bar.changed.connect(lambda: changes.append(None))
144
+
145
+ tag_bar._toggle_item_role(tag_bar._list.item(0))
146
+
147
+ assert tag_bar.axes == ["x"]
148
+ assert tag_bar.fields == ["signal"]
149
+ assert changes == []
150
+
151
+ def test_clicking_non_field_moves_it_to_end_of_fields(self) -> None:
152
+ tag_bar = TagBar()
153
+ tag_bar.set_columns(
154
+ ["x", "signal", "reference"],
155
+ ["x"],
156
+ ["signal"],
157
+ [],
158
+ )
159
+
160
+ tag_bar._toggle_item_role(tag_bar._list.item(4))
161
+
162
+ assert tag_bar.axes == ["x"]
163
+ assert tag_bar.fields == ["signal", "reference"]
164
+ assert tag_bar._split()[2] == []
165
+
166
+ def test_clicking_groupby_column_moves_it_to_fields(self) -> None:
167
+ tag_bar = TagBar()
168
+ tag_bar.set_columns(
169
+ ["x", "signal", "device"],
170
+ ["x"],
171
+ ["signal"],
172
+ ["device"],
173
+ )
174
+
175
+ tag_bar._toggle_item_role(tag_bar._list.item(4))
176
+
177
+ assert tag_bar.axes == ["x"]
178
+ assert tag_bar.fields == ["signal", "device"]
179
+ assert tag_bar.groupby == []
180
+
181
+ def test_clicking_separator_does_not_change_roles(self) -> None:
182
+ tag_bar = TagBar()
183
+ tag_bar.set_columns(["x", "signal"], ["x"], ["signal"], [])
184
+ changes: list[None] = []
185
+ tag_bar.changed.connect(lambda: changes.append(None))
186
+
187
+ tag_bar._toggle_item_role(tag_bar._list.item(1))
188
+
189
+ assert tag_bar.axes == ["x"]
190
+ assert tag_bar.fields == ["signal"]
191
+ assert changes == []
192
+
123
193
 
124
194
  def test_resolve_plot_columns_fills_axes_before_fields() -> None:
125
195
  resolved = resolve_plot_columns(
@@ -321,39 +391,6 @@ class TestPlotManagerFitAndColorBar:
321
391
  assert manager.fit_controller._field == "a"
322
392
  manager.widget.deleteLater()
323
393
 
324
- def test_plot_actions_use_compact_tool_buttons(self) -> None:
325
- manager = PlotManager()
326
-
327
- for button in (
328
- manager.exponential_fit_button,
329
- manager.quadratic_fit_button,
330
- manager.cursor_button,
331
- manager.copy_plot_button,
332
- ):
333
- assert isinstance(button, QToolButton)
334
-
335
- manager.widget.deleteLater()
336
-
337
- def test_points_context_menu_is_hidden(self) -> None:
338
- manager = PlotManager()
339
- plot_item = manager.plot_widget.getPlotItem()
340
-
341
- points_action = next(
342
- action
343
- for action in plot_item.ctrlMenu.actions()
344
- if action.text() == "Points"
345
- )
346
-
347
- assert not points_action.isVisible()
348
- manager.widget.deleteLater()
349
-
350
- def test_view_context_menu_has_save_plot_action(self) -> None:
351
- manager = PlotManager()
352
-
353
- assert manager.save_plot_action.text() == "Save plot"
354
- assert manager.save_plot_action in manager.fit_view_box.getMenu(None).actions()
355
- manager.widget.deleteLater()
356
-
357
394
  def test_view_context_menu_mirrors_log_mode_controls(self) -> None:
358
395
  manager = PlotManager()
359
396
  plot_item = manager.plot_widget.getPlotItem()
@@ -372,14 +409,6 @@ class TestPlotManagerFitAndColorBar:
372
409
  assert not manager.log_y_action.isChecked()
373
410
  manager.widget.deleteLater()
374
411
 
375
- def test_copy_shortcut_is_scoped_to_plot_widget(self) -> None:
376
- manager = PlotManager()
377
-
378
- assert manager.copy_plot_shortcut.key() == QKeySequence.Copy
379
- assert manager.copy_plot_shortcut.context() == Qt.WidgetWithChildrenShortcut
380
- assert manager.copy_plot_shortcut.parent() is manager.plot_widget
381
- manager.widget.deleteLater()
382
-
383
412
  def test_double_click_zooms_to_fit_all_data(
384
413
  self, monkeypatch: pytest.MonkeyPatch
385
414
  ) -> None:
@@ -420,7 +449,9 @@ class TestPlotManagerFitAndColorBar:
420
449
  ) -> None:
421
450
  manager = PlotManager()
422
451
  record_path = Path("/logs/example-record")
423
- manager._plot_record = SimpleNamespace(path=record_path)
452
+ manager._plot_record = SimpleNamespace(path=record_path, title="Example title")
453
+ plot_item = manager.plot_widget.getPlotItem()
454
+ initial_minimum_width = plot_item.layout.minimumWidth()
424
455
  observed: dict[str, object] = {}
425
456
 
426
457
  class FakeExporter:
@@ -445,11 +476,13 @@ class TestPlotManagerFitAndColorBar:
445
476
 
446
477
  assert observed == {
447
478
  "copy": True,
448
- "title": str(record_path),
479
+ "title": f"Example title — {str(record_path).replace('/', '/<wbr>')}",
449
480
  "visible": True,
450
481
  "width": 800,
451
482
  }
452
- assert not manager.plot_widget.getPlotItem().titleLabel.isVisible()
483
+ assert not plot_item.titleLabel.isVisible()
484
+ assert plot_item.titleLabel.text == ""
485
+ assert plot_item.layout.minimumWidth() == initial_minimum_width
453
486
  manager.widget.deleteLater()
454
487
 
455
488
  def test_save_plot_writes_png_with_record_path_title(
@@ -458,7 +491,7 @@ class TestPlotManagerFitAndColorBar:
458
491
  monkeypatch: pytest.MonkeyPatch,
459
492
  ) -> None:
460
493
  manager = PlotManager()
461
- manager._plot_record = SimpleNamespace(path=tmp_path)
494
+ manager._plot_record = SimpleNamespace(path=tmp_path, title="Example title")
462
495
  observed: dict[str, object] = {}
463
496
 
464
497
  class FakeExporter:
@@ -490,7 +523,7 @@ class TestPlotManagerFitAndColorBar:
490
523
 
491
524
  assert observed == {
492
525
  "to_bytes": True,
493
- "title": str(tmp_path),
526
+ "title": f"Example title — {str(tmp_path).replace('/', '/<wbr>')}",
494
527
  "width": 800,
495
528
  "path": str(tmp_path / "plot.png"),
496
529
  "format": "PNG",
@@ -548,35 +581,6 @@ class TestPlotManagerFitAndColorBar:
548
581
  assert saved_paths == [str(tmp_path / "plot-2.png")]
549
582
  manager.widget.deleteLater()
550
583
 
551
- def test_color_bar_is_reused_and_removed_when_switching_to_1d(self) -> None:
552
- manager = PlotManager()
553
- manager._plot_record = object()
554
- manager._plot_frame = pd.DataFrame(
555
- {
556
- "x": [0.0, 0.0, 1.0, 1.0],
557
- "y": [0.0, 1.0, 0.0, 1.0],
558
- "z": [1.0, 2.0, 3.0, 4.0],
559
- }
560
- )
561
-
562
- manager._refresh_plot_2d("x", "y", "z")
563
- color_bar = manager._color_bar
564
- assert color_bar is not None
565
- assert color_bar.getAxis("left").labelText == "z"
566
- assert color_bar.axis.labelText == ""
567
- assert color_bar.maximumHeight() == round(
568
- manager.plot_widget.getPlotItem().vb.height() * COLOR_BAR_HEIGHT_FACTOR
569
- )
570
- assert manager.exponential_fit_button.isHidden()
571
- assert manager.quadratic_fit_button.isHidden()
572
-
573
- manager._refresh_plot_2d("x", "y", "z")
574
- assert manager._color_bar is color_bar
575
-
576
- manager._refresh_plot_1d("x", ["z"])
577
- assert manager._color_bar is None
578
- manager.widget.deleteLater()
579
-
580
584
  def test_2d_cursor_replaces_color_bar_and_target_moves_both_lines(self) -> None:
581
585
  manager = PlotManager()
582
586
  manager._plot_record = object()
@@ -1,7 +1,10 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import builtins
4
+ import sys
5
+ from types import SimpleNamespace
4
6
 
7
+ from PySide6.QtGui import QIcon
5
8
  from PySide6.QtWidgets import QApplication
6
9
 
7
10
  from logqbit.gui.browser import startup
@@ -26,8 +29,26 @@ def test_browser_startup_notice_is_shown_immediately() -> None:
26
29
  splash.close()
27
30
 
28
31
 
32
+ def test_windows_taskbar_identity_is_set_before_qt_startup(monkeypatch) -> None:
33
+ app_ids: list[str] = []
34
+ fake_ctypes = SimpleNamespace(
35
+ windll=SimpleNamespace(
36
+ shell32=SimpleNamespace(
37
+ SetCurrentProcessExplicitAppUserModelID=app_ids.append
38
+ )
39
+ )
40
+ )
41
+ monkeypatch.setattr(startup.platform, "system", lambda: "Windows")
42
+ monkeypatch.setitem(sys.modules, "ctypes", fake_ctypes)
43
+
44
+ startup._set_windows_app_user_model_id()
45
+
46
+ assert app_ids == [startup._WINDOWS_APP_USER_MODEL_ID]
47
+
48
+
29
49
  def test_browser_startup_failure_shows_error_dialog(monkeypatch) -> None:
30
- _create_application()
50
+ app = _create_application()
51
+ app.setWindowIcon(QIcon())
31
52
  expected = RuntimeError("window import failed")
32
53
  shown: list[Exception] = []
33
54
  original_import = builtins.__import__
@@ -42,6 +63,7 @@ def test_browser_startup_failure_shows_error_dialog(monkeypatch) -> None:
42
63
 
43
64
  assert startup.run_browser_application([]) == 1
44
65
  assert shown == [expected]
66
+ assert not app.windowIcon().isNull()
45
67
 
46
68
 
47
69
  def test_startup_error_dialog_contains_exception_details(monkeypatch) -> None:
@@ -6,13 +6,11 @@ from types import SimpleNamespace
6
6
  import pandas as pd
7
7
  import pytest
8
8
  from PySide6.QtCore import QEventLoop, QSettings, Qt, QTimer
9
- from PySide6.QtGui import QColor, QKeySequence, QPalette
9
+ from PySide6.QtGui import QKeySequence
10
10
  from PySide6.QtTest import QTest
11
11
  from PySide6.QtWidgets import (
12
12
  QApplication,
13
13
  QMessageBox,
14
- QStyle,
15
- QStyleOptionViewItem,
16
14
  )
17
15
 
18
16
  from logqbit import catalog as catalog_module
@@ -22,20 +20,12 @@ from logqbit.catalog import (
22
20
  LogRecord,
23
21
  MergeRecordsError,
24
22
  MergeRecordsResult,
25
- PreparedMerge,
26
- )
27
- from logqbit.gui.browser.window.model import (
28
- COL_CREATE_TIME,
29
- COL_ROWS,
30
23
  )
24
+ from logqbit.gui.browser.window.model import COL_ROWS
31
25
  from logqbit.gui.browser.window import merge as merge_module
32
26
  from logqbit.gui.browser.window.merge import MergeDialog
33
27
  from logqbit.gui.browser.detail.view import RecordDetailWindow
34
- from logqbit.gui.browser.window.view import (
35
- LogBrowserWindow,
36
- LogListItemDelegate,
37
- _validated_log_id,
38
- )
28
+ from logqbit.gui.browser.window.view import LogBrowserWindow, _validated_log_id
39
29
  from logqbit.metadata import LogMetadata
40
30
 
41
31
 
@@ -123,25 +113,6 @@ class TestBrowserWindow:
123
113
  with pytest.raises(ValueError):
124
114
  _validated_log_id(value)
125
115
 
126
- def test_log_list_uses_white_selection_text(self, sample_logfolder: Path) -> None:
127
- window = LogBrowserWindow(sample_logfolder)
128
- try:
129
- assert not window.log_table.styleSheet()
130
- assert isinstance(window.log_table.itemDelegate(), LogListItemDelegate)
131
-
132
- option = QStyleOptionViewItem()
133
- option.state |= QStyle.State_Selected
134
- palette = option.palette
135
- palette.setColor(QPalette.HighlightedText, QColor("black"))
136
- option.palette = palette
137
-
138
- display_option = LogListItemDelegate._display_option(option)
139
- assert display_option.palette.color(QPalette.HighlightedText) == QColor(
140
- "white"
141
- )
142
- finally:
143
- window.close()
144
-
145
116
  def test_browser_window_detail_shortcuts(self, sample_logfolder: Path) -> None:
146
117
  app = _create_application()
147
118
  window = LogBrowserWindow(sample_logfolder)
@@ -280,50 +251,6 @@ class TestBrowserWindow:
280
251
  finally:
281
252
  window.close()
282
253
 
283
- def test_column_visibility_actions_are_in_header_context_menu(
284
- self,
285
- sample_logfolder: Path,
286
- ) -> None:
287
- window = LogBrowserWindow(sample_logfolder)
288
- try:
289
- assert window.log_table.isColumnHidden(COL_CREATE_TIME)
290
-
291
- menu = window._actions.create_header_context_menu()
292
- actions = menu.actions()
293
-
294
- assert [action.text() for action in actions] == [
295
- "Show Plot Axes Column",
296
- "Show Create Time Column",
297
- "Show Create Machine Column",
298
- ]
299
- actions[1].trigger()
300
- assert not window.log_table.isColumnHidden(COL_CREATE_TIME)
301
- finally:
302
- window.close()
303
-
304
- def test_append_target_uses_cached_columns_without_reading_data(
305
- self,
306
- sample_records: list[LogRecord],
307
- monkeypatch: pytest.MonkeyPatch,
308
- ) -> None:
309
- aggregate = LogRecord(
310
- sample_records[0].path,
311
- row_count=sample_records[0].row_count,
312
- columns=(*sample_records[0].columns, LOGFOLDER_SID_COLUMN),
313
- data_version=sample_records[0].data_version,
314
- )
315
- monkeypatch.setattr(
316
- LogRecord,
317
- "read_dataframe",
318
- lambda _self: pytest.fail("finding the append target must not load data"),
319
- )
320
-
321
- assert (
322
- PreparedMerge.find_append_target([sample_records[1], aggregate])
323
- is aggregate
324
- )
325
- assert PreparedMerge.find_append_target(sample_records[:2]) is None
326
-
327
254
  def test_append_opens_persistent_dialog_for_sole_sid_record(
328
255
  self,
329
256
  sample_records: list[LogRecord],
@@ -628,59 +555,6 @@ class TestBrowserWindow:
628
555
  finally:
629
556
  window.close()
630
557
 
631
- def test_list_refresh_preserves_current_detail_cache(
632
- self, sample_logfolder: Path, monkeypatch: pytest.MonkeyPatch
633
- ) -> None:
634
- app = _create_application()
635
- window = LogBrowserWindow(sample_logfolder)
636
- app.processEvents()
637
- try:
638
- record = window._selected_record
639
- assert record is not None
640
- dataframe = window.detail_view._data_cache.dataframe
641
- assert dataframe is not None
642
-
643
- read_count = 0
644
- original_read_feather = catalog_module.pd.read_feather
645
-
646
- def count_read_feather(*args, **kwargs):
647
- nonlocal read_count
648
- read_count += 1
649
- return original_read_feather(*args, **kwargs)
650
-
651
- monkeypatch.setattr(catalog_module.pd, "read_feather", count_read_feather)
652
-
653
- window.refresh_logs()
654
-
655
- assert window._selected_record is record
656
- assert window.detail_view._data_cache.dataframe is dataframe
657
- assert read_count == 0
658
- finally:
659
- window.close()
660
-
661
- def test_manual_refresh_reads_current_feather_once(
662
- self, sample_logfolder: Path, monkeypatch: pytest.MonkeyPatch
663
- ) -> None:
664
- app = _create_application()
665
- window = LogBrowserWindow(sample_logfolder)
666
- app.processEvents()
667
- try:
668
- read_count = 0
669
- original_read_feather = catalog_module.pd.read_feather
670
-
671
- def count_read_feather(*args, **kwargs):
672
- nonlocal read_count
673
- read_count += 1
674
- return original_read_feather(*args, **kwargs)
675
-
676
- monkeypatch.setattr(catalog_module.pd, "read_feather", count_read_feather)
677
-
678
- window._on_refresh_clicked()
679
-
680
- assert read_count == 1
681
- finally:
682
- window.close()
683
-
684
558
  def test_manual_refresh_updates_catalog_summary_and_detail(
685
559
  self, sample_logfolder: Path, monkeypatch: pytest.MonkeyPatch
686
560
  ) -> None:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes