-
-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
438 additions
and
252 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
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,41 @@ | ||
from __future__ import annotations | ||
|
||
from dataclasses import dataclass | ||
from typing import Any, Literal | ||
|
||
import numpy as np | ||
|
||
from zarr.buffer import BufferPrototype | ||
from zarr.common import ChunkCoords, parse_dtype, parse_fill_value, parse_order, parse_shapelike | ||
|
||
|
||
@dataclass(frozen=True) | ||
class ArraySpec: | ||
shape: ChunkCoords | ||
dtype: np.dtype[Any] | ||
fill_value: Any | ||
order: Literal["C", "F"] | ||
prototype: BufferPrototype | ||
|
||
def __init__( | ||
self, | ||
shape: ChunkCoords, | ||
dtype: np.dtype[Any], | ||
fill_value: Any, | ||
order: Literal["C", "F"], | ||
prototype: BufferPrototype, | ||
) -> None: | ||
shape_parsed = parse_shapelike(shape) | ||
dtype_parsed = parse_dtype(dtype) | ||
fill_value_parsed = parse_fill_value(fill_value) | ||
order_parsed = parse_order(order) | ||
|
||
object.__setattr__(self, "shape", shape_parsed) | ||
object.__setattr__(self, "dtype", dtype_parsed) | ||
object.__setattr__(self, "fill_value", fill_value_parsed) | ||
object.__setattr__(self, "order", order_parsed) | ||
object.__setattr__(self, "prototype", prototype) | ||
|
||
@property | ||
def ndim(self) -> int: | ||
return len(self.shape) |
Oops, something went wrong.