forked from zarr-developers/VirtualiZarr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bug with expand dims of a scalar array (zarr-developers#103)
* simple function to create manifestarray in tests * test to expose bug with broadcast_to for scalars * fix usage of outdated attribute name * fix bug by special-casing broadcasting of scalar arrays
- Loading branch information
1 parent
0f37222
commit 79d6969
Showing
4 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import numpy as np | ||
|
||
from virtualizarr.manifests import ChunkEntry, ChunkManifest, ManifestArray | ||
from virtualizarr.zarr import ZArray | ||
|
||
|
||
def create_manifestarray( | ||
shape: tuple[int, ...], chunks: tuple[int, ...] | ||
) -> ManifestArray: | ||
""" | ||
Create an example ManifestArray with sensible defaults. | ||
""" | ||
|
||
zarray = ZArray( | ||
chunks=chunks, | ||
compressor="zlib", | ||
dtype=np.dtype("float32"), | ||
fill_value=0.0, # TODO change this to NaN? | ||
filters=None, | ||
order="C", | ||
shape=shape, | ||
zarr_format=2, | ||
) | ||
|
||
if shape != (): | ||
raise NotImplementedError( | ||
"Only generation of array representing a single scalar currently supported" | ||
) | ||
|
||
# TODO generalize this | ||
chunkmanifest = ChunkManifest( | ||
entries={"0": ChunkEntry(path="scalar.nc", offset=6144, length=48)} | ||
) | ||
|
||
return ManifestArray(chunkmanifest=chunkmanifest, zarray=zarray) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters