Skip to content
Snippets Groups Projects
Commit b7829860 authored by Leo Singer's avatar Leo Singer
Browse files

Fix deprecation warning by making h5py file mode explicit

Fix the following deprecation warning:

    H5pyDeprecationWarning: The default file mode will change to 'r'
    (read-only) in h5py 3.0. To suppress this warning, pass the mode
    you need to h5py.File(), or set the global default
    h5.get_config().default_file_mode, or set the environment
    variable H5PY_DEFAULT_READONLY=1. Available modes are: 'r', 'r+',
    'w', 'w-'/'x', 'a'. See the docs for details.
parent 989242bc
No related branches found
No related tags found
1 merge request!32Fix deprecation warning by making h5py file mode explicit
Pipeline #124643 passed
......@@ -159,7 +159,7 @@ def source_classification_pe(posterior_samples_file, hdf5=True,
(0.0, 0.0)
"""
if hdf5:
data = h5py.File(posterior_samples_file)
data = h5py.File(posterior_samples_file, 'r')
engine = list(data['lalinference'].keys())[0]
samples = data['lalinference'][engine]['posterior_samples'][()]
mc_det_frame = samples['mc']
......
......@@ -11,7 +11,7 @@ from .. import em_bright
def test_source_classification_pe():
with NamedTemporaryFile() as f:
filename = f.name
with h5py.File(f) as tmp_h5:
with h5py.File(f, 'w') as tmp_h5:
data = np.array([(1.2, 1.0, 0.0, 0.0, 100.0), (2.0, 0.5, 0.99, 0.99, 150.0)],
dtype=[('mc', '<f8'), ('q', '<f8'),
('a1', '<f8'), ('a2', '<f8'), ('dist', '<f8')])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment