Skip to content

Commit

Permalink
Slight simplification of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
FrancescAlted committed Nov 20, 2023
1 parent 63ea3ce commit e275340
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
12 changes: 5 additions & 7 deletions examples/filler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# LICENSE file in the root directory of this source tree)
#######################################################################

# Fill an SChunk with a filler decorator

import numpy as np

import blosc2
Expand All @@ -14,15 +16,11 @@
chunk_len = 200 * 1000
schunk_dtype = np.dtype(np.float64)

# Set the compression and decompression parameters
cparams = {"codec": blosc2.Codec.LZ4, "typesize": schunk_dtype.itemsize, "nthreads": 1}
dparams = {"nthreads": 4}
contiguous = True
urlpath = None
storage = {"contiguous": contiguous, "urlpath": urlpath, "cparams": cparams, "dparams": dparams}
# Set the compression parameters. We need nthreads=1 for this example.
cparams = {"typesize": schunk_dtype.itemsize, "nthreads": 1}

# Create empty SChunk
schunk = blosc2.SChunk(chunksize=chunk_len * schunk_dtype.itemsize, **storage)
schunk = blosc2.SChunk(chunksize=chunk_len * schunk_dtype.itemsize, cparams=cparams)

# Create operands (can be a SChunk, numpy.ndarray or Python scalar)
op_dtype = np.dtype(np.int32)
Expand Down
9 changes: 4 additions & 5 deletions examples/prefilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
# LICENSE file in the root directory of this source tree)
#######################################################################

# Example of prefiltering data before compression

import numpy as np

import blosc2
Expand All @@ -15,12 +17,9 @@
output_dtype = np.dtype(np.float32)

# Set the compression and decompression parameters
cparams = {"codec": blosc2.Codec.LZ4, "typesize": 4, "nthreads": 1}
cparams = {"typesize": 4, "nthreads": 1}
dparams = {"nthreads": 4}
contiguous = True
urlpath = None
storage = {"contiguous": contiguous, "urlpath": urlpath, "cparams": cparams, "dparams": dparams}

storage = {"cparams": cparams, "dparams": dparams}
# Create empty schunk
schunk = blosc2.SChunk(chunksize=200 * 1000 * input_dtype.itemsize, **storage)

Expand Down

0 comments on commit e275340

Please sign in to comment.