Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions uxarray/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
def open_grid(
grid_filename_or_obj: str | os.PathLike[Any] | dict | xr.Dataset,
chunks=None,
use_dual: bool | None = False,
use_dual: bool = False,
**kwargs: dict[str, Any],
):
"""Constructs and returns a ``Grid`` from a grid file.
Expand Down Expand Up @@ -371,7 +371,7 @@ def open_dataset(
filename_or_obj: str | os.PathLike[Any] | xr.Dataset | None = None,
chunks=None,
chunk_grid: bool = True,
use_dual: bool | None = False,
use_dual: bool = False,
grid_kwargs: dict[str, Any] | None = None,
**kwargs: dict[str, Any],
) -> UxDataset:
Expand Down Expand Up @@ -501,7 +501,7 @@ def open_mfdataset(
paths: str | os.PathLike,
chunks=None,
chunk_grid: bool = True,
use_dual: bool | None = False,
use_dual: bool = False,
grid_kwargs: dict[str, Any] | None = None,
**kwargs: dict[str, Any],
) -> UxDataset:
Expand Down
20 changes: 10 additions & 10 deletions uxarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,11 +247,11 @@ def data_mapping(self):

def to_geodataframe(
self,
periodic_elements: str | None = "exclude",
periodic_elements: str = "exclude",
projection=None,
cache: bool | None = True,
override: bool | None = False,
engine: str | None = "spatialpandas",
cache: bool = True,
override: bool = False,
engine: str = "spatialpandas",
project: bool = True,
):
"""Constructs a ``GeoDataFrame`` consisting of polygons representing
Expand Down Expand Up @@ -341,11 +341,11 @@ def to_geodataframe(

def to_polycollection(
self,
periodic_elements: Optional[str] = "exclude",
periodic_elements: str = "exclude",
projection: Optional[ccrs.Projection] = None,
return_indices: Optional[bool] = False,
cache: Optional[bool] = True,
override: Optional[bool] = False,
return_indices: bool = False,
cache: bool = True,
override: bool = False,
**kwargs,
):
"""Constructs a ``matplotlib.collections.PolyCollection``` consisting
Expand Down Expand Up @@ -661,7 +661,7 @@ def _binary_op(self, other, f, reflexive=False, **kw_super):
return result

def integrate(
self, quadrature_rule: str | None = "triangular", order: int | None = 4
self, quadrature_rule: str = "triangular", order: int = 4
) -> UxDataArray:
"""Computes the integral of a data variable.

Expand Down Expand Up @@ -2033,7 +2033,7 @@ def scalardotgradient(self, v: "UxDataArray", q: "UxDataArray") -> "UxDataArray"
result = result.assign_attrs(attrs)
return result

def difference(self, destination: str | None = "edge"):
def difference(self, destination: str = "edge"):
"""Computes the absolute difference of a data variable.

The difference for a face-centered data variable can be computed on each edge using the ``edge_face_connectivity``,
Expand Down
56 changes: 27 additions & 29 deletions uxarray/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def __init__(
subset = UncachedAccessor(GridSubsetAccessor)

@classmethod
def from_dataset(cls, dataset, use_dual: bool | None = False, **kwargs):
def from_dataset(cls, dataset, use_dual: bool = False, **kwargs):
"""Constructs a ``Grid`` object from a dataset.

Parameters
Expand Down Expand Up @@ -352,7 +352,7 @@ def from_dataset(cls, dataset, use_dual: bool | None = False, **kwargs):
def from_file(
cls,
filename: str,
backend: str | None = "geopandas",
backend: str = "geopandas",
**kwargs,
):
"""Constructs a ``Grid`` object from a using the read_file method with
Expand Down Expand Up @@ -472,7 +472,7 @@ def from_topology(
node_lat: np.ndarray,
face_node_connectivity: np.ndarray,
fill_value: int | float | None = None,
start_index: int | None = 0,
start_index: int = 0,
dims_dict: dict | None = None,
**kwargs,
):
Expand All @@ -493,7 +493,7 @@ def from_topology(
Face node connectivity, mapping each face to the nodes that surround them
fill_value: int | float | None
Value used for padding connectivity variables when the maximum number of elements in a row is less than the maximum.
start_index: int | None, default=0
start_index: int, default=0
Start index (typically 0 or 1)
dims_dict : dict | None
Dictionary of dimension names mapped to the ugrid conventions (i.e. {"nVertices": "n_node})
Expand Down Expand Up @@ -589,7 +589,7 @@ def from_structured(
def from_face_vertices(
cls,
face_vertices: list | tuple | np.ndarray,
latlon: bool | None = True,
latlon: bool = True,
):
"""Constructs a ``Grid`` object from user-defined face vertices.

Expand Down Expand Up @@ -1828,9 +1828,9 @@ def chunk(self, n_node="auto", n_edge="auto", n_face="auto"):

def get_ball_tree(
self,
coordinates: str | None = "face centers",
coordinate_system: str | None = "spherical",
distance_metric: str | None = "haversine",
coordinates: str = "face centers",
coordinate_system: str = "spherical",
distance_metric: str = "haversine",
reconstruct: bool = False,
):
"""Get the BallTree data structure of this Grid that allows for nearest
Expand Down Expand Up @@ -1924,9 +1924,7 @@ def neighborhood(self, r: float = 1.0, on: str = "face centers") -> Neighborhood
"""
return Neighborhood(self, r=r, on=on)

def _get_scipy_kd_tree(
self, coordinates: str | None = "face", reconstruct: bool = False
):
def _get_scipy_kd_tree(self, coordinates: str = "face", reconstruct: bool = False):
"""
Build or retrieve a KDTree for efficient nearest-neighbor searches on grid points.

Expand Down Expand Up @@ -1978,9 +1976,9 @@ def _get_scipy_kd_tree(

def get_kd_tree(
self,
coordinates: str | None = "face centers",
coordinate_system: str | None = "cartesian",
distance_metric: str | None = "minkowski",
coordinates: str = "face centers",
coordinate_system: str = "cartesian",
distance_metric: str = "minkowski",
reconstruct: bool = False,
):
"""Get the KDTree data structure of this Grid that allows for nearest
Expand Down Expand Up @@ -2473,7 +2471,7 @@ def sphere_radius(self, radius: float) -> None:

self._ds.attrs["sphere_radius"] = radius

def to_xarray(self, grid_format: str | None = "ugrid"):
def to_xarray(self, grid_format: str = "ugrid"):
"""Returns an ``xarray.Dataset`` with the variables stored under the
``Grid`` encoded in a specific grid format.

Expand Down Expand Up @@ -2520,13 +2518,13 @@ def to_xarray(self, grid_format: str | None = "ugrid"):

def to_geodataframe(
self,
periodic_elements: str | None = "exclude",
periodic_elements: str = "exclude",
projection=None,
cache: bool | None = True,
override: bool | None = False,
engine: str | None = "spatialpandas",
return_non_nan_polygon_indices: bool | None = False,
exclude_nan_polygons: bool | None = True,
cache: bool = True,
override: bool = False,
engine: str = "spatialpandas",
return_non_nan_polygon_indices: bool = False,
exclude_nan_polygons: bool = True,
project: bool = True,
):
"""Constructs a ``GeoDataFrame`` consisting of polygons representing
Expand Down Expand Up @@ -2637,12 +2635,12 @@ def to_geodataframe(

def to_polycollection(
self,
periodic_elements: Optional[str] = "exclude",
periodic_elements: str = "exclude",
projection: Optional[ccrs.Projection] = None,
return_indices: Optional[bool] = False,
cache: Optional[bool] = True,
override: Optional[bool] = False,
return_non_nan_polygon_indices: Optional[bool] = False,
return_indices: bool = False,
cache: bool = True,
override: bool = False,
return_non_nan_polygon_indices: bool = False,
**kwargs,
):
"""Constructs a ``matplotlib.collections.PolyCollection``` consisting
Expand Down Expand Up @@ -2723,10 +2721,10 @@ def to_polycollection(

def to_linecollection(
self,
periodic_elements: Optional[str] = "exclude",
periodic_elements: str = "exclude",
projection: Optional[ccrs.Projection] = None,
cache: Optional[bool] = True,
override: Optional[bool] = False,
cache: bool = True,
override: bool = False,
**kwargs,
):
"""Constructs a ``matplotlib.collections.LineCollection``` consisting
Expand Down
60 changes: 30 additions & 30 deletions uxarray/grid/neighbors.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class KDTree:
def __init__(
self,
grid,
coordinates: str | None = "face centers",
coordinate_system: str | None = "cartesian",
distance_metric: str | None = "minkowski",
coordinates: str = "face centers",
coordinate_system: str = "cartesian",
distance_metric: str = "minkowski",
reconstruct: bool = False,
):
# Set up references
Expand Down Expand Up @@ -217,12 +217,12 @@ def _current_tree(self):
def query(
self,
coords: np.ndarray | list | tuple,
k: int | None = 1,
return_distance: bool | None = True,
in_radians: bool | None = False,
dualtree: bool | None = False,
breadth_first: bool | None = False,
sort_results: bool | None = True,
k: int = 1,
return_distance: bool = True,
in_radians: bool = False,
dualtree: bool = False,
breadth_first: bool = False,
sort_results: bool = True,
):
"""Queries the tree for the ``k`` nearest neighbors.

Expand Down Expand Up @@ -301,11 +301,11 @@ def query(
def query_radius(
self,
coords: np.ndarray | list | tuple,
r: int | None = 1.0,
return_distance: bool | None = False,
in_radians: bool | None = False,
count_only: bool | None = False,
sort_results: bool | None = False,
r: int = 1.0,
return_distance: bool = False,
in_radians: bool = False,
count_only: bool = False,
sort_results: bool = False,
):
"""Queries the tree for all neighbors within a radius ``r``.

Expand Down Expand Up @@ -440,9 +440,9 @@ class BallTree:
def __init__(
self,
grid,
coordinates: str | None = "face centers",
coordinate_system: str | None = "spherical",
distance_metric: str | None = "haversine",
coordinates: str = "face centers",
coordinate_system: str = "spherical",
distance_metric: str = "haversine",
reconstruct: bool = False,
):
# maintain a reference to the source grid
Expand Down Expand Up @@ -602,12 +602,12 @@ def _current_tree(self):
def query(
self,
coords: np.ndarray | list | tuple,
k: int | None = 1,
in_radians: bool | None = False,
return_distance: bool | None = True,
dualtree: bool | None = False,
breadth_first: bool | None = False,
sort_results: bool | None = True,
k: int = 1,
in_radians: bool = False,
return_distance: bool = True,
dualtree: bool = False,
breadth_first: bool = False,
sort_results: bool = True,
):
"""Queries the tree for the ``k`` nearest neighbors.

Expand Down Expand Up @@ -686,11 +686,11 @@ def query(
def query_radius(
self,
coords: np.ndarray | list | tuple,
r: int | None = 1.0,
in_radians: bool | None = False,
return_distance: bool | None = False,
count_only: bool | None = False,
sort_results: bool | None = False,
r: int = 1.0,
in_radians: bool = False,
return_distance: bool = False,
count_only: bool = False,
sort_results: bool = False,
):
"""Queries the tree for all neighbors within a radius ``r``.

Expand Down Expand Up @@ -905,8 +905,8 @@ def _initialize_face_hash_table(self):
def query(
self,
coords: np.ndarray | list | tuple,
in_radians: bool | None = False,
tol: float | None = 1e-6,
in_radians: bool = False,
tol: float = 1e-6,
):
"""Queries the hash table.

Expand Down
8 changes: 4 additions & 4 deletions uxarray/plot/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ def __getattr__(self, name: str) -> Any:

def polygons(
self,
periodic_elements: str | None = "split",
periodic_elements: str = "split",
backend: str | None = None,
engine: str | None = "spatialpandas",
rasterize: bool | None = True,
dynamic: bool | None = False,
engine: str = "spatialpandas",
rasterize: bool = True,
dynamic: bool = False,
projection=None,
xlabel: str | None = "Longitude",
ylabel: str | None = "Latitude",
Expand Down
2 changes: 1 addition & 1 deletion uxarray/remap/accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def nearest_neighbor(
destination_grid: Grid,
remap_to: str = "faces",
backend: str = "uxarray",
yac_method: str | None = "nnn",
yac_method: str = "nnn",
yac_options: dict | None = None,
**kwargs,
) -> UxDataArray | UxDataset:
Expand Down
4 changes: 2 additions & 2 deletions uxarray/subset/dataarray_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def bounding_circle(
self,
center_coord: tuple | list | np.ndarray,
r: float | int,
element: str | None = "face centers",
element: str = "face centers",
inverse_indices: list[str] | set[str] | bool = False,
**kwargs,
):
Expand Down Expand Up @@ -96,7 +96,7 @@ def nearest_neighbor(
self,
center_coord: tuple | list | np.ndarray,
k: int,
element: str | None = "face centers",
element: str = "face centers",
inverse_indices: list[str] | set[str] | bool = False,
**kwargs,
):
Expand Down
4 changes: 2 additions & 2 deletions uxarray/subset/grid_accessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def bounding_circle(
self,
center_coord: tuple | list | np.ndarray,
r: float | int,
element: str | None = "face centers",
element: str = "face centers",
inverse_indices: list[str] | set[str] | bool = False,
**kwargs,
):
Expand Down Expand Up @@ -107,7 +107,7 @@ def nearest_neighbor(
self,
center_coord: tuple | list | np.ndarray,
k: int,
element: str | None = "face centers",
element: str = "face centers",
inverse_indices: list[str] | set[str] | bool = False,
**kwargs,
):
Expand Down
Loading