diff --git a/tiled/server/pydantic_sparse.py b/tiled/server/pydantic_sparse.py index 8785daddc..7d6113e2d 100644 --- a/tiled/server/pydantic_sparse.py +++ b/tiled/server/pydantic_sparse.py @@ -2,7 +2,7 @@ import pydantic -from ..structures.array import BuiltinDtype, StructDtype, Endianness, Kind +from ..structures.array import BuiltinDtype, Endianness, Kind, StructDtype from ..structures.sparse import SparseLayout @@ -10,7 +10,9 @@ class COOStructure(pydantic.BaseModel): shape: Tuple[int, ...] # tuple of ints like (3, 3) chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None - coord_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype + coord_data_type: Optional[BuiltinDtype] = BuiltinDtype( + Endianness("little"), Kind("u"), 8 + ) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO diff --git a/tiled/structures/sparse.py b/tiled/structures/sparse.py index 13a8c2bcd..a84e67499 100644 --- a/tiled/structures/sparse.py +++ b/tiled/structures/sparse.py @@ -2,7 +2,7 @@ from dataclasses import dataclass from typing import Optional, Tuple, Union -from .array import BuiltinDtype, StructDtype, Endianness, Kind +from .array import BuiltinDtype, Endianness, Kind, StructDtype class SparseLayout(str, enum.Enum): @@ -16,7 +16,9 @@ class COOStructure: chunks: Tuple[Tuple[int, ...], ...] # tuple-of-tuples-of-ints like ((3,), (3,)) shape: Tuple[int, ...] # tuple of ints like (3, 3) data_type: Optional[Union[BuiltinDtype, StructDtype]] = None - coord_data_type: BuiltinDtype = BuiltinDtype(Endianness("little"), Kind("u"), 8) # numpy 'uint' dtype + coord_data_type: Optional[BuiltinDtype] = BuiltinDtype( + Endianness("little"), Kind("u"), 8 + ) # numpy 'uint' dtype dims: Optional[Tuple[str, ...]] = None # None or tuple of names like ("x", "y") resizable: Union[bool, Tuple[bool, ...]] = False layout: SparseLayout = SparseLayout.COO @@ -29,7 +31,9 @@ def from_json(cls, structure): data_type = StructDtype.from_json(data_type) else: data_type = BuiltinDtype.from_json(data_type) - coord_data_type = structure.get("coord_data_type", {"endianness":"little", "kind":"u", "itemsize":8}) + coord_data_type = structure.get( + "coord_data_type", {"endianness": "little", "kind": "u", "itemsize": 8} + ) return cls( data_type=data_type, coord_data_type=BuiltinDtype.from_json(coord_data_type),