From c285ffa0de86307da1ca1e27fdcf4521ce6c57fa Mon Sep 17 00:00:00 2001 From: crnbaker Date: Wed, 26 Jun 2024 11:53:35 +0100 Subject: [PATCH] #62 changed float_ annotations to float64 for numpy 2.0 compatibility --- src/spectrumdevice/devices/awg/synthesis.py | 6 +++--- src/spectrumdevice/devices/digitiser/digitiser_card.py | 6 +++--- .../devices/digitiser/digitiser_star_hub.py | 8 ++++---- src/spectrumdevice/measurement.py | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/spectrumdevice/devices/awg/synthesis.py b/src/spectrumdevice/devices/awg/synthesis.py index 3f16ce2..e4f2747 100644 --- a/src/spectrumdevice/devices/awg/synthesis.py +++ b/src/spectrumdevice/devices/awg/synthesis.py @@ -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. @@ -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. diff --git a/src/spectrumdevice/devices/digitiser/digitiser_card.py b/src/spectrumdevice/devices/digitiser/digitiser_card.py index a67ceae..942d915 100644 --- a/src/spectrumdevice/devices/digitiser/digitiser_card.py +++ b/src/spectrumdevice/devices/digitiser/digitiser_card.py @@ -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 ( @@ -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)` diff --git a/src/spectrumdevice/devices/digitiser/digitiser_star_hub.py b/src/spectrumdevice/devices/digitiser/digitiser_star_hub.py index 52e1b44..5351a61 100644 --- a/src/spectrumdevice/devices/digitiser/digitiser_star_hub.py +++ b/src/spectrumdevice/devices/digitiser/digitiser_star_hub.py @@ -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 ( @@ -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 @@ -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) diff --git a/src/spectrumdevice/measurement.py b/src/spectrumdevice/measurement.py index 0f1f755..c0f165c 100644 --- a/src/spectrumdevice/measurement.py +++ b/src/spectrumdevice/measurement.py @@ -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]