From 8e19b58d272d438b83b2450657960f317f3726a3 Mon Sep 17 00:00:00 2001 From: michaelcroquette <45485610+michaelcroquette@users.noreply.github.com> Date: Thu, 2 May 2024 20:12:11 +0200 Subject: [PATCH] np.complex and np.float deprecated --- pyrpl/hardware_modules/asg.py | 2 +- pyrpl/hardware_modules/iir/iir.py | 2 +- pyrpl/hardware_modules/iir/iir_theory.py | 18 +++++++++--------- pyrpl/hardware_modules/iq.py | 6 +++--- pyrpl/hardware_modules/pid.py | 2 +- pyrpl/software_modules/network_analyzer.py | 8 ++++---- pyrpl/software_modules/spectrum_analyzer.py | 2 +- .../test_hardware_modules/test_pid_na_iq.py | 4 ++-- 8 files changed, 22 insertions(+), 22 deletions(-) diff --git a/pyrpl/hardware_modules/asg.py b/pyrpl/hardware_modules/asg.py index c836083f4..62c0890c5 100644 --- a/pyrpl/hardware_modules/asg.py +++ b/pyrpl/hardware_modules/asg.py @@ -301,7 +301,7 @@ def data(self): # self._reads(self._DATA_OFFSET, self.data_length), # dtype=np.int32) x[x >= 2 ** 13] -= 2 ** 14 - return np.array(x, dtype=np.float) / 2 ** 13 + return np.array(x, dtype=float) / 2 ** 13 @data.setter def data(self, data): diff --git a/pyrpl/hardware_modules/iir/iir.py b/pyrpl/hardware_modules/iir/iir.py index a3445cd12..83ee303c7 100644 --- a/pyrpl/hardware_modules/iir/iir.py +++ b/pyrpl/hardware_modules/iir/iir.py @@ -682,7 +682,7 @@ def transfer_function(self, frequencies, extradelay=0): Returns ------- - tf: np.array(..., dtype=np.complex) + tf: np.array(..., dtype=complex) The complex open loop transfer function of the module. If kind=='all', a list of plotdata tuples is returned that can be passed directly to iir.bodeplot(). diff --git a/pyrpl/hardware_modules/iir/iir_theory.py b/pyrpl/hardware_modules/iir/iir_theory.py index 143d74609..e70de2d10 100644 --- a/pyrpl/hardware_modules/iir/iir_theory.py +++ b/pyrpl/hardware_modules/iir/iir_theory.py @@ -90,7 +90,7 @@ def freqs(sys, w): Returns ------- - np.array(..., dtype=np.complex) with the response + np.array(..., dtype=complex) with the response """ z, p, k = sys s = np.array(w, dtype=np.complex128) * 1j @@ -135,7 +135,7 @@ def freqz_(sys, w, dt=8e-9): Returns ------- - np.array(..., dtype=np.complex) with the response + np.array(..., dtype=complex) with the response """ z, p, k = sys b, a = sig.zpk2tf(z, p, k) @@ -877,7 +877,7 @@ def tf_inputfilter(self, inputfilter=None, frequencies=None): # input inputfilter = self.inputfilter if frequencies is None: frequencies = self.frequencies - frequencies = np.asarray(frequencies, dtype=np.complex) + frequencies = np.asarray(frequencies, dtype=complex) try: len(inputfilter) except: @@ -924,7 +924,7 @@ def tf_continuous(self, frequencies=None): frequencies to compute the transfer function for Returns ------- - np.array(..., dtype=np.complex) + np.array(..., dtype=complex) """ if frequencies is None: frequencies = self.frequencies @@ -948,7 +948,7 @@ def tf_partialfraction(self, frequencies=None): Returns ------- - np.array(..., dtype=np.complex) + np.array(..., dtype=complex) """ # this code is more or less a direct copy of get_coeff() if frequencies is None: @@ -985,7 +985,7 @@ def tf_discrete(self, rp_discrete=None, frequencies=None): Returns ------- - np.array(..., dtype=np.complex) + np.array(..., dtype=complex) """ if frequencies is None: frequencies = self.frequencies @@ -1023,7 +1023,7 @@ def tf_coefficients(self, frequencies=None, coefficients=None, Returns ------- - np.array(..., dtype=np.complex) + np.array(..., dtype=complex) """ if frequencies is None: frequencies = self.frequencies @@ -1071,7 +1071,7 @@ def tf_rounded(self, frequencies=None, delay=False): Returns ------- - np.array(..., dtype=np.complex) + np.array(..., dtype=complex) """ return self.tf_coefficients(frequencies=frequencies, coefficients=self.coefficients_rounded, @@ -1099,7 +1099,7 @@ def tf_final(self, frequencies=None): Returns ------- - np.array(..., dtype=np.complex) + np.array(..., dtype=complex) """ return self.tf_rounded(frequencies=frequencies, delay=True) * \ self.tf_inputfilter(frequencies=frequencies) diff --git a/pyrpl/hardware_modules/iq.py b/pyrpl/hardware_modules/iq.py index 01272fe7e..7e35c0642 100644 --- a/pyrpl/hardware_modules/iq.py +++ b/pyrpl/hardware_modules/iq.py @@ -544,15 +544,15 @@ def transfer_function(self, frequencies, extradelay=0): Returns ------- - tf: np.array(..., dtype=np.complex) + tf: np.array(..., dtype=complex) The complex open loop transfer function of the module. """ quadrature_delay = 2 # the delay experienced by the signal when it # is represented as a quadrature (=lower frequency, less phaseshift) # the remaining delay of the module module_delay = self._delay - quadrature_delay - frequencies = np.array(frequencies, dtype=np.complex) - tf = np.array(frequencies * 0, dtype=np.complex) + self.gain + frequencies = np.array(frequencies, dtype=complex) + tf = np.array(frequencies * 0, dtype=complex) + self.gain # bandpass filter for f in self.bandwidth: if f == 0: diff --git a/pyrpl/hardware_modules/pid.py b/pyrpl/hardware_modules/pid.py index 7d8aafe23..fc788129e 100644 --- a/pyrpl/hardware_modules/pid.py +++ b/pyrpl/hardware_modules/pid.py @@ -382,7 +382,7 @@ def transfer_function(self, frequencies, extradelay=0): Returns ------- - tf: np.array(..., dtype=np.complex) + tf: np.array(..., dtype=complex) The complex open loop transfer function of the module. """ return Pid._transfer_function(frequencies, diff --git a/pyrpl/software_modules/network_analyzer.py b/pyrpl/software_modules/network_analyzer.py index 1410e02f5..5767758ae 100644 --- a/pyrpl/software_modules/network_analyzer.py +++ b/pyrpl/software_modules/network_analyzer.py @@ -240,13 +240,13 @@ def transfer_function(self, frequencies, extradelay=0): Returns ------- - tf: np.array(..., dtype=np.complex) + tf: np.array(..., dtype=complex) The complex open loop transfer function of the module. """ module_delay = self._delay frequencies = np.array(np.array(frequencies, dtype=np.float), - dtype=np.complex) - tf = np.array(frequencies*0, dtype=np.complex) + 1.0 + dtype=complex) + tf = np.array(frequencies*0, dtype=complex) + 1.0 # input filter modelisation f = self.iq.inputfilter # no for loop here because only one filter # stage @@ -598,7 +598,7 @@ def _prepare_averaging(self): self.data_x = self.frequencies if not self.is_zero_span() else \ np.nan*np.ones(self.points) # Will be filled during acquisition self.data_avg = np.zeros(self.points, # np.empty can create nan - dtype=np.complex) #and nan*current_avg = nan + dtype=complex) #and nan*current_avg = nan # even if current_avg = 0 @property diff --git a/pyrpl/software_modules/spectrum_analyzer.py b/pyrpl/software_modules/spectrum_analyzer.py index a78495288..9703004dd 100644 --- a/pyrpl/software_modules/spectrum_analyzer.py +++ b/pyrpl/software_modules/spectrum_analyzer.py @@ -421,7 +421,7 @@ def _get_filtered_iq_data(self): :return: the product between the complex iq data and the filter_window """ return self._get_iq_data() * np.asarray(self.filter_window(), - dtype=np.complex) + dtype=complex) def useful_index_obsolete(self): """ diff --git a/pyrpl/test/test_hardware_modules/test_pid_na_iq.py b/pyrpl/test/test_hardware_modules/test_pid_na_iq.py index a1e5e515a..978a47dab 100644 --- a/pyrpl/test/test_hardware_modules/test_pid_na_iq.py +++ b/pyrpl/test/test_hardware_modules/test_pid_na_iq.py @@ -46,7 +46,7 @@ def test_na(self): data = na.single() f = na.data_x theory = np.array(f * 0 + 1.0, - dtype=np.complex) + dtype=complex) # obsolete since na data now comes autocorrected: # theory = na.transfer_function(f, extradelay=extradelay) relerror = np.abs((data - theory) / theory) @@ -110,7 +110,7 @@ def test_inputfilter(self): theory = pid.transfer_function(f, extradelay=extradelay) relerror = np.abs((data - theory) / theory) # get max error for values > -50 dB (otherwise its just NA noise) - mask = np.asarray(np.abs(theory) > 3e-3, dtype=np.float) + mask = np.asarray(np.abs(theory) > 3e-3, dtype=float) maxerror = np.max(relerror*mask) if maxerror > error_threshold: print(maxerror)