Skip to content

Commit 3031c64

Browse files
committed
More numpy.complex to be replaced
1 parent 455e472 commit 3031c64

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

QGL/Compiler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def generate_waveforms(physicalWires):
223223
continue
224224
if pulse.hashshape() not in wfs[ch]:
225225
if pulse.isTimeAmp:
226-
wfs[ch][pulse.hashshape()] = np.ones(1, dtype=np.complex)
226+
wfs[ch][pulse.hashshape()] = np.ones(1, dtype=np.complex128)
227227
else:
228228
wfs[ch][pulse.hashshape()] = pulse.shape
229229
return wfs

QGL/PulseShapes.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def gaussian(amp=1, length=0, cutoff=2, sampling_rate=1e9, **params):
2323
#Rescale so that the maximum equals amp
2424
amp = (amp / (1 - nextPoint))
2525
return (amp * (np.exp(-0.5 * (xPts**2)) - np.exp(-0.5 * (
26-
(xPts[-1] + xStep)**2)))).astype(np.complex)
26+
(xPts[-1] + xStep)**2)))).astype(np.complex128)
2727

2828

2929
def delay(length=0, sampling_rate=1e9, **params):
@@ -38,7 +38,7 @@ def constant(amp=1, length=0, sampling_rate=1e9, **params):
3838
A constant section.
3939
'''
4040
numPts = int(np.round(length * sampling_rate))
41-
return amp * np.ones(numPts, dtype=np.complex)
41+
return amp * np.ones(numPts, dtype=np.complex128)
4242

4343
# square is deprecated but alias square to constant
4444
square = constant
@@ -80,7 +80,7 @@ def gaussOn(amp=1, length=0, cutoff=2, sampling_rate=1e9, **params):
8080
nextPoint = np.exp(-0.5 * ((xPts[0] - xStep)**2))
8181
#Rescale so that it still goes to amp
8282
amp = (amp / (1 - nextPoint))
83-
return (amp * (np.exp(-0.5 * (xPts**2)) - nextPoint)).astype(np.complex)
83+
return (amp * (np.exp(-0.5 * (xPts**2)) - nextPoint)).astype(np.complex128)
8484

8585

8686
def gaussOff(amp=1, length=0, cutoff=2, sampling_rate=1e9, **params):
@@ -96,7 +96,7 @@ def gaussOff(amp=1, length=0, cutoff=2, sampling_rate=1e9, **params):
9696
nextPoint = np.exp(-0.5 * ((xPts[-1] + xStep)**2))
9797
#Rescale so that it still goes to amp
9898
amp = (amp / (1 - nextPoint))
99-
return (amp * (np.exp(-0.5 * (xPts**2)) - nextPoint)).astype(np.complex)
99+
return (amp * (np.exp(-0.5 * (xPts**2)) - nextPoint)).astype(np.complex128)
100100

101101

102102
def dragGaussOn(amp=1,
@@ -140,7 +140,7 @@ def tanh(amp=1, length=0, sigma=0, cutoff=2, sampling_rate=1e9, **params):
140140
A rounded constant shape from the sum of two tanh shapes.
141141
'''
142142
if length == 0.0:
143-
return np.empty(shape=(0,)).astype(np.complex)
143+
return np.empty(shape=(0,)).astype(np.complex128)
144144
else:
145145
numPts = int(np.round(length * sampling_rate))
146146
xPts = np.linspace(-length / 2, length / 2, numPts)
@@ -151,7 +151,7 @@ def tanh(amp=1, length=0, sigma=0, cutoff=2, sampling_rate=1e9, **params):
151151
f'(={sigma}s). Consider '
152152
f'using a Gaussian pulse instead.')
153153
return amp * 0.5 * (np.tanh((xPts - x1) / sigma) + np.tanh(
154-
(x2 - xPts) / sigma)).astype(np.complex)
154+
(x2 - xPts) / sigma)).astype(np.complex128)
155155

156156

157157
def exp_decay(amp=1, length=0, sigma=0, sampling_rate=1e9, steady_state=0.4, **params):
@@ -161,7 +161,7 @@ def exp_decay(amp=1, length=0, sigma=0, sampling_rate=1e9, steady_state=0.4, **p
161161
"""
162162
numPts = int(np.round(length * sampling_rate))
163163
timePts = (1.0 / sampling_rate) * np.arange(numPts)
164-
return amp * ((1-steady_state) * np.exp(-timePts / sigma) + steady_state).astype(np.complex)
164+
return amp * ((1-steady_state) * np.exp(-timePts / sigma) + steady_state).astype(np.complex128)
165165

166166
def CLEAR(amp=1, length=0, sigma=0, sampling_rate=1e9, **params):
167167
"""
@@ -175,10 +175,10 @@ def CLEAR(amp=1, length=0, sigma=0, sampling_rate=1e9, **params):
175175
if 'step_length' not in params:
176176
params['step_length'] = 100e-9
177177
timePts = (1.0 / sampling_rate) * np.arange(np.round((length-2*params['step_length']) * sampling_rate))
178-
flat_step = amp * (0.6 * np.exp(-timePts / sigma) + 0.4).astype(np.complex)
178+
flat_step = amp * (0.6 * np.exp(-timePts / sigma) + 0.4).astype(np.complex128)
179179
numPts_clear_step = int(np.round(params['step_length'] * sampling_rate))
180-
clear_step_one = amp * params['amp1'] * np.ones(numPts_clear_step, dtype=np.complex)
181-
clear_step_two = amp * params['amp2'] * np.ones(numPts_clear_step, dtype=np.complex)
180+
clear_step_one = amp * params['amp1'] * np.ones(numPts_clear_step, dtype=np.complex128)
181+
clear_step_two = amp * params['amp2'] * np.ones(numPts_clear_step, dtype=np.complex128)
182182
return np.append(flat_step, [clear_step_one, clear_step_two])
183183

184184
def autodyne(frequency=10e6, baseShape=constant, **params):

QGL/drivers/APSPattern.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def apply_min_pulse_constraints(miniLL, wfLib):
240240
if curEntry.isZero and not nextEntry.isZero:
241241
# Concatenate the waveforms
242242
paddedWF = np.hstack((np.zeros(curEntry.length,
243-
dtype=np.complex),
243+
dtype=np.complex128),
244244
wfLib[wf_sig(nextEntry)]))
245245
# Generate a new key
246246
nextEntry.key = hash_pulse(paddedWF)
@@ -263,12 +263,12 @@ def apply_min_pulse_constraints(miniLL, wfLib):
263263
continue
264264
elif curEntry.isTimeAmp: # non-zero
265265
paddedWF = np.hstack(
266-
(np.zeros(padLength, dtype=np.complex),
266+
(np.zeros(padLength, dtype=np.complex128),
267267
wfLib[wf_sig(curEntry)] * np.ones(curEntry.length)))
268268
curEntry.isTimeAmp = False
269269
else:
270270
paddedWF = np.hstack((np.zeros(padLength,
271-
dtype=np.complex),
271+
dtype=np.complex128),
272272
wfLib[wf_sig(curEntry)]))
273273
# Generate a new key
274274
curEntry.key = hash_pulse(paddedWF)
@@ -291,12 +291,12 @@ def apply_min_pulse_constraints(miniLL, wfLib):
291291
elif curEntry.isTimeAmp: #non-zero
292292
paddedWF = np.hstack(
293293
(wfLib[curEntry.key] * np.ones(curEntry.length),
294-
np.zeros(padLength, dtype=np.complex)))
294+
np.zeros(padLength, dtype=np.complex128)))
295295
curEntry.isTimeAmp = False
296296
else:
297297
paddedWF = np.hstack((wfLib[curEntry.key],
298298
np.zeros(padLength,
299-
dtype=np.complex)))
299+
dtype=np.complex128)))
300300
# Generate a new key
301301
curEntry.key = hash_pulse(paddedWF)
302302
curEntry.length = paddedWF.size

0 commit comments

Comments
 (0)