Skip to content

Commit 9d7441e

Browse files
Merge #3623
3623: Add two more methods to dataset protocol r=jenshnielsen a=jenshnielsen Research shows that these are fairly commonly uses so to make it easier to use the protocol I suggest adding them here. The implementation is also fairly straight forward Co-authored-by: Jens H. Nielsen <Jens.Nielsen@microsoft.com>
2 parents cd0c048 + 1d2ca21 commit 9d7441e

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

qcodes/dataset/data_set.py

-7
Original file line numberDiff line numberDiff line change
@@ -437,13 +437,6 @@ def paramspecs(self) -> Dict[str, ParamSpec]:
437437
return {ps.name: ps
438438
for ps in self.get_parameters()}
439439

440-
@property
441-
def dependent_parameters(self) -> Tuple[ParamSpecBase, ...]:
442-
"""
443-
Return all the parameters that explicitly depend on other parameters
444-
"""
445-
return tuple(self._rundescriber.interdeps.dependencies.keys())
446-
447440
@property
448441
def exp_id(self) -> int:
449442
exp_id = select_one_where(self.conn, "runs", "exp_id", "run_id", self.run_id)

qcodes/dataset/data_set_in_memory.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111

1212
import numpy as np
1313

14-
from qcodes.dataset.data_set_protocol import SPECS, BaseDataSet, CompletedError
14+
from qcodes.dataset.data_set_protocol import (
15+
SPECS,
16+
BaseDataSet,
17+
CompletedError,
18+
ParameterData,
19+
)
1520
from qcodes.dataset.descriptions.dependencies import InterDependencies_
1621
from qcodes.dataset.descriptions.param_spec import ParamSpec, ParamSpecBase
1722
from qcodes.dataset.descriptions.rundescriber import RunDescriber
@@ -825,6 +830,15 @@ def to_pandas_dataframe(
825830
self._warn_if_set(*params, start=start, end=end)
826831
return self.cache.to_pandas_dataframe()
827832

833+
def get_parameter_data(
834+
self,
835+
*params: Union[str, ParamSpec, _BaseParameter],
836+
start: Optional[int] = None,
837+
end: Optional[int] = None,
838+
) -> ParameterData:
839+
self._warn_if_set(*params, start=start, end=end)
840+
return self.cache.data()
841+
828842
@staticmethod
829843
def _warn_if_set(
830844
*params: Union[str, ParamSpec, _BaseParameter],

qcodes/dataset/data_set_protocol.py

+19
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,22 @@ def export_info(self) -> ExportInfo:
219219
def cache(self) -> DataSetCache[DataSetProtocol]:
220220
pass
221221

222+
def get_parameter_data(
223+
self,
224+
*params: Union[str, ParamSpec, _BaseParameter],
225+
start: Optional[int] = None,
226+
end: Optional[int] = None,
227+
) -> ParameterData:
228+
pass
229+
222230
def get_parameters(self) -> SPECS:
223231
# used by plottr
224232
pass
225233

234+
@property
235+
def dependent_parameters(self) -> Tuple[ParamSpecBase, ...]:
236+
pass
237+
226238
# exporters to other in memory formats
227239

228240
def to_xarray_dataarray_dict(
@@ -501,6 +513,13 @@ def completed_timestamp(self, fmt: str = "%Y-%m-%d %H:%M:%S") -> Optional[str]:
501513
"""
502514
return raw_time_to_str_time(self.completed_timestamp_raw, fmt)
503515

516+
@property
517+
def dependent_parameters(self) -> Tuple[ParamSpecBase, ...]:
518+
"""
519+
Return all the parameters that explicitly depend on other parameters
520+
"""
521+
return tuple(self.description.interdeps.dependencies.keys())
522+
504523

505524
class DataSetType(str, Enum):
506525

0 commit comments

Comments
 (0)