Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix h5py deprecation warnings #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions labscript_devices/AlazarTechBoard.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def init(self):
def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
self.h5file = h5file # We'll need this in transition_to_manual
self.device_name = device_name
with h5py.File(h5file) as hdf5_file:
with h5py.File(h5file, 'r') as hdf5_file:
print("\nUsing "+h5file)
self.atsparam = atsparam = labscript_utils.properties.get(
hdf5_file, device_name, 'device_properties')
Expand Down Expand Up @@ -379,7 +379,7 @@ def transition_to_buffered(self, device_name, h5file, initial_values, fresh):

# Store the actual acquisition rate back as an attribute.
# Again, this should be done as an ACQUISITIONS table entry, but not today
with h5py.File(h5file) as hdf5_file:
with h5py.File(h5file, 'r+') as hdf5_file:
hdf5_file['devices'][device_name].attrs.create(
'acquisition_rate', actual_acquisition_rate, dtype='int32')

Expand Down Expand Up @@ -585,7 +585,7 @@ def transition_to_manual(self):
# Waits on the acquisition thread, and manages the lock
self.wait_acquisition_complete()
# Write data to HDF5 file
with h5py.File(self.h5file) as hdf5_file:
with h5py.File(self.h5file, 'r+') as hdf5_file:
grp = hdf5_file.create_group('/data/traces/'+self.device_name)
if self.channels & ats.CHANNEL_A:
dsetA = grp.create_dataset(
Expand Down
2 changes: 1 addition & 1 deletion labscript_devices/FunctionRunner/labscript_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def func(shot_context, t, ...):
recommended place to do it is within the group 'data/<device_name>', for
example:

with h5py.File(self.h5_file) as f:
with h5py.File(self.h5_file, 'r+') as f:
data_group = f['data'].create_group(self.device_name)
# save datasets/attributes within this group

Expand Down
2 changes: 1 addition & 1 deletion labscript_devices/IMAQdxCamera/blacs_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ def transition_to_manual(self):

print(f"Saving {len(self.images)}/{len(self.exposures)} images.")

with h5py.File(self.h5_filepath) as f:
with h5py.File(self.h5_filepath, 'r+') as f:
# Use orientation for image path, device_name if orientation unspecified
if self.orientation is not None:
image_path = 'images/' + self.orientation
Expand Down
2 changes: 1 addition & 1 deletion labscript_devices/LightCrafterDMD.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def program_manual(self, values):
return {}

def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
with h5py.File(h5file) as hdf5_file:
with h5py.File(h5file, 'r') as hdf5_file:
group = hdf5_file['/devices/'+device_name]
if 'IMAGE_TABLE' in group:
table_data = group['IMAGE_TABLE'][:]
Expand Down
2 changes: 1 addition & 1 deletion labscript_devices/NovaTechDDS9M.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def transition_to_buffered(self,device_name,h5file,initial_values,fresh):
self.final_values = {}
static_data = None
table_data = None
with h5py.File(h5file) as hdf5_file:
with h5py.File(h5file, 'r') as hdf5_file:
group = hdf5_file['/devices/'+device_name]
# If there are values to set the unbuffered outputs to, set them now:
if 'STATIC_DATA' in group:
Expand Down
2 changes: 1 addition & 1 deletion labscript_devices/PhaseMatrixQuickSyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ def transition_to_buffered(self,device_name,h5file,initial_values,fresh):
self.initial_values = initial_values
# Store the final values to for use during transition_to_static:
self.final_values = {}
with h5py.File(h5file) as hdf5_file:
with h5py.File(h5file, 'r') as hdf5_file:
group = hdf5_file['/devices/'+device_name]
# If there are values to set the unbuffered outputs to, set them now:
if 'STATIC_DATA' in group:
Expand Down
4 changes: 2 additions & 2 deletions labscript_devices/TekScope/blacs_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def init(self):
def transition_to_buffered(self, device_name, h5file, front_panel_values, refresh):
self.h5file = h5file # We'll need this in transition_to_manual
self.device_name = device_name
with h5py.File(h5file) as hdf5_file:
with h5py.File(h5file, 'r') as hdf5_file:
print('\n' + h5file)
self.scope_params = scope_params = labscript_utils.properties.get(
hdf5_file, device_name, 'device_properties')
Expand Down Expand Up @@ -53,7 +53,7 @@ def transition_to_manual(self):
data[ch] = vals[ch]

# Open the file after download so as not to hog the file lock
with h5py.File(self.h5file) as hdf_file:
with h5py.File(self.h5file, 'r+') as hdf_file:
grp = hdf_file.create_group('/data/traces')
print('Saving traces...')
dset = grp.create_dataset(self.device_name, data=data)
Expand Down
2 changes: 1 addition & 1 deletion labscript_devices/ZaberStageController/blacs_workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def program_manual(self, values):
return self.check_remote_values()

def transition_to_buffered(self, device_name, h5file, initial_values, fresh):
with h5py.File(h5file) as hdf5_file:
with h5py.File(h5file, 'r') as hdf5_file:
group = hdf5_file['/devices/' + device_name]
if 'static_values' in group:
data = group['static_values']
Expand Down
2 changes: 1 addition & 1 deletion labscript_devices/imaqdx_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ def transition_to_static(self, h5_filepath):
# # Just save the first however many we were expecting:
# self.imgs = self.imgs[:n_images]

with h5py.File(h5_filepath) as h5_file:
with h5py.File(h5_filepath, 'r+') as h5_file:
# Use orientation for image path, camera_name if orientation unspecified
if self.device_properties['orientation']:
image_path = self.image_path + _ensure_str(self.device_properties['orientation'])
Expand Down