Skip to content

Commit

Permalink
Merge pull request #278 from omaech/updating-examples
Browse files Browse the repository at this point in the history
Update of the Initialization of CParams, DParams, and Storage in Blosc2
  • Loading branch information
FrancescAlted authored Oct 10, 2024
2 parents a4493f4 + c71f8c6 commit 3da7003
Show file tree
Hide file tree
Showing 29 changed files with 623 additions and 655 deletions.
8 changes: 4 additions & 4 deletions bench/get_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

nchunks = shape // chunksize
# Set the compression and decompression parameters
cparams = {"codec": blosc2.Codec.BLOSCLZ, "typesize": 8, "blocksize": blocksize * 8}
dparams = {}
cparams = blosc2.CParams(codec=blosc2.Codec.BLOSCLZ, typesize=8, blocksize=blocksize * 8)
dparams = blosc2.DParams()
contiguous = True
persistent = bool(sys.argv[1]) if len(sys.argv) > 1 else False

Expand All @@ -32,11 +32,11 @@
else:
urlpath = None

storage = {"contiguous": contiguous, "urlpath": urlpath, "cparams": cparams, "dparams": dparams}
storage = blosc2.Storage(contiguous=contiguous, urlpath=urlpath)
blosc2.remove_urlpath(urlpath)

# Create the empty SChunk
schunk = blosc2.SChunk(chunksize=chunksize * cparams["typesize"], **storage)
schunk = blosc2.SChunk(chunksize=chunksize * cparams.typesize, storage=storage, cparams=cparams, dparams=dparams)

# Append some chunks
for i in range(nchunks):
Expand Down
16 changes: 8 additions & 8 deletions bench/ndarray/compare_getslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@
cname = "zstd"
nthreads = 8
filter = blosc2.Filter.SHUFFLE
cparams = {
"codec": blosc2.Codec.ZSTD,
"clevel": clevel,
"filters": [filter],
"filters_meta": [0],
"nthreads": nthreads,
}
dparams = {"nthreads": nthreads}
cparams = blosc2.CParams(
codec=blosc2.Codec.ZSTD,
clevel=clevel,
filters=[filter],
filters_meta=[0],
nthreads=nthreads,
)
dparams = blosc2.DParams(nthreads=nthreads)

zfilter = numcodecs.Blosc.SHUFFLE
blocksize = int(np.prod(blocks)) if blocks else 0
Expand Down
3 changes: 2 additions & 1 deletion bench/ndarray/copy_postfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
dtype = np.dtype(np.int32)

# Set the compression and decompression parameters
dparams = {"nthreads": 1}
dparams = {"nthreads" : 1}

# Create array
arr = blosc2.empty(shape=(nchunks * chunkshape,), chunks=(chunkshape,), dtype=dtype, dparams=dparams)
data = np.arange(chunkshape, dtype=dtype)

t0 = time()
for i in range(nchunks):
arr[i * chunkshape : (i + 1) * chunkshape] = data
Expand Down
6 changes: 3 additions & 3 deletions bench/ndarray/transcode_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
},
}

dparams = {
"nthreads": nthreads_decomp,
}
dparams = blosc2.DParams(
nthreads=nthreads_decomp,
)

dir_path = Path(dir_path)
if not dir_path.is_dir():
Expand Down
8 changes: 4 additions & 4 deletions bench/set_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@

nchunks = shape // chunksize
# Set the compression and decompression parameters
cparams = {"codec": blosc2.Codec.BLOSCLZ, "typesize": 8, "blocksize": blocksize * 8}
dparams = {}
cparams = blosc2.CParams(codec=blosc2.Codec.BLOSCLZ, typesize=8, blocksize=blocksize * 8)
dparams = blosc2.DParams()
contiguous = True
persistent = bool(sys.argv[1]) if len(sys.argv) > 1 else False

Expand All @@ -32,11 +32,11 @@
else:
urlpath = None

storage = {"contiguous": contiguous, "urlpath": urlpath, "cparams": cparams, "dparams": dparams}
storage = blosc2.Storage(contiguous=contiguous, urlpath=urlpath)
blosc2.remove_urlpath(urlpath)

# Create the empty SChunk
schunk = blosc2.SChunk(chunksize=chunksize * cparams["typesize"], **storage)
schunk = blosc2.SChunk(chunksize=chunksize * cparams.typesize, storage=storage, cparams=cparams, dparams=dparams)

# Append some chunks
for i in range(nchunks):
Expand Down
9 changes: 4 additions & 5 deletions bench/sum_postfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
chunksize = chunkshape * dtype.itemsize

# Set the compression and decompression parameters
cparams = {"typesize": 4, "nthreads": 1}
dparams = {"nthreads": 1}
storage = {"cparams": cparams, "dparams": dparams}
cparams = blosc2.CParams(typesize=4, nthreads=1)
dparams = blosc2.DParams(nthreads=1)

# Create super-chunks
schunk0 = blosc2.SChunk(chunksize=chunksize, **storage)
schunk = blosc2.SChunk(chunksize=chunksize, **storage)
schunk0 = blosc2.SChunk(chunksize=chunksize, cparams=cparams, dparams=dparams)
schunk = blosc2.SChunk(chunksize=chunksize, cparams=cparams, dparams=dparams)

data = np.arange(chunkshape, dtype=dtype)
t0 = time()
Expand Down
Loading

0 comments on commit 3da7003

Please sign in to comment.