14
14
import copy
15
15
from itertools import chain , zip_longest
16
16
import operator
17
+ from typing import Sequence , Union
17
18
import warnings
18
19
import zlib
19
20
20
21
import cftime
21
22
import dask .array as da
22
23
import numpy as np
23
24
import numpy .ma as ma
25
+ import numpy .typing as npt
24
26
25
27
from iris ._data_manager import DataManager
26
28
import iris ._lazy_data as _lazy
@@ -248,7 +250,7 @@ def _lazy_values(self):
248
250
"""
249
251
return self ._values_dm .lazy_data ()
250
252
251
- def _core_values (self ):
253
+ def _core_values (self ) -> Union [ npt . NDArray , "da.Array" ] :
252
254
"""
253
255
The values array of this dimensional metadata which may be a NumPy
254
256
array or a dask array.
@@ -545,7 +547,7 @@ def dtype(self):
545
547
return self ._values_dm .dtype
546
548
547
549
@property
548
- def ndim (self ):
550
+ def ndim (self ) -> int :
549
551
"""
550
552
Return the number of dimensions of the current dimensional metadata
551
553
object.
@@ -1445,7 +1447,7 @@ def points(self, points):
1445
1447
self ._values = points
1446
1448
1447
1449
@property
1448
- def bounds (self ):
1450
+ def bounds (self ) -> npt . NDArray :
1449
1451
"""
1450
1452
The coordinate bounds values, as a NumPy array,
1451
1453
or None if no bound values are defined.
@@ -1571,7 +1573,7 @@ def core_points(self):
1571
1573
"""
1572
1574
return super ()._core_values ()
1573
1575
1574
- def core_bounds (self ):
1576
+ def core_bounds (self ) -> Union [ npt . NDArray , "da.Array" ] :
1575
1577
"""
1576
1578
The points array at the core of this coord, which may be a NumPy array
1577
1579
or a dask array.
@@ -1933,7 +1935,9 @@ def cell(self, index):
1933
1935
1934
1936
return Cell (point , bound )
1935
1937
1936
- def collapsed (self , dims_to_collapse = None ):
1938
+ def collapsed (
1939
+ self , dims_to_collapse : Union [int , Sequence [int ], None ] = None
1940
+ ) -> "Coord" :
1937
1941
"""
1938
1942
Returns a copy of this coordinate, which has been collapsed along
1939
1943
the specified dimensions.
@@ -1951,7 +1955,9 @@ def collapsed(self, dims_to_collapse=None):
1951
1955
if np .issubdtype (self .dtype , np .str_ ):
1952
1956
# Collapse the coordinate by serializing the points and
1953
1957
# bounds as strings.
1954
- def serialize (x , axis ):
1958
+ def serialize (
1959
+ x : npt .NDArray , axis : Union [Sequence [int ], None ]
1960
+ ) -> Union [npt .NDArray , str ]:
1955
1961
if axis is None :
1956
1962
return "|" .join (str (i ) for i in x .flatten ())
1957
1963
0 commit comments