GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit b44a4210 authored by payno's avatar payno

Merge branch 'h5py_3_compatibility' into 'master'

H5py 3 compatibility

See merge request !28
parents d520e59c d0965139
Pipeline #36657 passed with stages
in 14 minutes and 29 seconds
......@@ -19,7 +19,6 @@ check_style:
before_script:
- pip install black
script:
- pip install -r requirements.txt
# run black
- LC_ALL=C.UTF-8 black --check --safe .
......@@ -34,12 +33,14 @@ doc:
- arch
- which python
- python --version
- source ./ci/install_scripts.sh
- python -m pip install pip --upgrade
- python -m pip install setuptools --upgrade
- python -m pip install sphinx
- python -m pip install nbsphinx
- python -m pip install nbconvert
- python -m pip install pandoc
- install_silx
- python -m pip install -r requirements.txt
- rm -rf artifacts
- mkdir artifacts
......@@ -66,8 +67,10 @@ doc:
- export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/:${LD_LIBRARY_PATH}
- export ORANGE_WEB_LOG='False'
- python --version
- source ./ci/install_scripts.sh
- python -m pip install pip --upgrade
- python -m pip install setuptools --upgrade
- install_silx
- python -m pip install -r requirements.txt
- python -m pip install .
script:
......@@ -95,6 +98,7 @@ test:test-tomoscan-tutorials:
- export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu/:${LD_LIBRARY_PATH}
- export ORANGE_WEB_LOG='False'
- python --version
- source ./ci/install_scripts.sh
- python -m pip install pip --upgrade
- python -m pip install setuptools --upgrade
- python -m pip install numpy --upgrade
......@@ -103,6 +107,7 @@ test:test-tomoscan-tutorials:
- python -m pip install nbconvert
- python -m pip install pandoc
- python -m pip install ipykernel
- install_silx
- python -m pip install -r requirements.txt
- python -m pip install fabio --upgrade --pre
- python -m pip install silx --upgrade --pre
......
#!/bin/bash
function install_silx(){
if [ "$2" = 'latest' ]; then
python -m install silx
else
python -m pip install git+https://github.com/silx-kit/silx.git
fi
}
function silx_version(){
python -c 'import silx; print(silx.version)'
}
silx>=0.9
# silx>=0.14
lxml
numpy
\ No newline at end of file
......@@ -321,7 +321,7 @@ def get_project_configuration(dry_run):
install_requires = [
# for the script launcher and pkg_resources
"setuptools",
"silx>=0.9",
"silx>=0.14a",
"lxml",
]
......
......@@ -43,6 +43,7 @@ from tomoscan.io import HDF5File
from silx.io.utils import get_data
from ..unitsystem import metricsystem
from .utils import get_compacted_dataslices
from silx.io.utils import h5py_read_dataset
import typing
import logging
......@@ -443,7 +444,9 @@ class HDF5TomoScan(TomoScanBase):
if self._rotation_angles is None:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r", swmr=True) as h5_file:
_rotation_angles = h5_file[self._entry][self._ROTATION_ANGLE_PATH][()]
_rotation_angles = h5py_read_dataset(
h5_file[self._entry][self._ROTATION_ANGLE_PATH]
)
# cast in float
self._rotation_angles = tuple(
[float(angle) for angle in _rotation_angles]
......@@ -455,7 +458,9 @@ class HDF5TomoScan(TomoScanBase):
if self._entry and self._image_keys is None:
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r", swmr=True) as h5_file:
self._image_keys = h5_file[self._entry][self._IMG_KEY_PATH][()]
self._image_keys = h5py_read_dataset(
h5_file[self._entry][self._IMG_KEY_PATH]
)
return self._image_keys
@property
......@@ -464,9 +469,9 @@ class HDF5TomoScan(TomoScanBase):
self._check_hdf5scan_validity()
with HDF5File(self.master_file, "r", swmr=True) as h5_file:
if self._IMG_KEY_CONTROL_PATH in h5_file[self._entry]:
self._image_keys_control = h5_file[self._entry][
self._IMG_KEY_CONTROL_PATH
][()]
self._image_keys_control = h5py_read_dataset(
h5_file[self._entry][self._IMG_KEY_CONTROL_PATH]
)
else:
self._image_keys_control = None
return self._image_keys_control
......@@ -563,7 +568,7 @@ class HDF5TomoScan(TomoScanBase):
def _get_fov(self):
with HDF5File(self.master_file, "r", swmr=True, libver="latest") as h5_file:
if self._FOV_PATH in h5_file[self._entry]:
fov = h5_file[self._entry][self._FOV_PATH][()]
fov = h5py_read_dataset(h5_file[self._entry][self._FOV_PATH])
return _FOV.from_value(fov)
else:
return None
......@@ -571,7 +576,9 @@ class HDF5TomoScan(TomoScanBase):
def _get_estimated_cor_frm_motor(self):
with HDF5File(self.master_file, "r", swmr=True, libver="latest") as h5_file:
if self._ESTIMATED_COR_FRM_MOTOR_PATH in h5_file[self._entry]:
value = h5_file[self._entry][self._ESTIMATED_COR_FRM_MOTOR_PATH][()]
value = h5py_read_dataset(
h5_file[self._entry][self._ESTIMATED_COR_FRM_MOTOR_PATH]
)
return float(value)
else:
return None
......@@ -776,7 +783,7 @@ class HDF5TomoScan(TomoScanBase):
Unit can be defined in on of the group attributes. It it is the case
will pick this unit, otherwise will use the default unit
"""
value = node[()]
value = h5py_read_dataset(node)
if "unit" in node.attrs:
unit = node.attrs["unit"]
elif "units" in node.attrs:
......
......@@ -36,6 +36,7 @@ from xml.etree import cElementTree
import fabio
import fabio.edfimage
from .hdf5scan import ImageKey, HDF5TomoScan
from silx.io.utils import h5py_read_dataset
class _ScanMock:
......@@ -293,7 +294,7 @@ class MockHDF5(_ScanMock):
# add data
if "data" in detector_grp:
# read and remove data
current_dataset = detector_grp["data"][()]
current_dataset = h5py_read_dataset(detector_grp["data"])
new_dataset = numpy.append(current_dataset, data_)
del detector_grp["data"]
shape = list(current_dataset.shape)
......@@ -304,7 +305,7 @@ class MockHDF5(_ScanMock):
# add rotation angle
if "rotation_angle" in sample_grp:
new_rot_angle = sample_grp["rotation_angle"][()]
new_rot_angle = h5py_read_dataset(sample_grp["rotation_angle"])
new_rot_angle = numpy.append(new_rot_angle, rotation_angle)
del sample_grp["rotation_angle"]
else:
......@@ -314,7 +315,7 @@ class MockHDF5(_ScanMock):
# add image_key
if "image_key" in detector_grp:
new_image_key = detector_grp["image_key"][()]
new_image_key = h5py_read_dataset(detector_grp["image_key"])
new_image_key = numpy.append(new_image_key, image_key)
del detector_grp["image_key"]
else:
......@@ -324,7 +325,9 @@ class MockHDF5(_ScanMock):
# add image_key_control
if "image_key_control" in detector_grp:
new_image_key_control = detector_grp["image_key_control"][()]
new_image_key_control = h5py_read_dataset(
detector_grp["image_key_control"]
)
new_image_key_control = numpy.append(
new_image_key_control, image_key_control
)
......@@ -336,7 +339,7 @@ class MockHDF5(_ScanMock):
# add count_time
if "count_time" in detector_grp:
new_count_time = detector_grp["count_time"][()]
new_count_time = h5py_read_dataset(detector_grp["count_time"])
new_count_time = numpy.append(new_count_time, self._PROJ_COUNT)
del detector_grp["count_time"]
else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment