mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-14 10:44:28 +00:00
python 3.9 compat
This commit is contained in:
parent
74f03b10bf
commit
705de53838
2 changed files with 5 additions and 5 deletions
|
@ -2,7 +2,7 @@
|
|||
Interface for Dask arrays
|
||||
"""
|
||||
|
||||
from typing import Any, Iterable, Literal, Optional
|
||||
from typing import Any, Iterable, List, Literal, Optional, Union
|
||||
|
||||
import numpy as np
|
||||
from pydantic import SerializationInfo
|
||||
|
@ -17,7 +17,7 @@ except ImportError: # pragma: no cover
|
|||
DaskArray = None
|
||||
|
||||
|
||||
def _as_tuple(a_list: list | Any) -> tuple:
|
||||
def _as_tuple(a_list: Any) -> tuple:
|
||||
"""Make a list of list into a tuple of tuples"""
|
||||
return tuple(
|
||||
[_as_tuple(item) if isinstance(item, list) else item for item in a_list]
|
||||
|
@ -93,7 +93,7 @@ class DaskInterface(Interface):
|
|||
@classmethod
|
||||
def to_json(
|
||||
cls, array: DaskArray, info: Optional[SerializationInfo] = None
|
||||
) -> list | DaskJsonDict:
|
||||
) -> Union[List, DaskJsonDict]:
|
||||
"""
|
||||
Convert an array to a JSON serializable array by first converting to a numpy
|
||||
array and then to a list.
|
||||
|
|
|
@ -65,7 +65,7 @@ class ZarrJsonDict(JsonDict):
|
|||
path: Optional[str] = None
|
||||
array: Optional[list] = None
|
||||
|
||||
def to_array_input(self) -> ZarrArray | ZarrArrayPath:
|
||||
def to_array_input(self) -> Union[ZarrArray, ZarrArrayPath]:
|
||||
"""
|
||||
Construct a ZarrArrayPath if file and path are present,
|
||||
otherwise a ZarrArray
|
||||
|
@ -168,7 +168,7 @@ class ZarrInterface(Interface):
|
|||
cls,
|
||||
array: Union[ZarrArray, str, Path, ZarrArrayPath, Sequence],
|
||||
info: Optional[SerializationInfo] = None,
|
||||
) -> list | ZarrJsonDict:
|
||||
) -> Union[list, ZarrJsonDict]:
|
||||
"""
|
||||
Dump a Zarr Array to JSON
|
||||
|
||||
|
|
Loading…
Reference in a new issue