Skip to content

Commit

Permalink
Fix typing of cache.to_pandas_* methods becasue they cannot return None
Browse files Browse the repository at this point in the history
  • Loading branch information
astafan8 committed Feb 23, 2021
1 parent a2c8469 commit 00f4bb3
Showing 1 changed file with 5 additions and 18 deletions.
23 changes: 5 additions & 18 deletions qcodes/dataset/data_set_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def add_data(self, new_data: Dict[str, Dict[str, np.ndarray]]) -> None:
if not all(status is None for status in self._write_status.values()):
self._live = True

def to_pandas_dataframe_dict(self) -> Optional[Dict[str, "pd.DataFrame"]]:
def to_pandas_dataframe_dict(self) -> Dict[str, "pd.DataFrame"]:
"""
Convert the cached dataset to Pandas dataframes. The returned dataframes
are in the same format :py:class:`.DataSet.to_pandas_dataframe_dict`.
Expand All @@ -141,14 +141,10 @@ def to_pandas_dataframe_dict(self) -> Optional[Dict[str, "pd.DataFrame"]]:
A dict from parameter name to Pandas Dataframes. Each dataframe
represents one parameter tree.
"""

data = self.data()
if data is None:
return None

return self._dataset._load_to_dataframe_dict(data)

def to_pandas_dataframe(self) -> Optional["pd.DataFrame"]:
def to_pandas_dataframe(self) -> "pd.DataFrame":
"""
Convert the cached dataset to Pandas dataframes. The returned dataframes
are in the same format :py:class:`.DataSet.to_pandas_dataframe_dict`.
Expand All @@ -158,13 +154,10 @@ def to_pandas_dataframe(self) -> Optional["pd.DataFrame"]:
represents one parameter tree.
"""
data = self.data()
if data is None:
return None

return self._dataset._load_to_concatenated_dataframe(data)

@deprecate(alternative="to_pandas_dataframe or to_pandas_dataframe_dict")
def to_pandas(self) -> Optional[Dict[str, "pd.DataFrame"]]:
def to_pandas(self) -> Dict[str, "pd.DataFrame"]:
"""
Returns the values stored in the :class:`.dataset.data_set.DataSet` as a
concatenated :py:class:`pandas.DataFrame` s
Expand All @@ -184,7 +177,7 @@ def to_pandas(self) -> Optional[Dict[str, "pd.DataFrame"]]:
"""
return self.to_pandas_dataframe_dict()

def to_xarray_dataarray_dict(self) -> Optional[Dict[str, "xr.DataArray"]]:
def to_xarray_dataarray_dict(self) -> Dict[str, "xr.DataArray"]:
"""
Returns the values stored in the :class:`.dataset.data_set.DataSet` as a dict of
:py:class:`xr.DataArray` s
Expand All @@ -197,12 +190,9 @@ def to_xarray_dataarray_dict(self) -> Optional[Dict[str, "xr.DataArray"]]:
"""
data = self.data()
if data is None:
return None

return self._dataset._load_to_xarray_dataarray_dict(data)

def to_xarray_dataset(self) -> Optional["xr.Dataset"]:
def to_xarray_dataset(self) -> "xr.Dataset":
"""
Returns the values stored in the :class:`.dataset.data_set.DataSet` as a
:py:class:`xr.Dataset` object.
Expand All @@ -217,9 +207,6 @@ def to_xarray_dataset(self) -> Optional["xr.Dataset"]:
"""
data = self.data()
if data is None:
return None

return self._dataset._load_to_xarray_dataset(data)


Expand Down

0 comments on commit 00f4bb3

Please sign in to comment.