Skip to content

Commit f98d6a7

Browse files
authored
Merge pull request #103 from silx-kit/training_2022_11_21_pierre
Training 2022-11-21: HDF5
2 parents 4e3a351 + bebca08 commit f98d6a7

4 files changed

Lines changed: 14 additions & 32 deletions

File tree

python/io/io_hdf5.ipynb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -234,19 +234,6 @@
234234
"[h5py](https://www.h5py.org/) is the python binding for accessing HDF5 files. Originally from [Andrew Collette](http://shop.oreilly.com/product/0636920030249.do)"
235235
]
236236
},
237-
{
238-
"cell_type": "markdown",
239-
"metadata": {
240-
"slideshow": {
241-
"slide_type": "subslide"
242-
}
243-
},
244-
"source": [
245-
"**Warning**: A major version of h5py has been released at the end of 2020 (3.0).\n",
246-
"\n",
247-
"Some code might not be compatible with it yet (end of Python2 support, [interface for storing & reading strings has changed](https://docs.h5py.org/en/stable/strings.html)...)."
248-
]
249-
},
250237
{
251238
"cell_type": "code",
252239
"execution_count": null,
@@ -1116,7 +1103,7 @@
11161103
"metadata": {
11171104
"celltoolbar": "Slideshow",
11181105
"kernelspec": {
1119-
"display_name": "Python 3",
1106+
"display_name": "Python 3 (ipykernel)",
11201107
"language": "python",
11211108
"name": "python3"
11221109
},
@@ -1130,7 +1117,7 @@
11301117
"name": "python",
11311118
"nbconvert_exporter": "python",
11321119
"pygments_lexer": "ipython3",
1133-
"version": "3.7.3"
1120+
"version": "3.9.2"
11341121
},
11351122
"toc": {
11361123
"base_numbering": 1,

python/io/solutions/exercise1.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ def flatfield_correction(raw, flat, dark):
2424
def imshowmany(*args, **kwargs):
2525
"""
2626
Dispaly as image all array provided as argument.
27-
27+
2828
The image title is defined using the argument name.
2929
"""
3030
from matplotlib import pyplot
3131
if len(kwargs) == 0:
32-
import collections
33-
kwargs = collections.OrderedDict()
32+
kwargs = {}
3433
for i, arg in enumerate(args):
3534
if isinstance(arg, dict):
3635
kwargs.update(arg)
@@ -66,6 +65,6 @@ def solution():
6665
saved = h5out["result"][...]
6766
imshowmany(Before=raw, After=saved)
6867

69-
68+
7069
if __name__ == '__main__':
7170
solution()

python/io/solutions/exercise2.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@ def flatfield_correction(raw, flat, dark):
2323
def imshowmany(*args, **kwargs):
2424
"""
2525
Dispaly as image all array provided as argument.
26-
26+
2727
The image title is defined using the argument name.
2828
"""
2929
from matplotlib import pyplot
3030
if len(kwargs) == 0:
31-
import collections
32-
kwargs = collections.OrderedDict()
31+
kwargs = {}
3332
for i, arg in enumerate(args):
3433
if isinstance(arg, dict):
3534
kwargs.update(arg)
@@ -69,13 +68,12 @@ def solution():
6968
h5out[name] = normalized
7069

7170
# Check the saved result
72-
import collections
73-
result = collections.OrderedDict()
71+
result = {}
7472
with h5py.File("exercise2.h5", "r") as h5out:
7573
for name in h5out:
7674
result[name] = h5out[name][...]
7775
imshowmany(result)
7876

79-
77+
8078
if __name__ == '__main__':
81-
solution()
79+
solution()

python/io/solutions/exercise3.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,12 @@ def flatfield_correction(raw, flat, dark):
2424
def imshowmany(*args, **kwargs):
2525
"""
2626
Dispaly as image all array provided as argument.
27-
27+
2828
The image title is defined using the argument name.
2929
"""
3030
from matplotlib import pyplot
3131
if len(kwargs) == 0:
32-
import collections
33-
kwargs = collections.OrderedDict()
32+
kwargs = {}
3433
for i, arg in enumerate(args):
3534
if isinstance(arg, dict):
3635
kwargs.update(arg)
@@ -92,13 +91,12 @@ def solution():
9291
h5out[name] = normalized
9392

9493
# Check the saved result
95-
import collections
96-
result = collections.OrderedDict()
94+
result = {}
9795
with h5py.File("exercise3.h5", "r") as h5out:
9896
for name in h5out:
9997
result[name] = h5out[name][...]
10098
imshowmany(result)
10199

102-
100+
103101
if __name__ == '__main__':
104102
solution()

0 commit comments

Comments
 (0)