Skip to content

Commit

Permalink
Merge pull request #296 from DimitriPapadopoulos/ruff
Browse files Browse the repository at this point in the history
Apply Ruff rules to please pre-commit
  • Loading branch information
FrancescAlted authored Nov 1, 2024
2 parents fc274b4 + 75236e2 commit 0fd95f9
Show file tree
Hide file tree
Showing 98 changed files with 201 additions and 103 deletions.
3 changes: 2 additions & 1 deletion examples/btune.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
# https://github.com/Blosc/blosc2_btune/blob/main/README.md
#######################################################################

import blosc2
import blosc2_btune
import numpy as np

import blosc2

nchunks = 10
# Set the compression and decompression parameters, use BTUNE tuner
cparams = blosc2.CParams(codec=blosc2.Codec.LZ4HC, typesize=4, tuner=blosc2.Tuner.BTUNE)
Expand Down
3 changes: 2 additions & 1 deletion examples/compress2_decompress2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
# LICENSE file in the root directory of this source tree)
#######################################################################

import blosc2
import numpy as np

import blosc2

a = np.linspace(0, 1, 1_000_000, dtype=np.float64)
typesize = a.dtype.itemsize
c_bytesobj = blosc2.compress2(
Expand Down
3 changes: 2 additions & 1 deletion examples/filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Fill an SChunk with a filler decorator

import blosc2
import numpy as np

import blosc2

nchunks = 3
chunk_len = 200 * 1000
schunk_dtype = np.dtype(np.float64)
Expand Down
3 changes: 2 additions & 1 deletion examples/mmap-rw.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

# Example for writing and reading memory-mapped files

import blosc2
import numpy as np

import blosc2

urlpath = "array.b2nd"
blosc2.remove_urlpath(urlpath)
a = np.arange(1_000_000, dtype=np.int64)
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/asarray_.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Import structured arrays using the array interface

import blosc2
import numpy as np

import blosc2

shape = (2, 2)
dtype = np.float64

Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/broadcast_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
# This shows how to evaluate expressions with NDArray instances having different shapes as operands.
# The broadcast is done internally and tries to mimic NumPy behavior.

import blosc2
import numpy as np

import blosc2

# Two operands with the next shapes should be supported
# shape1, shape2 = (2, 1, 3, 2), (3, 3, 2)
# shape1, shape2 = (2, 1, 3, 2), (3, 1, 2)
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Creating/dumping an NDArray from/to a buffer

import blosc2
import numpy as np

import blosc2

shape = (50, 50)
chunks = (49, 49)
dtype = np.dtype("|S8")
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/bytedelta_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@

import math

import blosc2
import numpy as np

import blosc2

shape = (1000, 1000)

# Create a buffer
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/c2array_expr.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import pathlib

import blosc2
import numpy as np

import blosc2

host = "https://demo.caterva2.net/"
root = "b2tests"
dir = "expr/"
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/compute_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# This shows how to evaluate expressions with NDArray instances as operands.

import blosc2
import numpy as np

import blosc2

shape = (50, 50)

# Create a NDArray from a NumPy array
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/compute_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# This shows how to evaluate expressions with NDField instances as operands.

import blosc2
import numpy as np

import blosc2

shape = (50, 50)

# Create a structured NumPy array
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/compute_udf_numba.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@

# This shows how to evaluate expressions with NDArray instances as operands.

import blosc2
import numba as nb
import numpy as np

import blosc2


# The UDF to be evaluated
@nb.jit(nopython=True, parallel=True)
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/compute_where.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# This shows how to evaluate expressions in combination with the where() functionality.

import blosc2
import numpy as np

import blosc2

shape = (50, 50)
chunks = (10, 10)
blocks = (5, 5)
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/copy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Copying NDArrays

import blosc2
import numpy as np

import blosc2

shape = (10, 10)
blocks = (10, 10)
dtype = np.float64
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/formats.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

from time import time

import blosc2
import numpy as np

import blosc2

urlpath_sparse = "ex_formats_sparse.b2nd"
urlpath_contiguous = "ex_formats_contiguous.b2nd"

Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/general_expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# This shows how to build expressions with a general mix of NDArray and NumPy operands.

import blosc2
import numpy as np

import blosc2

shape = (50, 50)

# Create a NDArray from a NumPy array
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/getitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Show how getitem / setitem works for an NDArray

import blosc2
import numpy as np

import blosc2

shape = (10, 10)
slices = (slice(2, 7), slice(4, 8))

Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Store metadata in persistent arrays

import blosc2
import numpy as np

import blosc2

shape = (128, 128)
urlpath = "ex_meta.b2nd"
dtype = np.complex128
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/ndarray_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Copying NDArrays

import blosc2
import numpy as np

import blosc2

shape = (10, 10)
blocks = (10, 10)
dtype = np.float64
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/ndmean.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#######################################################################


import blosc2
import numpy as np

import blosc2

shape = (50, 50)
chunks = (49, 49)
dtype = np.float64
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/persistency.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Shows how you can persist an array on disk

import blosc2
import numpy as np

import blosc2

shape = (128, 128)
urlpath = "ex_persistency.b2nd"
dtype = np.complex128
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/reduce_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# This shows how to evaluate expressions with NDArray instances as operands.

import blosc2
import numpy as np

import blosc2

shape = (10, 10, 2)

# Create a NDArray from a NumPy array
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/reduce_expr_save.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# This shows how to evaluate expressions with NDArray instances as operands.

import blosc2
import numpy as np

import blosc2

shape = (10, 1, 2)

# Create a NDArray from a NumPy array
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/reduce_string_expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# This shows how to evaluate expressions with NDArray instances as operands.

import blosc2
import numpy as np

import blosc2

shape = (10, 10, 2)

# Create a NDArray from a NumPy array
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/work_with_numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Shows how you can easily convert from/to NumPy arrays

import blosc2
import numpy as np

import blosc2

shape = (1234, 23)
chunks = (253, 23)
dtype = bool
Expand Down
3 changes: 2 additions & 1 deletion examples/ndarray/zfp_codec.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#######################################################################


import blosc2
import numpy as np

import blosc2

shape = (50, 50)
chunks = (49, 49)
dtype = np.float64
Expand Down
3 changes: 2 additions & 1 deletion examples/pack_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@


# A simple example using the pack and unpack functions
import blosc2
import numpy as np

import blosc2

a = np.array(["å", "ç", "ø"])
parray = blosc2.pack(a, 9)
a2 = blosc2.unpack(parray)
Expand Down
3 changes: 2 additions & 1 deletion examples/pack_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

# A simple example using the pack_tensor and unpack_tensor functions

import blosc2
import numpy as np

import blosc2

a = np.arange(1_000_000)

cparams = blosc2.CParams(
Expand Down
3 changes: 2 additions & 1 deletion examples/postfilter1.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
# LICENSE file in the root directory of this source tree)
#######################################################################

import blosc2
import numpy as np

import blosc2

nchunks = 5
input_dtype = np.dtype(np.int32)
output_dtype = np.dtype(np.float32)
Expand Down
3 changes: 2 additions & 1 deletion examples/postfilter2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
# LICENSE file in the root directory of this source tree)
#######################################################################

import blosc2
import numpy as np

import blosc2

nchunks = 10
input_dtype = np.dtype("M8[D]")
output_dtype = np.int64 # output dtype has to be of the same size as input
Expand Down
3 changes: 2 additions & 1 deletion examples/postfilter3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
# LICENSE file in the root directory of this source tree)
#######################################################################

import blosc2
import numpy as np

import blosc2

nchunks = 10
input_dtype = np.dtype(np.int64)

Expand Down
3 changes: 2 additions & 1 deletion examples/prefilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@

# Example of prefiltering data before compression

import blosc2
import numpy as np

import blosc2

nchunks = 3
input_dtype = np.dtype(np.int32)
output_dtype = np.dtype(np.float32)
Expand Down
3 changes: 2 additions & 1 deletion examples/save_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

# A simple example using the save_tensor and load_tensor functions

import blosc2
import numpy as np

import blosc2

a = np.arange(1_000_000)

file_size = blosc2.save_tensor(a, "save_tensor.bl2", mode="w")
Expand Down
Loading

0 comments on commit 0fd95f9

Please sign in to comment.