From e2753404da89e8d324eeaa0f6f37baec1fdc4717 Mon Sep 17 00:00:00 2001 From: Francesc Alted Date: Mon, 20 Nov 2023 07:11:07 +0100 Subject: [PATCH] Slight simplification of examples --- examples/filler.py | 12 +++++------- examples/prefilter.py | 9 ++++----- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/examples/filler.py b/examples/filler.py index 31f07692..7f8b1e82 100644 --- a/examples/filler.py +++ b/examples/filler.py @@ -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 @@ -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) diff --git a/examples/prefilter.py b/examples/prefilter.py index 9f181ce6..e181d72b 100644 --- a/examples/prefilter.py +++ b/examples/prefilter.py @@ -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 @@ -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)