Skip to content

Commit 26a0e81

Browse files
remove_workaround: Depend on numpy 1.5.1 and remove use of workarounds requried for earlier
numpy versions.
1 parent e00eb93 commit 26a0e81

File tree

6 files changed

+12
-18
lines changed

6 files changed

+12
-18
lines changed

AlazarTechBoard.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@
1818
# or keep in local directory.
1919
import labscript_devices.atsapi as ats
2020

21-
# Workaround for compound dtypes (numpy issue #10672)
22-
from labscript_utils.numpy_dtype_workaround import dtype_workaround
23-
2421
# TDQM progress indicator defaults
2522
tqdm_kwargs = {'file': sys.stdout, 'ascii': False, 'ncols': 80}
2623

@@ -165,7 +162,7 @@ def generate_code(self, hdf5_file):
165162
acquisitions_table_dtypes = [('connection', 'a256'), ('label', 'a256'), ('start', float),
166163
('stop', float), ('wait label', 'a256'), ('scale factor', float), ('units', 'a256')]
167164
acquisition_table = np.empty(
168-
len(acquisitions), dtype=dtype_workaround(acquisitions_table_dtypes))
165+
len(acquisitions), dtype=acquisitions_table_dtypes)
169166
for i, acq in enumerate(acquisitions):
170167
acquisition_table[i] = acq
171168
grp = self.init_device_group(hdf5_file)
@@ -216,11 +213,11 @@ def find_clock_and_r(f, clocks):
216213
# that exceeds the requested frequency f.
217214
divisors, remainders = divmod(clocks, f)
218215
opts_dtypes = [('rem', 'i4'), ('div', 'i4'), ('clock', 'i4')]
219-
opts = np.array(list(zip(remainders, divisors, clocks)), dtype=dtype_workaround(opts_dtypes))
220-
opts.sort(order=b'rem' if PY2 else 'rem')
216+
opts = np.array(list(zip(remainders, divisors, clocks)), dtype=opts_dtypes)
217+
opts.sort(order='rem')
221218
minrem = opts['rem'][0]
222219
# This gets the option with minimum remainder and maximum divisor
223-
bestopt = np.sort(opts[opts['rem'] == minrem], order=b'div' if PY2 else 'div')[-1]
220+
bestopt = np.sort(opts[opts['rem'] == minrem], order='div')[-1]
224221
return bestopt['clock'], bestopt['div']
225222

226223

DummyIntermediateDevice.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
from labscript_devices import labscript_device, BLACS_tab, BLACS_worker
3030
from labscript import IntermediateDevice, DigitalOut, AnalogOut, config
31-
from labscript_utils.numpy_dtype_workaround import dtype_workaround
3231
import numpy as np
3332

3433
@labscript_device
@@ -62,7 +61,7 @@ def generate_code(self, hdf5_file):
6261
dtypes.append((device.name, device_dtype))
6362

6463
# create dataset
65-
out_table = np.zeros(len(times), dtype=dtype_workaround(dtypes))
64+
out_table = np.zeros(len(times), dtype=dtypes)
6665
for device in self.child_devices:
6766
out_table[device.name][:] = device.raw_output
6867

PulseBlaster.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
str = unicode
1717

1818
from labscript_devices import BLACS_tab, runviewer_parser
19-
from labscript_utils.numpy_dtype_workaround import dtype_workaround
2019

2120
from labscript import Device, PseudoclockDevice, Pseudoclock, ClockLine, IntermediateDevice, DigitalQuantity, DigitalOut, DDS, config, LabscriptError, set_passed_properties
2221

@@ -548,7 +547,7 @@ def write_pb_inst_to_h5(self, pb_inst, hdf5_file):
548547
('dds_en1', np.int32), ('phase_reset1', np.int32),
549548
('flags', np.int32), ('inst', np.int32),
550549
('inst_data', np.int32), ('length', np.float64)]
551-
pb_inst_table = np.empty(len(pb_inst),dtype = dtype_workaround(pb_dtype))
550+
pb_inst_table = np.empty(len(pb_inst),dtype = pb_dtype)
552551
for i,inst in enumerate(pb_inst):
553552
flagint = int(inst['flags'][::-1],2)
554553
instructionint = self.pb_instructions[inst['instruction']]

PulseBlaster_No_DDS.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
if PY2:
1616
str = unicode
1717

18-
from labscript_utils.numpy_dtype_workaround import dtype_workaround
1918
from labscript_devices import BLACS_tab, runviewer_parser
2019
from labscript_devices.PulseBlaster import PulseBlaster, PulseBlasterParser
2120
from labscript import PseudoclockDevice, config
@@ -34,7 +33,7 @@ class PulseBlaster_No_DDS(PulseBlaster):
3433

3534
def write_pb_inst_to_h5(self, pb_inst, hdf5_file):
3635
# OK now we squeeze the instructions into a numpy array ready for writing to hdf5:
37-
pb_dtype= dtype_workaround([('flags',np.int32), ('inst',np.int32), ('inst_data',np.int32), ('length',np.float64)])
36+
pb_dtype= [('flags',np.int32), ('inst',np.int32), ('inst_data',np.int32), ('length',np.float64)]
3837
pb_inst_table = np.empty(len(pb_inst),dtype = pb_dtype)
3938
for i,inst in enumerate(pb_inst):
4039
flagint = int(inst['flags'][::-1],2)

RFBlaster.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from labscript import PseudoclockDevice, Pseudoclock, ClockLine, IntermediateDevice, DDS, config, startupinfo, LabscriptError, set_passed_properties
2020
import numpy as np
2121

22-
from labscript_utils.numpy_dtype_workaround import dtype_workaround
2322
from labscript_devices import BLACS_tab, runviewer_parser
2423

2524
# Define a RFBlasterPseudoclock that only accepts one child clockline
@@ -93,7 +92,7 @@ def generate_code(self, hdf5_file):
9392

9493
# Generate clock and save raw instructions to the h5 file:
9594
PseudoclockDevice.generate_code(self, hdf5_file)
96-
dtypes = dtype_workaround([('time',float),('amp0',float),('freq0',float),('phase0',float),('amp1',float),('freq1',float),('phase1',float)])
95+
dtypes = [('time',float),('amp0',float),('freq0',float),('phase0',float),('amp1',float),('freq1',float),('phase1',float)]
9796

9897
times = self.pseudoclock.times[self._clock_line]
9998

@@ -108,9 +107,9 @@ def generate_code(self, hdf5_file):
108107
group.create_dataset('TABLE_DATA',compression=config.compression, data=data)
109108

110109
# Quantise the data and save it to the h5 file:
111-
quantised_dtypes = dtype_workaround([('time',np.int64),
110+
quantised_dtypes = [('time',np.int64),
112111
('amp0',np.int32), ('freq0',np.int32), ('phase0',np.int32),
113-
('amp1',np.int32), ('freq1',np.int32), ('phase1',np.int32)])
112+
('amp1',np.int32), ('freq1',np.int32), ('phase1',np.int32)]
114113

115114
quantised_data = np.zeros(len(times),dtype=quantised_dtypes)
116115
quantised_data['time'] = np.array(c.tT*1e6*data['time']+0.5)

__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@
1919
import traceback
2020
import inspect
2121

22-
__version__ = '2.2.0'
22+
__version__ = '2.3.0'
2323

2424
check_version('qtutils', '2.0.0', '3.0.0')
2525
check_version('labscript', '2.1', '3')
2626
check_version('blacs', '2.4.0', '3.0.0')
2727
check_version('zprocess', '2.2.7', '3')
28+
check_version('numpy', '1.5.1', '2')
2829

2930
from labscript_utils import labscript_suite_install_dir, dedent
3031

0 commit comments

Comments
 (0)