Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.
Merged
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: 3 additions & 2 deletions src/pymodaq_data/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def data(self):
@data.setter
def data(self, data: Union[np.ndarray, Q_]):
if data is not None:
self._check_data_valid(data)
data = self._check_data_valid(data)
self.get_scale_offset_from_data(data)
self._size = data.size
elif self.size is None:
Expand Down Expand Up @@ -484,14 +484,15 @@ def _check_index_valid(index: int):
elif index < 0:
raise ValueError('index for the Axis class should be a positive integer')

def _check_data_valid(self, data: Union[np.ndarray, Q_]):
def _check_data_valid(self, data: Union[np.ndarray, Q_]) -> np.ndarray:
if isinstance(data, Q_):
self.units = str(data.units)
data = data.magnitude
if not isinstance(data, np.ndarray):
raise TypeError(f'data for the Axis class should be a 1D numpy array')
elif len(data.shape) != 1:
raise ValueError(f'data for the Axis class should be a 1D numpy array')
return data

def _linear_data(self, nsteps: int):
"""create axis data with a linear version using scaling and offset"""
Expand Down
Loading