Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into ruff9
Browse files Browse the repository at this point in the history
* upstream/main:
  ruff rule D211, D300, D403 compliance. (SciTools#5661)
  ruff rule D412 compliance. (SciTools#5660)
  • Loading branch information
tkknight committed Dec 20, 2023
2 parents 3b64268 + 3383f00 commit 0ea8489
Show file tree
Hide file tree
Showing 26 changed files with 108 additions and 132 deletions.
5 changes: 1 addition & 4 deletions .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,12 @@ lint.ignore = [
"D202", # No blank lines allowed after function docstring
"D205", # 1 blank line required between summary line and description
"D209", # Multi-line docstring closing quotes should be on a separate line
"D211", # No blank lines allowed before class docstring
"D300", # triple double quotes `""" / Use triple single quotes `'''`
"D401", # First line of docstring should be in imperative mood: ...
"D403", # First word of the first line should be capitalized
"D404", # First word of the docstring should not be "This"
"D405", # Section name should be properly capitalized
"D406", # Section name should end with a newline
"D407", # Missing dashed underline after section
"D412", # No blank lines allowed between a section header and its content
"D409", # Section underline should match the length of its name

# pyupgrade (UP)
# https://docs.astral.sh/ruff/rules/#pyupgrade-up
Expand Down
1 change: 0 additions & 1 deletion benchmarks/benchmarks/aux_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class FactoryCommon:
# * make class an ABC
# * remove NotImplementedError
# * combine setup_common into setup

"""A base class running a generalised suite of benchmarks for any factory.
Factory to be specified in a subclass.
Expand Down
1 change: 0 additions & 1 deletion benchmarks/benchmarks/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class ComponentCommon:
# * make class an ABC
# * remove NotImplementedError
# * combine setup_common into setup

"""A base class running a generalised suite of benchmarks for cubes that
include a specified component (e.g. Coord, CellMeasure etc.). Component to
be specified in a subclass.
Expand Down
1 change: 0 additions & 1 deletion docs/gallery_code/general/plot_SOI_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
References
----------
Duchon C. E. (1979) Lanczos Filtering in One and Two Dimensions.
Journal of Applied Meteorology, Vol 18, pp 1016-1022.
Expand Down
1 change: 0 additions & 1 deletion docs/gallery_code/meteorology/plot_COP_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
References
----------
Johns T.C., et al. (2011) Climate change under aggressive mitigation: the
ENSEMBLES multi-model experiment. Climate Dynamics, Vol 37, No. 9-10,
doi:10.1007/s00382-011-1005-5.
Expand Down
1 change: 0 additions & 1 deletion docs/gallery_code/meteorology/plot_COP_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
References
----------
Johns T.C., et al. (2011) Climate change under aggressive mitigation: the
ENSEMBLES multi-model experiment. Climate Dynamics, Vol 37, No. 9-10,
doi:10.1007/s00382-011-1005-5.
Expand Down
67 changes: 34 additions & 33 deletions lib/iris/analysis/_grid_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def _3d_xyz_from_latlon(lon, lat):
Arrays of longitudes and latitudes, in degrees.
Both the same shape.
Returns:
* xyz : (array, dtype=float64)
Returns
-------
xyz : array, dtype=float64
Cartesian coordinates on a unit sphere.
Shape is (3, <input-shape>).
The x / y / z coordinates are in xyz[0 / 1 / 2].
Expand Down Expand Up @@ -52,9 +52,9 @@ def _latlon_from_xyz(xyz):
Shape (3, <input_points_dimensions>).
x / y / z values are in xyz[0 / 1 / 2],
Returns:
* lonlat : (array)
Returns
-------
lonlat : array
longitude and latitude position angles, in degrees.
Shape (2, <input_points_dimensions>).
The longitudes / latitudes are in lonlat[0 / 1].
Expand Down Expand Up @@ -104,9 +104,9 @@ def _angle(p, q, r):
Shape is (2, <input_points_dimensions>).
Longitudes / latitudes are in array[0 / 1].
Returns:
* angle : (float array)
Returns
-------
angle : float array
Grid angles relative to true-East, in degrees.
Positive when grid-East is anticlockwise from true-East.
Shape is same as <input_points_dimensions>.
Expand Down Expand Up @@ -178,23 +178,22 @@ def gridcell_angles(x, y=None, cell_angle_boundpoints="mid-lhs, mid-rhs"):
takes an angles between the average of the left-hand and right-hand
pairs of corners. The default is 'mid-lhs, mid-rhs'.
Returns:
angles : (2-dimensional cube)
Cube of angles of grid-x vector from true Eastward direction for
each gridcell, in degrees.
It also has "true" longitude and latitude coordinates, with no
coordinate system.
When the input has coords, then the output ones are identical if
the inputs are true-latlons, otherwise they are transformed
true-latlon versions.
When the input has bounded coords, then the output coords have
matching bounds and centrepoints (possibly transformed).
When the input is 2d arrays, or has unbounded coords, then the
output coords have matching points and no bounds.
When the input is 3d arrays, then the output coords have matching
bounds, and the centrepoints are an average of the 4 boundpoints.
Returns
-------
angles : 2-dimensional cube
Cube of angles of grid-x vector from true Eastward direction for
each gridcell, in degrees.
It also has "true" longitude and latitude coordinates, with no
coordinate system.
When the input has coords, then the output ones are identical if
the inputs are true-latlons, otherwise they are transformed
true-latlon versions.
When the input has bounded coords, then the output coords have
matching bounds and centrepoints (possibly transformed).
When the input is 2d arrays, or has unbounded coords, then the
output coords have matching points and no bounds.
When the input is 3d arrays, then the output coords have matching
bounds, and the centrepoints are an average of the 4 boundpoints.
"""
cube = None
Expand Down Expand Up @@ -423,15 +422,17 @@ def rotate_grid_vectors(u_cube, v_cube, grid_angles_cube=None, grid_angles_kwarg
Additional keyword args to be passed to the :func:`gridcell_angles`
method, if it is used.
Returns:
true_u, true_v : (cube)
Cubes of true-north oriented vector components.
Units are same as inputs.
Returns
-------
true_u, true_v : cube
Cubes of true-north oriented vector components.
Units are same as inputs.
.. Note::
Notes
-----
.. note::
Vector magnitudes will always be the same as the inputs.
Vector magnitudes will always be the same as the inputs.
.. note::
Expand Down
7 changes: 4 additions & 3 deletions lib/iris/analysis/_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,10 @@ def _interpolate(self, data, interp_points):
The other (leading) dimensions index over the different required
sample points.
Returns:
A :class:`np.ndarray`. Its shape is "points_shape + extra_shape",
Returns
-------
:class:`np.ndarray`.
Its shape is "points_shape + extra_shape",
where "extra_shape" is the remaining non-interpolated dimensions of
the data array (i.e. 'data.shape[N:]'), and "points_shape" is the
leading dimensions of interp_points,
Expand Down
1 change: 0 additions & 1 deletion lib/iris/analysis/_scipy_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def _ndim_coords_from_arrays(points, ndim=None):
# source: https://github.com/scipy/scipy/blob/b94a5d5ccc08dddbc88453477ff2625\
# 9aeaafb32/scipy/interpolate/interpolate.py#L1400
class _RegularGridInterpolator:

"""Interpolation on a regular grid in arbitrary dimensions.
The data must be defined on a regular grid; the grid spacing however may be
Expand Down
4 changes: 2 additions & 2 deletions lib/iris/analysis/cartography.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ def cosine_latitude_weights(cube):
w_l = \cos \phi_l
Examples:
Examples
--------
Compute weights suitable for averaging type operations::
from iris.analysis.cartography import cosine_latitude_weights
Expand Down
8 changes: 0 additions & 8 deletions lib/iris/analysis/maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ def add(cube, other, dim=None, in_place=False):
Parameters
----------
cube : iris.cube.Cube
First operand to add.
Expand All @@ -234,7 +233,6 @@ def add(cube, other, dim=None, in_place=False):
Returns
-------
iris.cube.Cube
Notes
Expand Down Expand Up @@ -273,7 +271,6 @@ def subtract(cube, other, dim=None, in_place=False):
Parameters
----------
cube : iris.cube.Cube
Cube from which to subtract.
Expand All @@ -289,7 +286,6 @@ def subtract(cube, other, dim=None, in_place=False):
Returns
-------
iris.cube.Cube
Notes
Expand Down Expand Up @@ -378,7 +374,6 @@ def multiply(cube, other, dim=None, in_place=False):
Parameters
----------
cube : iris.cube.Cube
First operand to multiply.
Expand All @@ -394,7 +389,6 @@ def multiply(cube, other, dim=None, in_place=False):
Returns
-------
iris.cube.Cube
Notes
Expand Down Expand Up @@ -464,7 +458,6 @@ def divide(cube, other, dim=None, in_place=False):
Parameters
----------
cube : iris.cube.Cube
Numerator.
Expand All @@ -480,7 +473,6 @@ def divide(cube, other, dim=None, in_place=False):
Returns
-------
iris.cube.Cube
Notes
Expand Down
2 changes: 0 additions & 2 deletions lib/iris/coord_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,6 @@ def __init__(
Parameters
----------
central_lat : float
The latitude of the pole.
Expand Down Expand Up @@ -1113,7 +1112,6 @@ def __init__(
Parameters
----------
central_lat : {90, -90}
The latitude of the pole.
Expand Down
30 changes: 13 additions & 17 deletions lib/iris/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,6 @@ class CubeAttrsDict(MutableMapping):
Examples
--------
>>> from iris.cube import Cube
>>> cube = Cube([0])
>>> # CF defines 'history' as global by default.
Expand Down Expand Up @@ -829,7 +828,6 @@ def __init__(
Examples
--------
>>> from iris.cube import CubeAttrsDict
>>> # CF defines 'history' as global by default.
>>> CubeAttrsDict({'history': 'data-story', 'comment': 'this-cube'})
Expand Down Expand Up @@ -2364,11 +2362,11 @@ def mesh(self):
:class:`~iris.experimental.ugrid.MeshCoord`\\ s,
or ``None`` if it has none.
Returns:
* mesh (:class:`iris.experimental.ugrid.mesh.Mesh` or None):
Returns
-------
mesh : :class:`iris.experimental.ugrid.mesh.Mesh` or None
The mesh of the cube
:class:`~iris.experimental.ugrid.MeshCoord`\\s,
:class:`~iris.experimental.ugrid.MeshCoord`'s,
or ``None``.
"""
Expand All @@ -2383,13 +2381,12 @@ def location(self):
:class:`~iris.experimental.ugrid.MeshCoord`\\ s,
or ``None`` if it has none.
Returns:
* location (str or None):
Returns
-------
location : str or None
The mesh location of the cube
:class:`~iris.experimental.ugrid.MeshCoord`\\s
(i.e. one of 'face' / 'edge' / 'node'),
or ``None``.
:class:`~iris.experimental.ugrid.MeshCoord`'s
(i.e. one of 'face' / 'edge' / 'node'), or ``None``.
"""
result = self._any_meshcoord()
Expand All @@ -2402,10 +2399,10 @@ def mesh_dim(self):
:class:`~iris.experimental.ugrid.MeshCoord`\\ s,
or ``None`` if it has none.
Returns:
* mesh_dim (int, or None):
the cube dimension which the cube
Returns
-------
mesh_dim : int or None
The cube dimension which the cube
:class:`~iris.experimental.ugrid.MeshCoord`\\s map to,
or ``None``.
Expand Down Expand Up @@ -4191,7 +4188,6 @@ def aggregated_by(self, coords, aggregator, climatological=False, **kwargs):
Examples
--------
>>> import iris
>>> import iris.analysis
>>> import iris.coord_categorisation as cat
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/experimental/ugrid/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2140,7 +2140,7 @@ def _add(self, coords):
setattr(self, member_y, coords[1])

def add(self, node_x=None, node_y=None, edge_x=None, edge_y=None):
"""use self.remove(edge_x=True) to remove a coordinate e.g., using the
"""Use self.remove(edge_x=True) to remove a coordinate e.g., using the
pattern self.add(edge_x=None) will not remove the edge_x coordinate.
"""
Expand Down
15 changes: 7 additions & 8 deletions lib/iris/fileformats/_nc_load_rules/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,10 @@ def _split_cell_methods(nc_cell_methods: str) -> List[re.Match]:
* nc_cell_methods: The value of the cell methods attribute to be split.
Returns:
* nc_cell_methods_matches: A list of the re.Match objects associated with
each parsed cell method
Returns
-------
nc_cell_methods_matches: list of re.Match objects
A list of re.Match objects associated with each parsed cell method
Splitting is done based on words followed by colons outside of any brackets.
Validation of anything other than being laid out in the expected format is
Expand Down Expand Up @@ -337,10 +337,9 @@ def parse_cell_methods(nc_cell_methods):
* nc_cell_methods (str):
The value of the cell methods attribute to be parsed.
Returns:
* cell_methods
An iterable of :class:`iris.coords.CellMethod`.
Returns
-------
iterable of :class:`iris.coords.CellMethod`.
Multiple coordinates, intervals and comments are supported.
If a method has a non-standard name a warning will be issued, but the
Expand Down
5 changes: 2 additions & 3 deletions lib/iris/fileformats/cf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
according to the 'NetCDF Climate and Forecast (CF) Metadata Conventions'.
References:
[CF] NetCDF Climate and Forecast (CF) Metadata conventions.
[NUG] NetCDF User's Guide, https://www.unidata.ucar.edu/software/netcdf/documentation/NUG/
[CF] NetCDF Climate and Forecast (CF) Metadata conventions.
[NUG] NetCDF User's Guide, https://www.unidata.ucar.edu/software/netcdf/documentation/NUG/
"""

Expand Down
Loading

0 comments on commit 0ea8489

Please sign in to comment.