Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update of the Initialization of CParams, DParams, and Storage in Blosc2 #278

Merged
merged 4 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading