11
11
from functools import lru_cache
12
12
from itertools import zip_longest
13
13
import operator
14
+ from typing import Sequence , Union
14
15
import warnings
15
16
import zlib
16
17
17
18
import dask .array as da
18
19
import numpy as np
19
20
import numpy .ma as ma
21
+ import numpy .typing as npt
20
22
21
23
from iris ._data_manager import DataManager
22
24
import iris ._lazy_data as _lazy
@@ -238,8 +240,24 @@ def _lazy_values(self):
238
240
"""Return a lazy array representing the dimensional metadata values."""
239
241
return self ._values_dm .lazy_data ()
240
242
243
+ < << << << HEAD
241
244
def _core_values (self ):
242
245
"""Value array of this dimensional metadata which may be a NumPy array or a dask array."""
246
+ | | | | | | | constructed merge base
247
+ def _core_values (self ):
248
+ """
249
+ The values array of this dimensional metadata which may be a NumPy
250
+ array or a dask array.
251
+
252
+ """
253
+ == == == =
254
+ def _core_values (self ) -> Union [npt .NDArray , "da.Array" ]:
255
+ """
256
+ The values array of this dimensional metadata which may be a NumPy
257
+ array or a dask array.
258
+
259
+ """
260
+ >> >> >> > add type hints
243
261
result = self ._values_dm .core_data ()
244
262
if not _lazy .is_lazy_data (result ):
245
263
result = result .view ()
@@ -771,8 +789,24 @@ def dtype(self):
771
789
return self ._values_dm .dtype
772
790
773
791
@property
792
+ < << << << HEAD
774
793
def ndim (self ):
775
794
"""Return the number of dimensions of the current dimensional metadata object."""
795
+ | | | | | | | constructed merge base
796
+ def ndim (self ):
797
+ """
798
+ Return the number of dimensions of the current dimensional metadata
799
+ object.
800
+
801
+ """
802
+ == == == =
803
+ def ndim (self ) -> int :
804
+ """
805
+ Return the number of dimensions of the current dimensional metadata
806
+ object.
807
+
808
+ """
809
+ >> >> >> > add type hints
776
810
return self ._values_dm .ndim
777
811
778
812
def has_bounds (self ):
@@ -1584,9 +1618,17 @@ def points(self, points):
1584
1618
self ._values = points
1585
1619
1586
1620
@property
1621
+ < << << << HEAD
1587
1622
def bounds (self ):
1588
1623
"""Coordinate bounds values.
1589
1624
1625
+ ||||||| constructed merge base
1626
+ def bounds(self):
1627
+ """
1628
+ == == == =
1629
+ def bounds (self ) -> npt .NDArray :
1630
+ """
1631
+ >>>>>>> add type hints
1590
1632
The coordinate bounds values, as a NumPy array,
1591
1633
or None if no bound values are defined.
1592
1634
@@ -1720,8 +1762,24 @@ def core_points(self):
1720
1762
"""Core points array at the core of this coord, which may be a NumPy array or a dask array."""
1721
1763
return super ()._core_values ()
1722
1764
1765
+ << << << < HEAD
1723
1766
def core_bounds (self ):
1724
1767
"""Core bounds. The points array at the core of this coord, which may be a NumPy array or a dask array."""
1768
+ | | | | | | | constructed merge base
1769
+ def core_bounds (self ):
1770
+ """
1771
+ The points array at the core of this coord, which may be a NumPy array
1772
+ or a dask array.
1773
+
1774
+ """
1775
+ == == == =
1776
+ def core_bounds (self ) -> Union [npt .NDArray , "da.Array" ]:
1777
+ """
1778
+ The points array at the core of this coord, which may be a NumPy array
1779
+ or a dask array.
1780
+
1781
+ """
1782
+ >> >> >> > add type hints
1725
1783
result = None
1726
1784
if self .has_bounds ():
1727
1785
result = self ._bounds_dm .core_data ()
@@ -2099,8 +2157,11 @@ def cell(self, index):
2099
2157
2100
2158
return Cell (point , bound )
2101
2159
2102
- def collapsed (self , dims_to_collapse = None ):
2103
- """Return a copy of this coordinate, which has been collapsed along the specified dimensions.
2160
+ def collapsed (
2161
+ self , dims_to_collapse : Union [int , Sequence [int ], None ] = None
2162
+ ) -> "Coord" :
2163
+ """
2164
+ Returns a copy of this coordinate, which has been collapsed along the specified dimensions.
2104
2165
2105
2166
Replaces the points & bounds with a simple bounded region.
2106
2167
"""
@@ -2114,7 +2175,9 @@ def collapsed(self, dims_to_collapse=None):
2114
2175
if np .issubdtype (self .dtype , np .str_ ):
2115
2176
# Collapse the coordinate by serializing the points and
2116
2177
# bounds as strings.
2117
- def serialize (x , axis ):
2178
+ def serialize (
2179
+ x : npt .NDArray , axis : Union [Sequence [int ], None ]
2180
+ ) -> Union [npt .NDArray , str ]:
2118
2181
if axis is None :
2119
2182
return "|" .join (str (i ) for i in x .flatten ())
2120
2183
0 commit comments