Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changes/newsfragments/7772.improved
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
The table created by experiments_widget() now has a column of buttons by which individual datasets can be exported as ASCII files. This is a user-friendly way to use the qcode.dataset.export() method.

To demo this feature, run
> experiments_widget(sort_by="timestamp")
in Jupyter, and click on one of the cells in the "Export" column.
18 changes: 18 additions & 0 deletions src/qcodes/interactive_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import traceback
from datetime import datetime
from functools import partial, reduce
from pathlib import Path
from typing import TYPE_CHECKING, Any, Literal

from ipywidgets import ( # type: ignore[import-untyped]
Expand Down Expand Up @@ -442,6 +443,21 @@ def _get_plot_button(ds: DataSetProtocol, tab: Tab) -> Button:
)


def _get_export_button(
ds: DataSetProtocol, tab: Tab
) -> Button: # New button in the table to export each dataset
return button(
"",
"warning",
tooltip="Click to export this DataSet as ASCII.",
on_click=lambda _: ds.export(
"csv",
path=Path.cwd() / "export",
),
button_kwargs=dict(icon="file-export"),
)


def _experiment_widget(
data_sets: Iterable[DataSetProtocol], tab: Tab
) -> GridspecLayout:
Expand All @@ -457,6 +473,7 @@ def _experiment_widget(
"Notes",
"Snapshot",
"Plot",
"Export",
]

header = {n: button(n, "info") for n in header_names}
Expand All @@ -471,6 +488,7 @@ def _experiment_widget(
row["MSMT Time"] = _get_timestamp_button(ds)
row["Snapshot"] = _get_snapshot_button(ds, tab)
row["Plot"] = _get_plot_button(ds, tab)
row["Export"] = _get_export_button(ds, tab)
rows.append(row)

grid = GridspecLayout(n_rows=len(rows), n_columns=len(header_names))
Expand Down
7 changes: 7 additions & 0 deletions tests/test_interactive_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def test_snapshot_button(tab, standalone_parameters_dataset) -> None:
assert "snapshot" in tab.get_title(1)


def test_export_button(tab, standalone_parameters_dataset) -> None:
ds = standalone_parameters_dataset
export_button = interactive_widget._get_export_button(ds, tab)
export_button.click()
time.sleep(0.5) # after click


@patch("matplotlib.pyplot.show")
def test_plot_button(tab, standalone_parameters_dataset) -> None:
ds = standalone_parameters_dataset
Expand Down
Loading