2222)
2323from zarr .core .dtype .npy .common import (
2424 ComplexLike ,
25- TComplexDType_co ,
26- TComplexScalar_co ,
2725 check_json_complex_float_v2 ,
2826 check_json_complex_float_v3 ,
2927 complex_float_from_json_v2 ,
4038
4139
4240@dataclass (frozen = True )
43- class BaseComplex (ZDType [TComplexDType_co , TComplexScalar_co ], HasEndianness , HasItemSize ):
41+ class BaseComplex [
42+ DType : np .dtypes .Complex64DType | np .dtypes .Complex128DType ,
43+ Scalar : np .complex64 | np .complex128 ,
44+ ](ZDType [DType , Scalar ], HasEndianness , HasItemSize ):
4445 """
4546 A base class for Zarr data types that wrap NumPy complex float data types.
4647 """
@@ -74,13 +75,13 @@ def from_native_dtype(cls, dtype: TBaseDType) -> Self:
7475 f"Invalid data type: { dtype } . Expected an instance of { cls .dtype_cls } "
7576 )
7677
77- def to_native_dtype (self ) -> TComplexDType_co :
78+ def to_native_dtype (self ) -> DType :
7879 """
7980 Convert this class to a NumPy complex dtype with the appropriate byte order.
8081
8182 Returns
8283 -------
83- TComplexDType_co
84+ DType
8485 A NumPy data type object representing the complex data type with the specified byte order.
8586 """
8687
@@ -235,7 +236,7 @@ def _check_scalar(self, data: object) -> TypeGuard[ComplexLike]:
235236 """
236237 return isinstance (data , ComplexLike )
237238
238- def _cast_scalar_unchecked (self , data : ComplexLike ) -> TComplexScalar_co :
239+ def _cast_scalar_unchecked (self , data : ComplexLike ) -> Scalar :
239240 """
240241 Cast the provided scalar data to the native scalar type of this class.
241242
@@ -246,7 +247,7 @@ def _cast_scalar_unchecked(self, data: ComplexLike) -> TComplexScalar_co:
246247
247248 Returns
248249 -------
249- TComplexScalar_co
250+ Scalar
250251 The casted data as a numpy complex scalar.
251252
252253 Notes
@@ -256,7 +257,7 @@ def _cast_scalar_unchecked(self, data: ComplexLike) -> TComplexScalar_co:
256257 """
257258 return self .to_native_dtype ().type (data ) # type: ignore[return-value]
258259
259- def cast_scalar (self , data : object ) -> TComplexScalar_co :
260+ def cast_scalar (self , data : object ) -> Scalar :
260261 """
261262 Attempt to cast a given object to a numpy complex scalar.
262263
@@ -267,7 +268,7 @@ def cast_scalar(self, data: object) -> TComplexScalar_co:
267268
268269 Returns
269270 -------
270- TComplexScalar_co
271+ Scalar
271272 The data cast as a numpy complex scalar.
272273
273274 Raises
@@ -283,7 +284,7 @@ def cast_scalar(self, data: object) -> TComplexScalar_co:
283284 )
284285 raise TypeError (msg )
285286
286- def default_scalar (self ) -> TComplexScalar_co :
287+ def default_scalar (self ) -> Scalar :
287288 """
288289 Get the default value, which is 0 cast to this dtype
289290
@@ -294,7 +295,7 @@ def default_scalar(self) -> TComplexScalar_co:
294295 """
295296 return self ._cast_scalar_unchecked (0 )
296297
297- def from_json_scalar (self , data : JSON , * , zarr_format : ZarrFormat ) -> TComplexScalar_co :
298+ def from_json_scalar (self , data : JSON , * , zarr_format : ZarrFormat ) -> Scalar :
298299 """
299300 Read a JSON-serializable value as a numpy float.
300301
0 commit comments