Skip to content

Commit 74f7be3

Browse files
committed
Fix a few "errors" reported by ruff
1 parent 7885002 commit 74f7be3

4 files changed

Lines changed: 27 additions & 26 deletions

File tree

‎caterva2/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
__all__ = [
1818
"BasicAuth",
1919
"Client",
20-
"Root",
21-
"File",
2220
"Dataset",
21+
"File",
22+
"Root",
2323
"sub_urlbase_default",
2424
]
2525
"""List of symbols exported by the Caterva2 package."""

‎caterva2/tests/test_api.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ def test_append(auth_client, fields, fill_auth, examples_dir):
297297
if not auth_client:
298298
return pytest.skip("authentication support needed")
299299

300-
fnames, mypublic = fill_auth
300+
_, mypublic = fill_auth
301301
myshared = auth_client.get("@shared")
302302
fname = "ds-1d.b2nd" if not fields else "ds-1d-fields.b2nd"
303303
# Copy a 1d dataset to the shared area

‎caterva2/tests/test_hdf5_proxy.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_expression(expression, examples_dir, tmp_path, auth_client):
313313
root = pathlib.Path("@shared")
314314
remote_root = auth_client.get(root)
315315
with contextlib.chdir(tmp_path):
316-
hdf5_path, remote_dir, file_list = create_and_unfold_hdf5(tmp_path, remote_root)
316+
hdf5_path, remote_dir, _ = create_and_unfold_hdf5(tmp_path, remote_root)
317317
h5f = h5py.File(hdf5_path, "r")
318318
remote_a = remote_dir / (ds_a + ".b2nd")
319319
assert remote_a in remote_root

‎test-images/encode-grok-numbers.py‎

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@
1111
Script for exporting a series of images into a Blosc2 HDF5 file using the Grok codec.
1212
"""
1313

14+
import os
15+
16+
import blosc2
1417
import blosc2_grok
1518
import h5py
1619
import hdf5plugin
1720
import numpy as np
1821
from PIL import Image
19-
import os
20-
21-
import blosc2
2222

23-
if __name__ == '__main__':
23+
if __name__ == "__main__":
2424
# Define the compression and decompression parameters. Disable the filters and the
2525
# splitmode, because these don't work with the codec.
2626
cparams = {
27-
'codec': blosc2.Codec.GROK,
28-
'nthreads': 1,
29-
'filters': [],
30-
'splitmode': blosc2.SplitMode.NEVER_SPLIT,
27+
"codec": blosc2.Codec.GROK,
28+
"nthreads": 1,
29+
"filters": [],
30+
"splitmode": blosc2.SplitMode.NEVER_SPLIT,
3131
}
3232
# Set the parameters that will be used by grok
3333
kwargs = {
34-
'cod_format': blosc2_grok.GrkFileFmt.GRK_FMT_JP2,
35-
'num_threads': 1, # this does not have any effect (grok should work in multithreading mode)
36-
'quality_mode': "rates",
34+
"cod_format": blosc2_grok.GrkFileFmt.GRK_FMT_JP2,
35+
"num_threads": 1, # this does not have any effect (grok should work in multithreading mode)
36+
"quality_mode": "rates",
3737
}
3838

3939
# Compression params for identifying the codec. In the future, one should be able to
4040
# specify the grok plugin (and its parameters) here.
4141
b2params = hdf5plugin.Blosc2()
4242

4343
# Open the PNG datasets
44-
dir_path = 'numbers'
44+
dir_path = "numbers"
4545
# List of PNG files (in order)
4646
png_files = [
4747
"zero.png",
@@ -62,30 +62,31 @@
6262
img_color = Image.open(os.path.join(dir_path, png_file))
6363
images_color.append(np.array(img_color))
6464
# Convert the image to grayscale
65-
img_gray = img_color.convert('L')
65+
img_gray = img_color.convert("L")
6666
images_gray.append(np.array(img_gray))
6767
dset_color = np.array(images_color)
6868
dset_gray = np.array(images_gray)
6969

7070
# Open the output file for color and gray images
71-
fname = f'numbers-jpeg2000.h5'
71+
fname = "numbers-jpeg2000.h5"
7272
print(f"output file: {fname}")
73-
fout = h5py.File(fname, 'w')
73+
fout = h5py.File(fname, "w")
7474

7575
for cratio in (2, 5, 10, 20):
7676
print(f"Compressing with cratio={cratio}x ...")
77-
kwargs['quality_layers'] = np.array([cratio], dtype=np.float64)
77+
kwargs["quality_layers"] = np.array([cratio], dtype=np.float64)
7878
blosc2_grok.set_params_defaults(**kwargs)
79-
group = fout.create_group(f'/cratio_{cratio}x')
79+
group = fout.create_group(f"/cratio_{cratio}x")
8080
# Store the color and grey images
8181
for dset in [dset_color, dset_gray]:
8282
chunks = (1,) + dset.shape[1:]
83-
name = 'numbers_color' if dset is dset_color else 'numbers_gray'
84-
disk_dset = group.create_dataset(name, shape=dset.shape, dtype=dset.dtype,
85-
chunks=chunks, **b2params)
86-
disk_dset.attrs['contenttype'] = 'tomography'
83+
name = "numbers_color" if dset is dset_color else "numbers_gray"
84+
disk_dset = group.create_dataset(
85+
name, shape=dset.shape, dtype=dset.dtype, chunks=chunks, **b2params
86+
)
87+
disk_dset.attrs["contenttype"] = "tomography"
8788
for i in range(dset.shape[0]):
88-
im = dset[i:i+1]
89+
im = dset[i : i + 1]
8990
b2im = blosc2.asarray(im, chunks=im.shape, blocks=im.shape, cparams=cparams)
9091
# Write to disk.
9192
# Due to leading 1 dim, color images have 4 dimensions, gray images have 3 dimensions

0 commit comments

Comments
 (0)