1111 List , Optional , Tuple , TypeVar , Union , cast
1212)
1313
14- import numpy as np
14+ import numpy
1515import xarray
1616from shapely import unary_union
1717from shapely .geometry import MultiPolygon , Point , Polygon
@@ -355,7 +355,7 @@ def get_time_name(self) -> Hashable:
355355 # A time variable must have units of the form '<units> since <epoc>'
356356 if 'since' in units :
357357 # The variable must now be a numpy datetime
358- if variable .dtype .type == np .datetime64 :
358+ if variable .dtype .type == numpy .datetime64 :
359359 return name
360360 raise NoSuchCoordinateError ("Could not find time coordinate in dataset" )
361361
@@ -441,7 +441,7 @@ def get_all_depth_names(self) -> List[Hashable]:
441441 ),
442442 DeprecationWarning ,
443443 )
444- def get_depths (self ) -> np .ndarray :
444+ def get_depths (self ) -> numpy .ndarray :
445445 """Get the depth of each vertical layer in this dataset.
446446
447447 .. deprecated:: 0.5.0
@@ -453,7 +453,7 @@ def get_depths(self) -> np.ndarray:
453453 :class:`numpy.ndarray`
454454 An array of depths, one per vertical layer in the dataset.
455455 """
456- return cast (np .ndarray , self .depth_coordinate .values )
456+ return cast (numpy .ndarray , self .depth_coordinate .values )
457457
458458 @utils .deprecated (
459459 (
@@ -462,7 +462,7 @@ def get_depths(self) -> np.ndarray:
462462 ),
463463 DeprecationWarning ,
464464 )
465- def get_times (self ) -> np .ndarray :
465+ def get_times (self ) -> numpy .ndarray :
466466 """Get all timesteps in this dataset.
467467
468468 .. deprecated:: 0.5.0
@@ -476,7 +476,7 @@ def get_times(self) -> np.ndarray:
476476 The datetimes will be whatever native format the dataset uses,
477477 likely :class:`numpy.datetime64`.
478478 """
479- return cast (np .ndarray , self .time_coordinate .values )
479+ return cast (numpy .ndarray , self .time_coordinate .values )
480480
481481 @abc .abstractmethod
482482 def ravel_index (self , index : Index ) -> int :
@@ -940,7 +940,7 @@ def make_poly_collection(
940940 values = data_array .values [self .mask ]
941941 kwargs ['array' ] = values
942942 if 'clim' not in kwargs :
943- kwargs ['clim' ] = (np .nanmin (values ), np .nanmax (values ))
943+ kwargs ['clim' ] = (numpy .nanmin (values ), numpy .nanmax (values ))
944944
945945 if 'transform' not in kwargs :
946946 kwargs ['transform' ] = self .data_crs
@@ -988,15 +988,15 @@ def make_quiver(
988988 """
989989 from matplotlib .quiver import Quiver
990990
991- x , y = np .transpose (self .face_centres )
991+ x , y = numpy .transpose (self .face_centres )
992992
993993 # A Quiver needs some values when being initialized.
994994 # We don't always want to provide values to the quiver,
995995 # sometimes preferring to fill them in later,
996996 # so `u` and `v` are optional.
997- # If they are not provided, we set default quiver values of `np .nan`.
998- values : Union [Tuple [np .ndarray , np .ndarray ], Tuple [float , float ]]
999- values = np .nan , np .nan
997+ # If they are not provided, we set default quiver values of `numpy .nan`.
998+ values : Union [Tuple [numpy .ndarray , numpy .ndarray ], Tuple [float , float ]]
999+ values = numpy .nan , numpy .nan
10001000
10011001 if u is not None and v is not None :
10021002 u , v = self ._get_data_array (u ), self ._get_data_array (v )
@@ -1024,7 +1024,7 @@ def make_quiver(
10241024
10251025 @property
10261026 @abc .abstractmethod
1027- def polygons (self ) -> np .ndarray :
1027+ def polygons (self ) -> numpy .ndarray :
10281028 """A :class:`numpy.ndarray` of :class:`shapely.Polygon` instances
10291029 representing the cells in this dataset.
10301030
@@ -1047,7 +1047,7 @@ def polygons(self) -> np.ndarray:
10471047 pass
10481048
10491049 @cached_property
1050- def face_centres (self ) -> np .ndarray :
1050+ def face_centres (self ) -> numpy .ndarray :
10511051 """
10521052 A numpy :class:`~numpy.ndarray` of face centres, which are (x, y) pairs.
10531053 The first dimension will be the same length and in the same order
@@ -1057,14 +1057,14 @@ def face_centres(self) -> np.ndarray:
10571057 # This default implementation simply finds the centroid of each polygon.
10581058 # Subclasses are free to override this if the particular convention and dataset
10591059 # provides the cell centres as a data array.
1060- centres = np .array ([
1061- polygon .centroid .coords [0 ] if polygon is not None else [np .nan , np .nan ]
1060+ centres = numpy .array ([
1061+ polygon .centroid .coords [0 ] if polygon is not None else [numpy .nan , numpy .nan ]
10621062 for polygon in self .polygons
10631063 ])
1064- return cast (np .ndarray , centres )
1064+ return cast (numpy .ndarray , centres )
10651065
10661066 @cached_property
1067- def mask (self ) -> np .ndarray :
1067+ def mask (self ) -> numpy .ndarray :
10681068 """
10691069 A boolean :class:`numpy.ndarray` indicating which cells have valid polygons.
10701070 This can be used to select only items from linear arrays
@@ -1081,10 +1081,10 @@ def mask(self) -> np.ndarray:
10811081 --------
10821082 :meth:`Convention.make_linear`
10831083 """
1084- mask = np .fromiter (
1084+ mask = numpy .fromiter (
10851085 (p is not None for p in self .polygons ),
10861086 dtype = bool , count = self .polygons .size )
1087- return cast (np .ndarray , mask )
1087+ return cast (numpy .ndarray , mask )
10881088
10891089 @cached_property
10901090 def geometry (self ) -> Union [Polygon , MultiPolygon ]:
0 commit comments