1515from functools import lru_cache
1616from itertools import chain , zip_longest
1717import operator
18+ from typing import Sequence , Union
1819import warnings
1920import zlib
2021
2122import cftime
2223import dask .array as da
2324import numpy as np
2425import numpy .ma as ma
26+ import numpy .typing as npt
2527
2628from iris ._data_manager import DataManager
2729import iris ._lazy_data as _lazy
@@ -253,7 +255,7 @@ def _lazy_values(self):
253255 """
254256 return self ._values_dm .lazy_data ()
255257
256- def _core_values (self ):
258+ def _core_values (self ) -> Union [ npt . NDArray , "da.Array" ] :
257259 """
258260 The values array of this dimensional metadata which may be a NumPy
259261 array or a dask array.
@@ -804,7 +806,7 @@ def dtype(self):
804806 return self ._values_dm .dtype
805807
806808 @property
807- def ndim (self ):
809+ def ndim (self ) -> int :
808810 """
809811 Return the number of dimensions of the current dimensional metadata
810812 object.
@@ -1691,7 +1693,7 @@ def points(self, points):
16911693 self ._values = points
16921694
16931695 @property
1694- def bounds (self ):
1696+ def bounds (self ) -> npt . NDArray :
16951697 """
16961698 The coordinate bounds values, as a NumPy array,
16971699 or None if no bound values are defined.
@@ -1817,7 +1819,7 @@ def core_points(self):
18171819 """
18181820 return super ()._core_values ()
18191821
1820- def core_bounds (self ):
1822+ def core_bounds (self ) -> Union [ npt . NDArray , "da.Array" ] :
18211823 """
18221824 The points array at the core of this coord, which may be a NumPy array
18231825 or a dask array.
@@ -2186,7 +2188,9 @@ def cell(self, index):
21862188
21872189 return Cell (point , bound )
21882190
2189- def collapsed (self , dims_to_collapse = None ):
2191+ def collapsed (
2192+ self , dims_to_collapse : Union [int , Sequence [int ], None ] = None
2193+ ) -> "Coord" :
21902194 """
21912195 Returns a copy of this coordinate, which has been collapsed along
21922196 the specified dimensions.
@@ -2204,7 +2208,9 @@ def collapsed(self, dims_to_collapse=None):
22042208 if np .issubdtype (self .dtype , np .str_ ):
22052209 # Collapse the coordinate by serializing the points and
22062210 # bounds as strings.
2207- def serialize (x , axis ):
2211+ def serialize (
2212+ x : npt .NDArray , axis : Union [Sequence [int ], None ]
2213+ ) -> Union [npt .NDArray , str ]:
22082214 if axis is None :
22092215 return "|" .join (str (i ) for i in x .flatten ())
22102216
0 commit comments