Skip to content

Commit

Permalink
np.complex and np.float deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelcroquette committed May 2, 2024
1 parent 7f67ce2 commit 8e19b58
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion pyrpl/hardware_modules/asg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion pyrpl/hardware_modules/iir/iir.py
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
18 changes: 9 additions & 9 deletions pyrpl/hardware_modules/iir/iir_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions pyrpl/hardware_modules/iq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion pyrpl/hardware_modules/pid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions pyrpl/software_modules/network_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyrpl/software_modules/spectrum_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
4 changes: 2 additions & 2 deletions pyrpl/test/test_hardware_modules/test_pid_na_iq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 8e19b58

Please sign in to comment.