Skip to content

Commit

Permalink
fix for ruff rule D400 (#5647)
Browse files Browse the repository at this point in the history
* fixed for ruff rule D400.

* additional fixes.

* update testing

* noqa for the gallery.

* merge fix

* fix a ",." in docstring

* removed D400 ignore
  • Loading branch information
tkknight authored Dec 18, 2023
1 parent 67be801 commit 332a779
Show file tree
Hide file tree
Showing 87 changed files with 131 additions and 117 deletions.
1 change: 0 additions & 1 deletion .ruff.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ lint.ignore = [
"D211", # No blank lines allowed before class docstring
"D214", # Section is over-indented
"D300", # triple double quotes `""" / Use triple single quotes `'''`
"D400", # First line should end with a period
"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"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/aux_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class FactoryCommon:
"""

def setup(self):
"""Prevent ASV instantiating (must therefore override setup() in any subclasses.)"""
"""Prevent ASV instantiating (must therefore override setup() in any subclasses.)."""
raise NotImplementedError

def setup_common(self):
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CoordCommon:
"""

def setup(self):
"""Prevent ASV instantiating (must therefore override setup() in any subclasses.)"""
"""Prevent ASV instantiating (must therefore override setup() in any subclasses.)."""
raise NotImplementedError

def setup_common(self):
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ComponentCommon:
"""

def setup(self):
"""Prevent ASV instantiating (must therefore override setup() in any subclasses.)"""
"""Prevent ASV instantiating (must therefore override setup() in any subclasses.)."""
raise NotImplementedError

def create(self):
Expand Down
4 changes: 3 additions & 1 deletion benchmarks/benchmarks/import_iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ class Iris:
@staticmethod
def _import(module_name, reset_colormaps=False):
"""Have experimented with adding sleep() commands into the imported
modules. The results reveal:
modules.
The results reveal:
ASV avoids invoking `import x` if nothing gets called in the
benchmark (some imports were timed, but only those where calls
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/regridding.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of Iris and is released under the BSD license.
# See LICENSE in the root of the repository for full licensing details.
"""Regridding benchmark test
"""Regridding benchmark test.
"""

Expand Down
2 changes: 1 addition & 1 deletion benchmarks/benchmarks/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This file is part of Iris and is released under the BSD license.
# See LICENSE in the root of the repository for full licensing details.
"""Trajectory benchmark test
"""Trajectory benchmark test.
"""

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_SOI_filtering.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
Trenberth K. E. (1984) Signal Versus Noise in the Southern Oscillation.
Monthly Weather Review, Vol 112, pp 326-332
"""
""" # noqa: D400

import matplotlib.pyplot as plt
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_anomaly_log_colouring.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
and :obj:`matplotlib.pyplot.pcolormesh`).
See also: https://en.wikipedia.org/wiki/False_color#Pseudocolor.
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.colors as mcols
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_coriolis.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
associated metadata. It then plots the Coriolis frequency on an orthographic
projection.
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_cross_section.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This example demonstrates contour plots of a cross-sectioned multi-dimensional
cube which features a hybrid height vertical coordinate system.
"""
""" # noqa: D400

import matplotlib.pyplot as plt

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_custom_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
over North America, and we want to calculate in how many years these exceed a
certain temperature over a spell of 5 years or more.
"""
""" # noqa: D400

import matplotlib.pyplot as plt
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_custom_file_loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
function which automatically invokes the ``FormatSpecification`` we defined.
The cube returned from the load function is then used to produce a plot.
"""
""" # noqa: D400

import datetime

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_global_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
This example demonstrates a contour plot of global air temperature. The plot
title and the labels for the axes are automatically derived from the metadata.
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_inset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
and longitude dimensions to plot a temperature series for a single latitude
coordinate, with an inset plot of the data region.
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_lineplot_with_legend.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Multi-Line Temperature Profile Plot
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
"""
""" # noqa: D400

import matplotlib.pyplot as plt

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_polar_stereo.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Demonstrates plotting data that are defined on a polar stereographic
projection.
"""
""" # noqa: D400

import matplotlib.pyplot as plt

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_polynomial_fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
cube, adding the fit to the cube's metadata, and plotting both the 1D data and
the fit.
"""
""" # noqa: D400

import matplotlib.pyplot as plt
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
We plot these over a specified region, in two different map projections.
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_rotated_pole_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* Block plot of contiguous bounded data
* Non native projection and a Natural Earth shaded relief image underlay
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/general/plot_zonal_means.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Zonal Mean Diagram of Air Temperature
=====================================
This example demonstrates aligning a linear plot and a cartographic plot using Matplotlib.
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_COP_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Further details on the aggregation functionality being used in this example
can be found in :ref:`cube-statistics`.
"""
""" # noqa: D400

import matplotlib.pyplot as plt
import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_COP_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Analyses, and Scenarios. Eos Trans. AGU, Vol 90, No. 21,
doi:10.1029/2009EO210001.
"""
""" # noqa: D400

import os.path

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_TEC.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
The plot exhibits an interesting outline effect due to excluding data
values below a certain threshold.
"""
""" # noqa: D400

import matplotlib.pyplot as plt
import numpy.ma as ma
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_deriving_phenomena.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
specific humidity. Finally, the two new cubes are presented side-by-side in a
plot.
"""
""" # noqa: D400

import matplotlib.pyplot as plt
import matplotlib.ticker
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_hovmoller.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
and has been pre-processed to calculate the monthly mean sea surface
temperature.
"""
""" # noqa: D400

import matplotlib.dates as mdates
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_lagged_ensemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
better approach would be to take the climatological mean, calibrated to the
model, from each ensemble member.
"""
""" # noqa: D400

import matplotlib.pyplot as plt
import matplotlib.ticker
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_wind_barbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
The magnitude of the wind in the original data is low and so doesn't illustrate
the full range of barbs. The wind is scaled to simulate a storm that better
illustrates the range of barbs that are available.
"""
""" # noqa: D400

import matplotlib.pyplot as plt

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/meteorology/plot_wind_speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
For the second plot, the data used for the arrows is normalised to produce
arrows with a uniform size on the plot.
"""
""" # noqa: D400

import cartopy.feature as cfeat
import matplotlib.pyplot as plt
Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/oceanography/plot_atlantic_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
presence of the attribute positive=down on the depth coordinate. This means
depth values intuitively increase downward on the y-axis.
"""
""" # noqa: D400

import matplotlib.pyplot as plt

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/oceanography/plot_load_nemo.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
the NEMO model and combine them into a time series in a single cube. The
different time dimensions in these files can prevent Iris from concatenating
them without the intervention shown here.
"""
""" # noqa: D400

import matplotlib.pyplot as plt

Expand Down
2 changes: 1 addition & 1 deletion docs/gallery_code/oceanography/plot_orca_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Second four pcolormesh plots are created from this projected dataset,
using different projections for the output image.
"""
""" # noqa: D400

import cartopy.crs as ccrs
import matplotlib.pyplot as plt
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ExampleClass:
"""Class Summary"""
"""Class Summary."""

def __init__(self, arg1, arg2):
"""Purpose section description.
Expand Down
1 change: 1 addition & 0 deletions lib/iris/analysis/_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,7 @@ def _create_cube(data, src, src_dims, tgt_coords, num_tgt_dims, regrid_callback)
- Horizontal coordinates are copied from the target cube.
- Auxiliary coordinates which span the grid dimensions are
ignored.
Parameters
----------
data : array
Expand Down
4 changes: 2 additions & 2 deletions lib/iris/analysis/_scipy_interpolate.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def _ndim_coords_from_arrays(points, ndim=None):
# 9aeaafb32/scipy/interpolate/interpolate.py#L1400
class _RegularGridInterpolator:

"""Interpolation on a regular grid in arbitrary dimensions
"""Interpolation on a regular grid in arbitrary dimensions.
The data must be defined on a regular grid; the grid spacing however may be
uneven. Linear and nearest-neighbour interpolation are supported. After
Expand Down Expand Up @@ -139,7 +139,7 @@ def __init__(
self.values = values

def __call__(self, xi, method=None):
"""Interpolation at coordinates
"""Interpolation at coordinates.
Parameters
----------
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/analysis/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def _extract_relevant_cube_slice(cube, geometry):
"""Given a shapely geometry object, this helper method returns
the tuple
(subcube, x_coord_of_subcube, y_coord_of_subcube,
(min_x_index, min_y_index, max_x_index, max_y_index))
(min_x_index, min_y_index, max_x_index, max_y_index)).
If cube and geometry don't overlap, returns None.
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/common/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ def _difference_strict_attributes(left, right):


class DimCoordMetadata(CoordMetadata):
"""Metadata container for a :class:`~iris.coords.DimCoord`"""
"""Metadata container for a :class:`~iris.coords.DimCoord`."""

# The "circular" member is stateful only, and does not participate
# in lenient/strict equivalence.
Expand Down
2 changes: 1 addition & 1 deletion lib/iris/coord_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class CoordSystem(metaclass=ABCMeta):
grid_mapping_name = None

def __eq__(self, other):
"""Override equality
"""Override equality.
The `_globe` and `_crs` attributes are not compared because they are
cached properties and completely derived from other attributes. The
Expand Down
10 changes: 6 additions & 4 deletions lib/iris/coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ def __hash__(self):
return hash(id(self))

def __binary_operator__(self, other, mode_constant):
"""Common code which is called by add, sub, mul and div
"""Common code which is called by add, sub, mul and div.
Mode constant is one of ADD, SUB, MUL, DIV, RDIV
Expand Down Expand Up @@ -2470,7 +2470,7 @@ def xml_element(self, doc):
return element

def _xml_id_extra(self, unique_value):
"""Coord specific stuff for the xml id"""
"""Coord specific stuff for the xml id."""
unique_value += str(self.coord_system).encode("utf-8") + b"\0"
return unique_value

Expand Down Expand Up @@ -2934,7 +2934,9 @@ class CellMethod(iris.util._OrderedHashable):
comments = None

def __init__(self, method, coords=None, intervals=None, comments=None):
"""Args:
"""Call Method initialise.
Args:
* method:
The name of the operation.
Expand Down Expand Up @@ -2993,7 +2995,7 @@ def __init__(self, method, coords=None, intervals=None, comments=None):
self._init(method, tuple(_coords), tuple(_intervals), tuple(_comments))

def __str__(self):
"""Return a custom string representation of CellMethod"""
"""Return a custom string representation of CellMethod."""
# Group related coord names intervals and comments together
coord_string = " ".join([f"{coord}:" for coord in self.coord_names])
method_string = str(self.method)
Expand Down
Loading

0 comments on commit 332a779

Please sign in to comment.