55import enum
66import logging
77import warnings
8+ from collections .abc import Hashable , Iterable , Sequence
89from functools import cached_property
910from typing import (
10- TYPE_CHECKING , Any , Callable , Dict , FrozenSet , Generic , Hashable , Iterable ,
11- List , Optional , Sequence , Tuple , TypeVar , Union , cast
11+ TYPE_CHECKING , Any , Callable , Generic , Optional , TypeVar , Union , cast
1212)
1313
1414import numpy
@@ -399,7 +399,7 @@ def get_depth_name(self) -> Hashable:
399399 except IndexError :
400400 raise NoSuchCoordinateError ("Could not find depth coordinate in dataset" )
401401
402- def get_all_depth_names (self ) -> List [Hashable ]:
402+ def get_all_depth_names (self ) -> list [Hashable ]:
403403 """Get the names of all depth layers.
404404 Some datasets include both a depth layer centre,
405405 and the depth layer 'edges'.
@@ -595,7 +595,7 @@ def unravel_index(
595595
596596 @property
597597 @abc .abstractmethod
598- def grid_kinds (self ) -> FrozenSet [GridKind ]:
598+ def grid_kinds (self ) -> frozenset [GridKind ]:
599599 """
600600 All of the :data:`grid kinds <.GridKind>` this dataset includes.
601601 """
@@ -612,7 +612,7 @@ def default_grid_kind(self) -> GridKind:
612612
613613 @property
614614 @abc .abstractmethod
615- def grid_size (self ) -> Dict [GridKind , int ]:
615+ def grid_size (self ) -> dict [GridKind , int ]:
616616 """The linear size of each grid kind."""
617617 pass
618618
@@ -662,7 +662,7 @@ def get_grid_kind(self, data_array: xarray.DataArray) -> GridKind:
662662
663663 def get_grid_kind_and_size (
664664 self , data_array : xarray .DataArray ,
665- ) -> Tuple [GridKind , int ]:
665+ ) -> tuple [GridKind , int ]:
666666 """
667667 Determines the relevant index kind and the extent of the linear index space
668668 for this data array.
@@ -885,7 +885,7 @@ def plot_on_figure(
885885 self ,
886886 figure : Figure ,
887887 scalar : Optional [DataArrayOrName ] = None ,
888- vector : Optional [Tuple [DataArrayOrName , DataArrayOrName ]] = None ,
888+ vector : Optional [tuple [DataArrayOrName , DataArrayOrName ]] = None ,
889889 title : Optional [str ] = None ,
890890 ** kwargs : Any ,
891891 ) -> None :
@@ -965,7 +965,7 @@ def animate_on_figure(
965965 self ,
966966 figure : Figure ,
967967 scalar : Optional [DataArrayOrName ] = None ,
968- vector : Optional [Tuple [DataArrayOrName , DataArrayOrName ]] = None ,
968+ vector : Optional [tuple [DataArrayOrName , DataArrayOrName ]] = None ,
969969 coordinate : Optional [DataArrayOrName ] = None ,
970970 title : Optional [Union [str , Callable [[Any ], str ]]] = None ,
971971 ** kwargs : Any ,
@@ -1187,7 +1187,7 @@ def make_quiver(
11871187 # sometimes preferring to fill them in later,
11881188 # so `u` and `v` are optional.
11891189 # If they are not provided, we set default quiver values of `numpy.nan`.
1190- values : Union [Tuple [numpy .ndarray , numpy .ndarray ], Tuple [float , float ]]
1190+ values : Union [tuple [numpy .ndarray , numpy .ndarray ], tuple [float , float ]]
11911191 values = numpy .nan , numpy .nan
11921192
11931193 if u is not None and v is not None :
@@ -1422,7 +1422,7 @@ def get_index_for_point(
14221422 return None
14231423
14241424 @abc .abstractmethod
1425- def selector_for_index (self , index : Index ) -> Dict [Hashable , int ]:
1425+ def selector_for_index (self , index : Index ) -> dict [Hashable , int ]:
14261426 """
14271427 Convert a convention native index into a selector
14281428 that can be passed to :meth:`Dataset.isel <xarray.Dataset.isel>`.
@@ -1516,7 +1516,7 @@ def select_point(self, point: Point) -> xarray.Dataset:
15161516 return self .select_index (index .index )
15171517
15181518 @abc .abstractmethod
1519- def get_all_geometry_names (self ) -> List [Hashable ]:
1519+ def get_all_geometry_names (self ) -> list [Hashable ]:
15201520 """
15211521 Return a list of the names of all geometry variables used by this convention.
15221522
@@ -1742,7 +1742,7 @@ class DimensionConvention(Convention[GridKind, Index]):
17421742
17431743 @property
17441744 @abc .abstractmethod
1745- def grid_dimensions (self ) -> Dict [GridKind , Sequence [Hashable ]]:
1745+ def grid_dimensions (self ) -> dict [GridKind , Sequence [Hashable ]]:
17461746 """
17471747 The dimensions associated with a particular grid kind.
17481748
@@ -1760,7 +1760,7 @@ def grid_dimensions(self) -> Dict[GridKind, Sequence[Hashable]]:
17601760 pass
17611761
17621762 @property
1763- def grid_shape (self ) -> Dict [GridKind , Sequence [int ]]:
1763+ def grid_shape (self ) -> dict [GridKind , Sequence [int ]]:
17641764 """
17651765 The :attr:`shape <numpy.ndarray.shape>` of each grid kind.
17661766
@@ -1775,7 +1775,7 @@ def grid_shape(self) -> Dict[GridKind, Sequence[int]]:
17751775 }
17761776
17771777 @property
1778- def grid_size (self ) -> Dict [GridKind , int ]:
1778+ def grid_size (self ) -> dict [GridKind , int ]:
17791779 return {
17801780 grid_kind : int (numpy .prod (shape ))
17811781 for grid_kind , shape in self .grid_shape .items ()
@@ -1806,7 +1806,7 @@ def _get_data_array(self, data_array: DataArrayOrName) -> xarray.DataArray:
18061806 return self .dataset [data_array ]
18071807
18081808 @abc .abstractmethod
1809- def unpack_index (self , index : Index ) -> Tuple [GridKind , Sequence [int ]]:
1809+ def unpack_index (self , index : Index ) -> tuple [GridKind , Sequence [int ]]:
18101810 """Convert a native index in to a grid kind and dimension indices.
18111811
18121812 Parameters
@@ -1902,7 +1902,7 @@ def wind(
19021902 dimensions = dimensions , sizes = sizes ,
19031903 linear_dimension = linear_dimension )
19041904
1905- def selector_for_index (self , index : Index ) -> Dict [Hashable , int ]:
1905+ def selector_for_index (self , index : Index ) -> dict [Hashable , int ]:
19061906 grid_kind , indices = self .unpack_index (index )
19071907 dimensions = self .grid_dimensions [grid_kind ]
19081908 return dict (zip (dimensions , indices ))
0 commit comments