1414from functools import lru_cache
1515from itertools import zip_longest
1616import operator
17+ from typing import Sequence , Union
1718import warnings
1819import zlib
1920
2021import dask .array as da
2122import numpy as np
2223import numpy .ma as ma
24+ import numpy .typing as npt
2325
2426from iris ._data_manager import DataManager
2527import iris ._lazy_data as _lazy
@@ -254,7 +256,7 @@ def _lazy_values(self):
254256 """
255257 return self ._values_dm .lazy_data ()
256258
257- def _core_values (self ):
259+ def _core_values (self ) -> Union [ npt . NDArray , "da.Array" ] :
258260 """
259261 The values array of this dimensional metadata which may be a NumPy
260262 array or a dask array.
@@ -805,7 +807,7 @@ def dtype(self):
805807 return self ._values_dm .dtype
806808
807809 @property
808- def ndim (self ):
810+ def ndim (self ) -> int :
809811 """
810812 Return the number of dimensions of the current dimensional metadata
811813 object.
@@ -1671,7 +1673,7 @@ def points(self, points):
16711673 self ._values = points
16721674
16731675 @property
1674- def bounds (self ):
1676+ def bounds (self ) -> npt . NDArray :
16751677 """
16761678 The coordinate bounds values, as a NumPy array,
16771679 or None if no bound values are defined.
@@ -1815,7 +1817,7 @@ def core_points(self):
18151817 """
18161818 return super ()._core_values ()
18171819
1818- def core_bounds (self ):
1820+ def core_bounds (self ) -> Union [ npt . NDArray , "da.Array" ] :
18191821 """
18201822 The points array at the core of this coord, which may be a NumPy array
18211823 or a dask array.
@@ -2214,7 +2216,9 @@ def cell(self, index):
22142216
22152217 return Cell (point , bound )
22162218
2217- def collapsed (self , dims_to_collapse = None ):
2219+ def collapsed (
2220+ self , dims_to_collapse : Union [int , Sequence [int ], None ] = None
2221+ ) -> "Coord" :
22182222 """
22192223 Returns a copy of this coordinate, which has been collapsed along
22202224 the specified dimensions.
@@ -2232,7 +2236,9 @@ def collapsed(self, dims_to_collapse=None):
22322236 if np .issubdtype (self .dtype , np .str_ ):
22332237 # Collapse the coordinate by serializing the points and
22342238 # bounds as strings.
2235- def serialize (x , axis ):
2239+ def serialize (
2240+ x : npt .NDArray , axis : Union [Sequence [int ], None ]
2241+ ) -> Union [npt .NDArray , str ]:
22362242 if axis is None :
22372243 return "|" .join (str (i ) for i in x .flatten ())
22382244
0 commit comments