Skip to content
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: 0 additions & 6 deletions .flake8

This file was deleted.

8 changes: 3 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,9 @@ jobs:
with:
python-version: '3.12'
cache: 'pip'
- run: python -m pip install --upgrade pip bandit black build flake8 isort mypy numpy twine
- run: bandit -c pyproject.toml -r .
- run: black --check .
- run: flake8
- run: isort --check .
- run: python -m pip install --upgrade build mypy numpy pip ruff twine
- run: ruff format --check
- run: ruff check
- run: mypy
- run: python -m build --sdist
- run: python -m twine check dist/*
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ jobs:
with:
python-version: '3.12'
cache: 'pip'
- run: python -m pip install --upgrade pip bandit build twine
- run: bandit -c pyproject.toml -r .
- run: python -m pip install --upgrade build mypy numpy pip ruff twine
- run: ruff format --check
- run: ruff check
- run: mypy
- run: python -m build --sdist
- run: python -m twine check dist/*
- run: pip install --pre "$(ls dist/hdf5plugin*.tar.gz)[test]"
Expand Down
18 changes: 5 additions & 13 deletions doc/contribute.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,15 @@ Formatting/Linting

From the source directory:

* Format code with `black <https://black.readthedocs.io/>`_::
* To format the code, use `ruff format <https://docs.astral.sh/ruff/formatter/>`_::

black .
ruff format

* Sort imports with `isort <https://pycqa.github.io/isort/>`_::
* To check (lint) the code, use `ruff check <https://docs.astral.sh/ruff/linter/>`_::

isort .
ruff check

* Check code with `flake8 <https://flake8.pycqa.org/>`_::

flake8

* Check code with `bandit <https://bandit.readthedocs.io/>`_ security linter::

bandit -c pyproject.toml -r .

* Check typing with `mypy <https://mypy.readthedocs.io>`_::
* To check typing, use `mypy <https://mypy.readthedocs.io>`_::

mypy

Expand Down
37 changes: 23 additions & 14 deletions doc/hdf5plugin_EuropeanHUG2021.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@
"%matplotlib inline\n",
"\n",
"# Creates data.h5 used for demos\n",
"import urllib.request\n",
"\n",
"import numpy\n",
"from matplotlib import pyplot as plt\n",
"from PIL import Image\n",
"\n",
"import h5py\n",
"import hdf5plugin\n",
"import numpy\n",
"from PIL import Image\n",
"import urllib.request\n",
"\n",
"url = \"https://www.eiroforum.org/wp-content/uploads/pg-esrf-01.jpg\"\n",
"filename = urllib.request.urlretrieve(url)[0]\n",
Expand All @@ -67,7 +69,9 @@
"h5file[\"copyright\"] = \"P.Ginter/ESRF\"\n",
"h5file.attrs[\"url\"] = url\n",
"h5file.create_dataset(\"/data\", data=image)\n",
"h5file.create_dataset(\"/compressed_data_bitshuffle_lz4\", data=image, **hdf5plugin.Bitshuffle())\n",
"h5file.create_dataset(\n",
" \"/compressed_data_bitshuffle_lz4\", data=image, **hdf5plugin.Bitshuffle()\n",
")\n",
"h5file.close()\n",
"\n",
"# Restart kernel once the file is created!"
Expand Down Expand Up @@ -334,6 +338,7 @@
],
"source": [
"from h5glance import H5Glance # Browsing HDF5 files\n",
"\n",
"H5Glance(\"data.h5\")"
]
},
Expand Down Expand Up @@ -373,8 +378,9 @@
"import h5py # Pythonic HDF5 wrapper: https://docs.h5py.org/\n",
"\n",
"h5file = h5py.File(\"data.h5\", mode=\"r\") # Open HDF5 file in read mode\n",
"data = h5file[\"/data\"][()] # Access HDF5 dataset \"/data\"\n",
"plt.imshow(data); plt.colorbar() # Display data"
"data = h5file[\"/data\"][()] # Access HDF5 dataset \"/data\"\n",
"plt.imshow(data) # Display data\n",
"plt.colorbar()"
]
},
{
Expand Down Expand Up @@ -506,7 +512,8 @@
],
"source": [
"data = h5file[\"/compressed_data_bitshuffle_lz4\"][()] # Access datset\n",
"plt.imshow(data); plt.colorbar() # Display data"
"plt.imshow(data) # Display data\n",
"plt.colorbar()"
]
},
{
Expand Down Expand Up @@ -567,7 +574,7 @@
" \"/compressed_data_bitshuffle_lz4\",\n",
" data=data,\n",
" compression=32008, # bitshuffle/lz4 HDF5 filter identifier\n",
" compression_opts=(0, 2) # options: default number of elements/block, enable LZ4\n",
" compression_opts=(0, 2), # options: default number of elements/block, enable LZ4\n",
")\n",
"h5file.close()"
]
Expand Down Expand Up @@ -597,7 +604,7 @@
"h5file.create_dataset(\n",
" \"/compressed_data_bitshuffle_lz4\",\n",
" data=data,\n",
" **hdf5plugin.Bitshuffle() # Or: **hdf5plugin.BitShuffle(lz4=True)\n",
" **hdf5plugin.Bitshuffle(), # Or: **hdf5plugin.BitShuffle(lz4=True)\n",
")\n",
"h5file.close()"
]
Expand Down Expand Up @@ -847,7 +854,8 @@
],
"source": [
"h5file = h5py.File(\"new_file_bitshuffle_lz4.h5\", mode=\"r\")\n",
"plt.imshow(h5file[\"/compressed_data_bitshuffle_lz4\"][()]); plt.colorbar()\n",
"plt.imshow(h5file[\"/compressed_data_bitshuffle_lz4\"][()])\n",
"plt.colorbar()\n",
"h5file.close()"
]
},
Expand Down Expand Up @@ -914,7 +922,8 @@
"source": [
"h5file = h5py.File(\"new_file_shuffle_gzip.h5\", mode=\"w\")\n",
"h5file.create_dataset(\n",
" \"/compressed_data_shuffle_gzip\", data=data, shuffle=True, compression=\"gzip\")\n",
" \"/compressed_data_shuffle_gzip\", data=data, shuffle=True, compression=\"gzip\"\n",
")\n",
"h5file.close()"
]
},
Expand Down Expand Up @@ -947,7 +956,7 @@
"h5file.create_dataset(\n",
" \"/compressed_data_blosc\",\n",
" data=data,\n",
" **hdf5plugin.Blosc(cname='zlib', clevel=5, shuffle=hdf5plugin.Blosc.SHUFFLE)\n",
" **hdf5plugin.Blosc(cname=\"zlib\", clevel=5, shuffle=hdf5plugin.Blosc.SHUFFLE),\n",
")\n",
"h5file.close()"
]
Expand Down Expand Up @@ -1098,7 +1107,7 @@
}
],
"source": [
"!h5dump -d /compressed_data_bitshuffle_lz4 -s \"0,0\" -c \"5,10\" data.h5 "
"!h5dump -d /compressed_data_bitshuffle_lz4 -s \"0,0\" -c \"5,10\" data.h5"
]
},
{
Expand Down Expand Up @@ -1137,7 +1146,7 @@
"outputs": [],
"source": [
"# Retrieve hdf5plugin.PLUGINS_PATH from the command line\n",
"!python3 -c \"import hdf5plugin; print(hdf5plugin.PLUGINS_PATH)\" "
"!python3 -c \"import hdf5plugin; print(hdf5plugin.PLUGINS_PATH)\""
]
},
{
Expand Down
35 changes: 18 additions & 17 deletions doc/hdf5plugin_EuropeanHUG2022.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"source": [
"# Notebook requirements\n",
"# A recent version of Pillow is required!\n",
"#%pip install numpy h5py hdf5plugin h5glance rise jupyterlab matplotlib ipympl Pillow"
"# %pip install numpy h5py hdf5plugin h5glance rise jupyterlab matplotlib ipympl Pillow"
]
},
{
Expand All @@ -47,12 +47,14 @@
"%matplotlib inline\n",
"\n",
"# Creates data.h5 used for demos\n",
"import urllib.request\n",
"\n",
"import numpy\n",
"from matplotlib import pyplot as plt\n",
"from PIL import Image\n",
"\n",
"import h5py\n",
"import hdf5plugin\n",
"import numpy\n",
"from PIL import Image\n",
"import urllib.request\n",
"\n",
"url = \"https://www.iter.org/doc/www/content/com/Lists/WebText_2014/Attachments/236/platform_view_north_1.jpg\"\n",
"filename = urllib.request.urlretrieve(url)[0]\n",
Expand All @@ -66,7 +68,7 @@
"h5file.create_dataset(\n",
" \"/compressed_data\",\n",
" data=image,\n",
" **hdf5plugin.Blosc('lz4', shuffle=hdf5plugin.Blosc.BITSHUFFLE)\n",
" **hdf5plugin.Blosc(\"lz4\", shuffle=hdf5plugin.Blosc.BITSHUFFLE),\n",
")\n",
"h5file.close()"
]
Expand All @@ -93,6 +95,7 @@
"outputs": [],
"source": [
"import os\n",
"\n",
"os._exit(0) # Makes the kernel restart"
]
},
Expand All @@ -110,6 +113,7 @@
"%matplotlib inline\n",
"from matplotlib import pyplot as plt\n",
"\n",
"\n",
"def imshow(image):\n",
" plt.imshow(image)\n",
" plt.colorbar()"
Expand Down Expand Up @@ -360,6 +364,7 @@
],
"source": [
"from h5glance import H5Glance # Browsing HDF5 files\n",
"\n",
"H5Glance(\"data.h5\")"
]
},
Expand Down Expand Up @@ -389,8 +394,8 @@
"import h5py # Pythonic HDF5 wrapper: https://docs.h5py.org/\n",
"\n",
"h5file = h5py.File(\"data.h5\", mode=\"r\") # Open HDF5 file in read mode\n",
"data = h5file[\"/data\"][()] # Access HDF5 dataset \"/data\"\n",
"imshow(data) # Display data"
"data = h5file[\"/data\"][()] # Access HDF5 dataset \"/data\"\n",
"imshow(data) # Display data"
]
},
{
Expand Down Expand Up @@ -536,7 +541,7 @@
],
"source": [
"data = h5file[\"/compressed_data\"][()] # Access datset\n",
"imshow(data) # Display data"
"imshow(data) # Display data"
]
},
{
Expand Down Expand Up @@ -598,7 +603,7 @@
" data=data,\n",
" compression=32001, # blosc HDF5 filter identifier\n",
" # options: 0, 0, 0, 0, level, shuffle, compression\n",
" compression_opts=(0, 0, 0, 0, 5, 2, 1) \n",
" compression_opts=(0, 0, 0, 0, 5, 2, 1),\n",
")\n",
"h5file.close()"
]
Expand Down Expand Up @@ -628,10 +633,7 @@
"h5file.create_dataset(\n",
" \"/compressed_data\",\n",
" data=data,\n",
" **hdf5plugin.Blosc(\n",
" cname='lz4',\n",
" clevel=5,\n",
" shuffle=hdf5plugin.Blosc.BITSHUFFLE),\n",
" **hdf5plugin.Blosc(cname=\"lz4\", clevel=5, shuffle=hdf5plugin.Blosc.BITSHUFFLE),\n",
")\n",
"h5file.close()"
]
Expand Down Expand Up @@ -1071,7 +1073,8 @@
"source": [
"h5file = h5py.File(\"new_file_shuffle_gzip.h5\", mode=\"w\")\n",
"h5file.create_dataset(\n",
" \"/compressed_data_shuffle_gzip\", data=data, shuffle=True, compression=\"gzip\")\n",
" \"/compressed_data_shuffle_gzip\", data=data, shuffle=True, compression=\"gzip\"\n",
")\n",
"h5file.close()"
]
},
Expand Down Expand Up @@ -1102,9 +1105,7 @@
"source": [
"h5file = h5py.File(\"new_file_bitshuffle_lz4.h5\", mode=\"w\")\n",
"h5file.create_dataset(\n",
" \"/compressed_data_bitshuffle_lz4\",\n",
" data=data,\n",
" **hdf5plugin.Bitshuffle()\n",
" \"/compressed_data_bitshuffle_lz4\", data=data, **hdf5plugin.Bitshuffle()\n",
")\n",
"h5file.close()"
]
Expand Down
Loading
Loading