Skip to content

Commit

Permalink
cleanup more docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
philipc2 committed Oct 4, 2024
1 parent 354ff19 commit 5f5f634
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
1 change: 0 additions & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ I/O & Conversion
Grid.to_geodataframe
Grid.to_polycollection
Grid.to_linecollection
Grid.encode_as

Indexing
~~~~~~~~
Expand Down
10 changes: 5 additions & 5 deletions uxarray/core/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def open_grid(
use_dual: Optional[bool] = False,
**kwargs: Dict[str, Any],
) -> Grid:
"""Constructs and returns a ``uxarray.Grid`` from a grid file.
"""Constructs and returns a ``Grid`` from a grid file.
Parameters
----------
Expand Down Expand Up @@ -101,8 +101,8 @@ def open_dataset(
grid_kwargs: Optional[Dict[str, Any]] = {},
**kwargs: Dict[str, Any],
) -> UxDataset:
"""Wraps ``xarray.open_dataset()`` to support read in a grid and data file
together.
"""Wraps ``xarray.open_dataset()`` to support reading in a grid and data
file together.
Parameters
----------
Expand Down Expand Up @@ -191,8 +191,8 @@ def open_mfdataset(
grid_kwargs: Optional[Dict[str, Any]] = {},
**kwargs: Dict[str, Any],
) -> UxDataset:
"""Wraps ``xarray.open_dataset()`` to support read in a grid and multiple
data files together.
"""Wraps ``xarray.open_dataset()`` to support reading in a grid and
multiple data files together.
Parameters
----------
Expand Down
10 changes: 4 additions & 6 deletions uxarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ def to_dataset(
name: Hashable = None,
promote_attrs: bool = False,
) -> UxDataset:
"""Convert a UxDataArray to a UxDataset.
"""Convert a ``UxDataArray`` to a ``UxDataset``.
Parameters
----------
Expand All @@ -361,8 +361,7 @@ def to_dataset(
def integrate(
self, quadrature_rule: Optional[str] = "triangular", order: Optional[int] = 4
) -> UxDataArray:
"""Computes the integral of a data variable residing on an unstructured
grid.
"""Computes the integral of a data variable.
Parameters
----------
Expand Down Expand Up @@ -859,8 +858,7 @@ def topological_any(
def gradient(
self, normalize: Optional[bool] = False, use_magnitude: Optional[bool] = True
):
"""Computes the horizontal gradient of a data variable residing on an
unstructured grid.
"""Computes the horizontal gradient of a data variable.
Currently only supports gradients of face-centered data variables, with the resulting gradient being stored
on each edge. The gradient of a node-centered data variable can be approximated by computing the nodal average
Expand Down Expand Up @@ -922,7 +920,7 @@ def gradient(
return uxda

def difference(self, destination: Optional[str] = "edge"):
"""Computes the absolute difference between a data variable.
"""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``,
specified by ``destination='edge'``.
Expand Down
17 changes: 8 additions & 9 deletions uxarray/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -1528,8 +1528,8 @@ def normalize_cartesian_coordinates(self):
self.face_z.data = face_z

def to_xarray(self, grid_format: Optional[str] = "ugrid"):
"""Returns a xarray Dataset representation in a specific grid format
from the Grid object.
"""Returns an ``xarray.Dataset`` with the variables stored under the
``Grid`` encoded in a specific grid format.
Parameters
----------
Expand Down Expand Up @@ -1576,9 +1576,8 @@ def to_geodataframe(
return_non_nan_polygon_indices: Optional[bool] = False,
exclude_nan_polygons: Optional[bool] = True,
):
"""Constructs a ``spatialpandas.GeoDataFrame`` with a "geometry"
column, containing a collection of Shapely Polygons or MultiPolygons
representing the geometry of the unstructured grid.
"""Constructs a ``GeoDataFrame`` consisting of polygons representing
the faces of the current ``Grid``
Periodic polygons (i.e. those that cross the antimeridian) can be handled using the ``periodic_elements``
parameter. Setting ``periodic_elements='split'`` will split each periodic polygon along the antimeridian.
Expand Down Expand Up @@ -1698,8 +1697,8 @@ def to_polycollection(
return_non_nan_polygon_indices: Optional[bool] = False,
**kwargs,
):
"""Converts a ``Grid`` to a ``matplotlib.collections.PolyCollection``,
representing each face as a polygon.
"""Constructs a ``matplotlib.collections.PolyCollection``` consisting
of polygons representing the faces of the current ``Grid``
Parameters
----------
Expand Down Expand Up @@ -1781,8 +1780,8 @@ def to_linecollection(
override: Optional[bool] = False,
**kwargs,
):
"""Converts a ``Grid`` to a ``matplotlib.collections.LineCollection``,
representing each edge as a line.
"""Constructs a ``matplotlib.collections.LineCollection``` consisting
of lines representing the edges of the current ``Grid``
Parameters
----------
Expand Down

0 comments on commit 5f5f634

Please sign in to comment.