Skip to content

Commit

Permalink
#62 changed float_ annotations to float64 for numpy 2.0 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
crnbaker committed Jun 26, 2024
1 parent 34d4d1f commit c285ffa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/spectrumdevice/devices/awg/synthesis.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from numpy import float_, iinfo, issubdtype, signedinteger, pi, sin, linspace, int_, ones, int16
from numpy import float64, iinfo, issubdtype, signedinteger, pi, sin, linspace, int_, ones, int16
from numpy.typing import NDArray


def make_full_scale_sine_waveform(
frequency_in_hz: float, sample_rate_in_hz: int, num_cycles: float, dtype: type = int16
) -> tuple[NDArray[float_], NDArray[int_]]:
) -> tuple[NDArray[float64], NDArray[int_]]:
"""Create a sine waveform covering the full range of the given data type. The resulting waveform is intended to
be transferred to the AWG's on-board memory for generation.
Expand All @@ -25,7 +25,7 @@ def make_full_scale_sine_waveform(

def make_full_scale_rect_waveform(
sample_rate_in_hz: int, duration_in_seconds: float, dtype: type = int16
) -> tuple[NDArray[float_], NDArray[int_]]:
) -> tuple[NDArray[float64], NDArray[int_]]:
"""Create a rectangular waveform covering the full range of the given data type. The resulting waveform is intended
to be transferred to the AWG's on-board memory for generation.
Expand Down
6 changes: 3 additions & 3 deletions src/spectrumdevice/devices/digitiser/digitiser_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import logging
from typing import List, Optional, Sequence, cast

from numpy import float_, int16, mod, squeeze, zeros
from numpy import float64, int16, mod, squeeze, zeros
from numpy.typing import NDArray

from spectrum_gmbh.py_header.regs import (
Expand Down Expand Up @@ -173,13 +173,13 @@ def get_raw_waveforms(self) -> List[List[NDArray[int16]]]:

return repeat_acquisitions

def get_waveforms(self) -> List[List[NDArray[float_]]]:
def get_waveforms(self) -> List[List[NDArray[float64]]]:
"""Get a list of the most recently transferred waveforms, in channel order, in Volts as floats.
See get_raw_waveforms() for details.
Returns:
waveforms (List[List[NDArray[float_]]]): A list of lists of 1D numpy arrays, one inner list per acquisition
waveforms (List[List[NDArray[float64]]]): A list of lists of 1D numpy arrays, one inner list per acquisition
and one array per enabled channel, in channel order. To average the acquisitions:
`np.array(waveforms).mean(axis=0)`
Expand Down
8 changes: 4 additions & 4 deletions src/spectrumdevice/devices/digitiser/digitiser_star_hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from threading import Thread
from typing import Callable, Dict, List, Optional, Sequence, TypeVar

from numpy import float_, int16
from numpy import float64, int16
from numpy.typing import NDArray

from spectrumdevice.devices.abstract_device import (
Expand All @@ -23,7 +23,7 @@
from spectrumdevice.settings.device_modes import AcquisitionMode


WAVEFORM_TYPE_VAR = TypeVar("WAVEFORM_TYPE_VAR", NDArray[float_], NDArray[int16])
WAVEFORM_TYPE_VAR = TypeVar("WAVEFORM_TYPE_VAR", NDArray[float64], NDArray[int16])


# noinspection PyTypeChecker
Expand Down Expand Up @@ -73,14 +73,14 @@ def wait_for_acquisition_to_complete(self) -> None:
for card in self._child_cards:
card.wait_for_acquisition_to_complete()

def get_waveforms(self) -> List[List[NDArray[float_]]]:
def get_waveforms(self) -> List[List[NDArray[float64]]]:
"""Get a list of the most recently transferred waveforms, as floating point voltages.
This method gets the waveforms from each child card and joins them into a new list, ordered by channel number.
See `SpectrumDigitiserCard.get_waveforms()` for more information.
Returns:
waveforms (List[List[NDArray[float_]]]): A list lists of 1D numpy arrays, one inner list per acquisition,
waveforms (List[List[NDArray[float64]]]): A list lists of 1D numpy arrays, one inner list per acquisition,
and one array per enabled channel, in channel order.
"""
return self._get_waveforms_in_threads(SpectrumDigitiserCard.get_waveforms)
Expand Down
4 changes: 2 additions & 2 deletions src/spectrumdevice/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from dataclasses import dataclass
from typing import List, Optional

from numpy import float_, int16
from numpy import int16, float64
from numpy.typing import NDArray


VoltageWaveformType = NDArray[float_]
VoltageWaveformType = NDArray[float64]
RawWaveformType = NDArray[int16]


Expand Down

0 comments on commit c285ffa

Please sign in to comment.