From b3755b00fdad6e1aff3f47299adb918412e239af Mon Sep 17 00:00:00 2001 From: Tremain Knight <2108488+tkknight@users.noreply.github.com> Date: Sun, 17 Dec 2023 14:56:10 +0000 Subject: [PATCH 1/7] fixed for ruff rule D400. --- .ruff.toml | 1 - lib/iris/analysis/_regrid.py | 1 + lib/iris/analysis/_scipy_interpolate.py | 4 ++-- lib/iris/analysis/geometry.py | 2 +- lib/iris/common/metadata.py | 2 +- lib/iris/coord_systems.py | 2 +- lib/iris/coords.py | 10 ++++++---- lib/iris/cube.py | 6 +++--- lib/iris/experimental/animate.py | 2 +- lib/iris/experimental/representation.py | 2 +- lib/iris/experimental/ugrid/__init__.py | 2 +- lib/iris/experimental/ugrid/mesh.py | 4 ++-- .../_structured_array_identification.py | 2 +- lib/iris/fileformats/name_loaders.py | 2 +- lib/iris/fileformats/nimrod.py | 2 +- lib/iris/fileformats/pp.py | 9 +++++---- lib/iris/fileformats/pp_save_rules.py | 2 +- lib/iris/fileformats/um/_fast_load.py | 4 +++- .../um/_fast_load_structured_fields.py | 4 +++- lib/iris/pandas.py | 2 +- lib/iris/plot.py | 2 +- lib/iris/tests/graphics/__init__.py | 2 +- lib/iris/tests/graphics/idiff.py | 2 +- lib/iris/tests/graphics/recreate_imagerepo.py | 2 +- lib/iris/tests/integration/plot/test_colorbar.py | 2 +- lib/iris/tests/stock/__init__.py | 2 +- lib/iris/tests/test_coding_standards.py | 2 +- lib/iris/tests/test_coordsystem.py | 4 ++-- lib/iris/tests/test_cube_to_pp.py | 4 ++-- lib/iris/tests/test_file_save.py | 16 ++++++++-------- lib/iris/tests/test_intersect.py | 2 +- lib/iris/tests/test_netcdf.py | 4 ++-- lib/iris/tests/test_plot.py | 2 +- lib/iris/tests/test_std_names.py | 2 +- lib/iris/tests/test_util.py | 2 +- .../cartography/test__get_lon_lat_coords.py | 2 +- .../analysis/cartography/test__quadrant_area.py | 2 +- .../unit/analysis/cartography/test__xy_range.py | 2 +- .../analysis/cartography/test_area_weights.py | 2 +- .../test_RectilinearInterpolator.py | 2 +- .../unit/common/lenient/test__lenient_client.py | 4 ++-- .../unit/common/lenient/test__lenient_service.py | 4 ++-- lib/iris/tests/unit/coords/test_Cell.py | 2 +- lib/iris/tests/unit/cube/test_Cube.py | 10 +++++++--- .../tests/unit/cube/test_Cube__aggregated_by.py | 2 +- .../nc_load_rules/helpers/test_get_names.py | 2 +- lib/iris/tests/unit/fileformats/test_rules.py | 2 +- lib/iris/tests/unit/pandas/test_pandas.py | 6 +++--- lib/iris/tests/unit/plot/test_plot.py | 4 ++-- lib/iris/tests/unit/util/test__coord_regular.py | 1 + lib/iris/tests/unit/util/test__mask_array.py | 2 +- .../tests/unit/util/test_equalise_attributes.py | 2 +- .../tests/unit/util/test_find_discontiguities.py | 2 +- lib/iris/tests/unit/util/test_mask_cube.py | 2 +- lib/iris/util.py | 2 +- 55 files changed, 92 insertions(+), 80 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index e09d03c2d4..56200b8c8c 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -43,7 +43,6 @@ lint.ignore = [ "D214", # Section is over-indented "D300", # triple double quotes `""" / Use triple single quotes `'''` "D301", # Use `r"""` if any backslashes in a docstring - "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" diff --git a/lib/iris/analysis/_regrid.py b/lib/iris/analysis/_regrid.py index 61b4d31204..3e9074fc6b 100644 --- a/lib/iris/analysis/_regrid.py +++ b/lib/iris/analysis/_regrid.py @@ -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 diff --git a/lib/iris/analysis/_scipy_interpolate.py b/lib/iris/analysis/_scipy_interpolate.py index 1300da6d89..bf1796f91e 100644 --- a/lib/iris/analysis/_scipy_interpolate.py +++ b/lib/iris/analysis/_scipy_interpolate.py @@ -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 @@ -139,7 +139,7 @@ def __init__( self.values = values def __call__(self, xi, method=None): - """Interpolation at coordinates + """Interpolation at coordinates. Parameters ---------- diff --git a/lib/iris/analysis/geometry.py b/lib/iris/analysis/geometry.py index 21c7d05943..a07ef61a76 100644 --- a/lib/iris/analysis/geometry.py +++ b/lib/iris/analysis/geometry.py @@ -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. diff --git a/lib/iris/common/metadata.py b/lib/iris/common/metadata.py index 3b2e909e9e..691e427aa5 100644 --- a/lib/iris/common/metadata.py +++ b/lib/iris/common/metadata.py @@ -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. diff --git a/lib/iris/coord_systems.py b/lib/iris/coord_systems.py index 0ecfae0fb7..60124044f1 100644 --- a/lib/iris/coord_systems.py +++ b/lib/iris/coord_systems.py @@ -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 diff --git a/lib/iris/coords.py b/lib/iris/coords.py index 08bb5ee7d9..9336f1f4c7 100644 --- a/lib/iris/coords.py +++ b/lib/iris/coords.py @@ -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 @@ -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 @@ -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. @@ -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) diff --git a/lib/iris/cube.py b/lib/iris/cube.py index 7e35893533..57c471894d 100644 --- a/lib/iris/cube.py +++ b/lib/iris/cube.py @@ -188,14 +188,14 @@ def __add__(self, other): return CubeList(list.__add__(self, other)) def __getitem__(self, keys): - """x.__getitem__(y) <==> x[y]""" + """x.__getitem__(y) <==> x[y].""" result = super().__getitem__(keys) if isinstance(result, list): result = CubeList(result) return result def __getslice__(self, start, stop): - """x.__getslice__(i, j) <==> x[i:j] + """x.__getslice__(i, j) <==> x[i:j]. Use of negative indices is not supported. @@ -209,7 +209,7 @@ def __iadd__(self, other_cubes): return super(CubeList, self).__iadd__(CubeList(other_cubes)) def __setitem__(self, key, cube_or_sequence): - """Set self[key] to cube or sequence of cubes""" + """Set self[key] to cube or sequence of cubes.""" if isinstance(key, int): # should have single cube. self._assert_is_cube(cube_or_sequence) diff --git a/lib/iris/experimental/animate.py b/lib/iris/experimental/animate.py index b660ae2a1a..5c9fa77bf8 100644 --- a/lib/iris/experimental/animate.py +++ b/lib/iris/experimental/animate.py @@ -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. -"""Wrapper for animating iris cubes using iris or matplotlib plotting functions +"""Wrapper for animating iris cubes using iris or matplotlib plotting functions. Notes ----- diff --git a/lib/iris/experimental/representation.py b/lib/iris/experimental/representation.py index 9acd926eb2..fd063a5475 100644 --- a/lib/iris/experimental/representation.py +++ b/lib/iris/experimental/representation.py @@ -202,7 +202,7 @@ def _make_shapes_row(self): def _make_row(self, title, body=None, col_span=0): """Produce one row for the table body; i.e. - Coord namex-... + Coord namex-.... `body` contains the content for each cell not in the left-most (title) column. diff --git a/lib/iris/experimental/ugrid/__init__.py b/lib/iris/experimental/ugrid/__init__.py index 58695912c6..7cae55a1bd 100644 --- a/lib/iris/experimental/ugrid/__init__.py +++ b/lib/iris/experimental/ugrid/__init__.py @@ -4,7 +4,7 @@ # See LICENSE in the root of the repository for full licensing details. """Infra-structure for unstructured mesh support, based on -CF UGRID Conventions (v1.0), https://ugrid-conventions.github.io/ugrid-conventions/ +CF UGRID Conventions (v1.0), https://ugrid-conventions.github.io/ugrid-conventions/. .. note:: diff --git a/lib/iris/experimental/ugrid/mesh.py b/lib/iris/experimental/ugrid/mesh.py index 02b26f41f1..8b77cf9983 100644 --- a/lib/iris/experimental/ugrid/mesh.py +++ b/lib/iris/experimental/ugrid/mesh.py @@ -1953,7 +1953,7 @@ def topology_dimension(self): class _Mesh1DCoordinateManager: """TBD: require clarity on coord_systems validation TBD: require clarity on __eq__ support - TBD: rationalise self.coords() logic with other manager and Cube + TBD: rationalise self.coords() logic with other manager and Cube. """ @@ -2141,7 +2141,7 @@ def _add(self, coords): 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 - pattern self.add(edge_x=None) will not remove the edge_x coordinate + pattern self.add(edge_x=None) will not remove the edge_x coordinate. """ self._add(MeshNodeCoords(node_x, node_y)) diff --git a/lib/iris/fileformats/_structured_array_identification.py b/lib/iris/fileformats/_structured_array_identification.py index e9f8d36324..05bd04036b 100644 --- a/lib/iris/fileformats/_structured_array_identification.py +++ b/lib/iris/fileformats/_structured_array_identification.py @@ -291,7 +291,7 @@ class GroupStructure: """ def __init__(self, length, component_structure, array_order="c"): - """group_component_to_array - a dictionary. See also TODO""" + """group_component_to_array - a dictionary. See also TODO.""" #: The size common to all of the original arrays and used to determine #: possible shape configurations. self.length = length diff --git a/lib/iris/fileformats/name_loaders.py b/lib/iris/fileformats/name_loaders.py index 8e1a9f5f9d..e6acb6aa66 100644 --- a/lib/iris/fileformats/name_loaders.py +++ b/lib/iris/fileformats/name_loaders.py @@ -211,7 +211,7 @@ def _calc_integration_period(time_avgs): def _parse_units(units): - """Return a known :class:`cf_units.Unit` given a NAME unit + """Return a known :class:`cf_units.Unit` given a NAME unit. .. note:: diff --git a/lib/iris/fileformats/nimrod.py b/lib/iris/fileformats/nimrod.py index b070b80d69..3aea8b8b81 100644 --- a/lib/iris/fileformats/nimrod.py +++ b/lib/iris/fileformats/nimrod.py @@ -240,7 +240,7 @@ def _read_header(self, infile): ) def _read_data(self, infile): - """Read the data array: int8, int16, int32 or float32 + """Read the data array: int8, int16, int32 or float32. (surrounded by 4-byte length, at start and end) diff --git a/lib/iris/fileformats/pp.py b/lib/iris/fileformats/pp.py index f6eb3d7168..d91a338c61 100644 --- a/lib/iris/fileformats/pp.py +++ b/lib/iris/fileformats/pp.py @@ -973,7 +973,7 @@ def __repr__(self): @property def stash(self): """Stash property giving access to the associated STASH object, - now supporting __eq__ + now supporting __eq__. """ if ( @@ -1052,7 +1052,7 @@ def lbproc(self, value): @property def data(self): """:class:`numpy.ndarray` representing the multidimensional data - of the pp file + of the pp file. """ if is_lazy_data(self._data): @@ -1126,7 +1126,8 @@ def y_bounds(self): def save(self, file_handle): """Save the PPField to the given file object. - (typically created with :func:`open`):: + + Typically created with :func:`open`:: # to append the field to a file with open(filename, 'ab') as fh: @@ -1976,7 +1977,7 @@ def _make_func(stashobj): def pp_filter(field): """Return True if field is to be kept, - False if field does not match filter + False if field does not match filter. """ res = True diff --git a/lib/iris/fileformats/pp_save_rules.py b/lib/iris/fileformats/pp_save_rules.py index 376c4a3632..60eef7ad96 100644 --- a/lib/iris/fileformats/pp_save_rules.py +++ b/lib/iris/fileformats/pp_save_rules.py @@ -815,7 +815,7 @@ def _vertical_rules(cube, pp): def _all_other_rules(cube, pp): - """Fields currently managed by these rules: + """Fields currently managed by these rules. * lbfc (field code) * lbrsvd[3] (ensemble member number) diff --git a/lib/iris/fileformats/um/_fast_load.py b/lib/iris/fileformats/um/_fast_load.py index 6ab4f20374..477a221727 100644 --- a/lib/iris/fileformats/um/_fast_load.py +++ b/lib/iris/fileformats/um/_fast_load.py @@ -47,7 +47,9 @@ class FieldCollation(BasicFieldCollation): # class, now renamed 'BasicFieldCollation'. def __init__(self, fields, filepath): - """Args: + """FieldCollation initialise. + + Args: * fields (iterable of :class:`iris.fileformats.pp.PPField`): The fields in the collation. diff --git a/lib/iris/fileformats/um/_fast_load_structured_fields.py b/lib/iris/fileformats/um/_fast_load_structured_fields.py index 26f2816891..41ec8720bc 100644 --- a/lib/iris/fileformats/um/_fast_load_structured_fields.py +++ b/lib/iris/fileformats/um/_fast_load_structured_fields.py @@ -45,7 +45,9 @@ class BasicFieldCollation: """ def __init__(self, fields): - """Args: + """BasicFieldCollation initialise. + + Args: * fields (iterable of :class:`iris.fileformats.pp.PPField`): The fields in the collation. diff --git a/lib/iris/pandas.py b/lib/iris/pandas.py index c5b4b0b498..0222c569b3 100644 --- a/lib/iris/pandas.py +++ b/lib/iris/pandas.py @@ -803,7 +803,7 @@ def as_data_frame( """ def merge_metadata(meta_var_list): - """Add auxiliary cube metadata to the DataFrame""" + """Add auxiliary cube metadata to the DataFrame.""" nonlocal data_frame for meta_var_name, meta_var_index, meta_var in meta_var_list: if not meta_var_index: diff --git a/lib/iris/plot.py b/lib/iris/plot.py index 667af06af1..b4e20c57af 100644 --- a/lib/iris/plot.py +++ b/lib/iris/plot.py @@ -255,7 +255,7 @@ def ticker_func(tick_location, _): def _invert_yaxis(v_coord, axes=None): - """Inverts the y-axis of the current plot based on conditions: + """Inverts the y-axis of the current plot based on conditions. * If the y-axis is already inverted we don't want to re-invert it. * If v_coord is None then it will not have any attributes. diff --git a/lib/iris/tests/graphics/__init__.py b/lib/iris/tests/graphics/__init__.py index c62ac1bf0e..366ad47bb7 100755 --- a/lib/iris/tests/graphics/__init__.py +++ b/lib/iris/tests/graphics/__init__.py @@ -3,7 +3,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. # !/usr/bin/env python -"""Contains Iris graphic testing utilities +"""Contains Iris graphic testing utilities. By default, this module sets the matplotlib backend to "agg". But when this module is imported it checks ``sys.argv`` for the flag "-d". If diff --git a/lib/iris/tests/graphics/idiff.py b/lib/iris/tests/graphics/idiff.py index 53d74caf27..50deec3df1 100755 --- a/lib/iris/tests/graphics/idiff.py +++ b/lib/iris/tests/graphics/idiff.py @@ -35,7 +35,7 @@ def extract_test_key(result_image_name): - """Extracts the name of the test which a result image refers to""" + """Extracts the name of the test which a result image refers to.""" name_match = _RESULT_NAME_PATTERN.match(str(result_image_name)) if name_match: test_key = name_match.group(1) diff --git a/lib/iris/tests/graphics/recreate_imagerepo.py b/lib/iris/tests/graphics/recreate_imagerepo.py index 96a0e54f2b..2e9a99a39a 100755 --- a/lib/iris/tests/graphics/recreate_imagerepo.py +++ b/lib/iris/tests/graphics/recreate_imagerepo.py @@ -3,7 +3,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. # !/usr/bin/env python -"""Updates imagerepo.json based on the baseline images +"""Updates imagerepo.json based on the baseline images. """ diff --git a/lib/iris/tests/integration/plot/test_colorbar.py b/lib/iris/tests/integration/plot/test_colorbar.py index 9aa856934c..4a3fd27a80 100644 --- a/lib/iris/tests/integration/plot/test_colorbar.py +++ b/lib/iris/tests/integration/plot/test_colorbar.py @@ -3,7 +3,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. """Test interaction between :mod:`iris.plot` and -:func:`matplotlib.pyplot.colorbar` +:func:`matplotlib.pyplot.colorbar`. """ diff --git a/lib/iris/tests/stock/__init__.py b/lib/iris/tests/stock/__init__.py index ca5adb21fc..894cc1d02c 100644 --- a/lib/iris/tests/stock/__init__.py +++ b/lib/iris/tests/stock/__init__.py @@ -650,7 +650,7 @@ def realistic_4d(): def realistic_4d_no_derived(): - """Returns a realistic 4d cube without hybrid height + """Returns a realistic 4d cube without hybrid height. >>> print(repr(realistic_4d())) Date: Sun, 17 Dec 2023 15:45:12 +0000 Subject: [PATCH 2/7] additional fixes. --- benchmarks/benchmarks/aux_factory.py | 2 +- benchmarks/benchmarks/coords.py | 2 +- benchmarks/benchmarks/cube.py | 2 +- benchmarks/benchmarks/import_iris.py | 4 +++- benchmarks/benchmarks/regridding.py | 2 +- benchmarks/benchmarks/trajectory.py | 2 +- .../developers_guide/documenting/docstrings_attribute.py | 2 +- pyproject.toml | 9 +++++++++ 8 files changed, 18 insertions(+), 7 deletions(-) diff --git a/benchmarks/benchmarks/aux_factory.py b/benchmarks/benchmarks/aux_factory.py index 49dc6a368c..aed50c2854 100644 --- a/benchmarks/benchmarks/aux_factory.py +++ b/benchmarks/benchmarks/aux_factory.py @@ -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): diff --git a/benchmarks/benchmarks/coords.py b/benchmarks/benchmarks/coords.py index 1c8f49967a..930cddb4f1 100644 --- a/benchmarks/benchmarks/coords.py +++ b/benchmarks/benchmarks/coords.py @@ -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): diff --git a/benchmarks/benchmarks/cube.py b/benchmarks/benchmarks/cube.py index f11e135996..8fcea35499 100644 --- a/benchmarks/benchmarks/cube.py +++ b/benchmarks/benchmarks/cube.py @@ -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): diff --git a/benchmarks/benchmarks/import_iris.py b/benchmarks/benchmarks/import_iris.py index 37c98bee09..fbae82fee6 100644 --- a/benchmarks/benchmarks/import_iris.py +++ b/benchmarks/benchmarks/import_iris.py @@ -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 diff --git a/benchmarks/benchmarks/regridding.py b/benchmarks/benchmarks/regridding.py index 1f8f2e3740..8e1c5e33df 100644 --- a/benchmarks/benchmarks/regridding.py +++ b/benchmarks/benchmarks/regridding.py @@ -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. """ diff --git a/benchmarks/benchmarks/trajectory.py b/benchmarks/benchmarks/trajectory.py index 79466d3804..4214ed3f6e 100644 --- a/benchmarks/benchmarks/trajectory.py +++ b/benchmarks/benchmarks/trajectory.py @@ -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. """ diff --git a/docs/src/developers_guide/documenting/docstrings_attribute.py b/docs/src/developers_guide/documenting/docstrings_attribute.py index 18bb0c9c6f..9485ca5af7 100644 --- a/docs/src/developers_guide/documenting/docstrings_attribute.py +++ b/docs/src/developers_guide/documenting/docstrings_attribute.py @@ -1,5 +1,5 @@ class ExampleClass: - """Class Summary""" + """Class Summary.""" def __init__(self, arg1, arg2): """Purpose section description. diff --git a/pyproject.toml b/pyproject.toml index acbb0c9c4b..ae1a0e63f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,8 @@ extend-exclude = [ "um_cf_map.py", "docs/src/sphinxext", "tools", + # excluded else the gallery page title breaks the make html + "docs/gallery_code" # TREMTEST ] line-length = 88 src = [ @@ -94,6 +96,13 @@ ignore = [ "D212", # Multi-line docstring summary should start at the first line ] +# TREMTEST +#[too.ruff.per-file-ignores] +# Ignore D400: "First line should end witrh a period." +# Otherwise it breaks the gallery titles. +#"docs/gallery_code/general/plot_custom_file_loading.py" = ["D400"] +#"docs/gallery_code/general/*" = ["D400"] + [tool.ruff.lint.isort] force-sort-within-sections = true known-first-party = ["iris"] From f097b3f60af38b57f269e418a24d01549209db7b Mon Sep 17 00:00:00 2001 From: Tremain Knight <2108488+tkknight@users.noreply.github.com> Date: Sun, 17 Dec 2023 16:11:07 +0000 Subject: [PATCH 3/7] update testing --- lib/iris/tests/unit/common/lenient/test__lenient_client.py | 4 ++-- lib/iris/tests/unit/common/lenient/test__lenient_service.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/iris/tests/unit/common/lenient/test__lenient_client.py b/lib/iris/tests/unit/common/lenient/test__lenient_client.py index 08e56c025e..a0c630bc21 100644 --- a/lib/iris/tests/unit/common/lenient/test__lenient_client.py +++ b/lib/iris/tests/unit/common/lenient/test__lenient_client.py @@ -78,7 +78,7 @@ def test_call_naked_doc(self): def myclient(): """myclient doc-string.""" - self.assertEqual(myclient.__doc__, "myclient doc-string") + self.assertEqual(myclient.__doc__, "myclient doc-string.") def test_call_no_kwargs(self): @_lenient_client() @@ -171,7 +171,7 @@ def test_call_doc(self): def myclient(): """myclient doc-string.""" - self.assertEqual(myclient.__doc__, "myclient doc-string") + self.assertEqual(myclient.__doc__, "myclient doc-string.") if __name__ == "__main__": diff --git a/lib/iris/tests/unit/common/lenient/test__lenient_service.py b/lib/iris/tests/unit/common/lenient/test__lenient_service.py index 740d05efec..6e53aeb952 100644 --- a/lib/iris/tests/unit/common/lenient/test__lenient_service.py +++ b/lib/iris/tests/unit/common/lenient/test__lenient_service.py @@ -69,7 +69,7 @@ def test_call_naked_doc(self): def myservice(): """myservice doc-string.""" - self.assertEqual(myservice.__doc__, "myservice doc-string") + self.assertEqual(myservice.__doc__, "myservice doc-string.") def test_call(self): @_lenient_service() @@ -107,7 +107,7 @@ def test_call_doc(self): def myservice(): """myservice doc-string.""" - self.assertEqual(myservice.__doc__, "myservice doc-string") + self.assertEqual(myservice.__doc__, "myservice doc-string.") if __name__ == "__main__": From 72b40a5aa981a9e1fb1ca13801646a6b86947cea Mon Sep 17 00:00:00 2001 From: Tremain Knight <2108488+tkknight@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:58:21 +0000 Subject: [PATCH 4/7] noqa for the gallery. --- docs/gallery_code/general/plot_SOI_filtering.py | 2 +- docs/gallery_code/general/plot_anomaly_log_colouring.py | 2 +- docs/gallery_code/general/plot_coriolis.py | 2 +- docs/gallery_code/general/plot_cross_section.py | 2 +- docs/gallery_code/general/plot_custom_aggregation.py | 2 +- docs/gallery_code/general/plot_custom_file_loading.py | 2 +- docs/gallery_code/general/plot_global_map.py | 2 +- docs/gallery_code/general/plot_inset.py | 2 +- docs/gallery_code/general/plot_lineplot_with_legend.py | 2 +- docs/gallery_code/general/plot_polar_stereo.py | 2 +- docs/gallery_code/general/plot_polynomial_fit.py | 2 +- .../general/plot_projections_and_annotations.py | 2 +- docs/gallery_code/general/plot_rotated_pole_mapping.py | 2 +- docs/gallery_code/general/plot_zonal_means.py | 2 +- docs/gallery_code/meteorology/plot_COP_1d.py | 2 +- docs/gallery_code/meteorology/plot_COP_maps.py | 2 +- docs/gallery_code/meteorology/plot_TEC.py | 2 +- docs/gallery_code/meteorology/plot_deriving_phenomena.py | 2 +- docs/gallery_code/meteorology/plot_hovmoller.py | 2 +- docs/gallery_code/meteorology/plot_lagged_ensemble.py | 2 +- docs/gallery_code/meteorology/plot_wind_barbs.py | 2 +- docs/gallery_code/meteorology/plot_wind_speed.py | 2 +- docs/gallery_code/oceanography/plot_atlantic_profiles.py | 2 +- docs/gallery_code/oceanography/plot_load_nemo.py | 2 +- docs/gallery_code/oceanography/plot_orca_projection.py | 2 +- pyproject.toml | 9 --------- 26 files changed, 25 insertions(+), 34 deletions(-) diff --git a/docs/gallery_code/general/plot_SOI_filtering.py b/docs/gallery_code/general/plot_SOI_filtering.py index 372369d450..9c4fad51bd 100644 --- a/docs/gallery_code/general/plot_SOI_filtering.py +++ b/docs/gallery_code/general/plot_SOI_filtering.py @@ -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 diff --git a/docs/gallery_code/general/plot_anomaly_log_colouring.py b/docs/gallery_code/general/plot_anomaly_log_colouring.py index af15868387..98751b0dbf 100644 --- a/docs/gallery_code/general/plot_anomaly_log_colouring.py +++ b/docs/gallery_code/general/plot_anomaly_log_colouring.py @@ -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 diff --git a/docs/gallery_code/general/plot_coriolis.py b/docs/gallery_code/general/plot_coriolis.py index 37be139dd3..3d5aa853e3 100644 --- a/docs/gallery_code/general/plot_coriolis.py +++ b/docs/gallery_code/general/plot_coriolis.py @@ -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 diff --git a/docs/gallery_code/general/plot_cross_section.py b/docs/gallery_code/general/plot_cross_section.py index f4fc0a2ecc..8eac3955b1 100644 --- a/docs/gallery_code/general/plot_cross_section.py +++ b/docs/gallery_code/general/plot_cross_section.py @@ -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 diff --git a/docs/gallery_code/general/plot_custom_aggregation.py b/docs/gallery_code/general/plot_custom_aggregation.py index e42144d777..521d0069b9 100644 --- a/docs/gallery_code/general/plot_custom_aggregation.py +++ b/docs/gallery_code/general/plot_custom_aggregation.py @@ -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 diff --git a/docs/gallery_code/general/plot_custom_file_loading.py b/docs/gallery_code/general/plot_custom_file_loading.py index d76ea877b2..53781ba044 100644 --- a/docs/gallery_code/general/plot_custom_file_loading.py +++ b/docs/gallery_code/general/plot_custom_file_loading.py @@ -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 diff --git a/docs/gallery_code/general/plot_global_map.py b/docs/gallery_code/general/plot_global_map.py index dbf05d773d..9634fc1458 100644 --- a/docs/gallery_code/general/plot_global_map.py +++ b/docs/gallery_code/general/plot_global_map.py @@ -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 diff --git a/docs/gallery_code/general/plot_inset.py b/docs/gallery_code/general/plot_inset.py index b173fb2044..7b7e04c7d3 100644 --- a/docs/gallery_code/general/plot_inset.py +++ b/docs/gallery_code/general/plot_inset.py @@ -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 diff --git a/docs/gallery_code/general/plot_lineplot_with_legend.py b/docs/gallery_code/general/plot_lineplot_with_legend.py index 81b89c8d55..981e9694ec 100644 --- a/docs/gallery_code/general/plot_lineplot_with_legend.py +++ b/docs/gallery_code/general/plot_lineplot_with_legend.py @@ -1,7 +1,7 @@ """Multi-Line Temperature Profile Plot ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -""" +""" # noqa: D400 import matplotlib.pyplot as plt diff --git a/docs/gallery_code/general/plot_polar_stereo.py b/docs/gallery_code/general/plot_polar_stereo.py index 27201018d4..0cb4e533fa 100644 --- a/docs/gallery_code/general/plot_polar_stereo.py +++ b/docs/gallery_code/general/plot_polar_stereo.py @@ -4,7 +4,7 @@ Demonstrates plotting data that are defined on a polar stereographic projection. -""" +""" # noqa: D400 import matplotlib.pyplot as plt diff --git a/docs/gallery_code/general/plot_polynomial_fit.py b/docs/gallery_code/general/plot_polynomial_fit.py index 10e844af1a..951f17209e 100644 --- a/docs/gallery_code/general/plot_polynomial_fit.py +++ b/docs/gallery_code/general/plot_polynomial_fit.py @@ -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 diff --git a/docs/gallery_code/general/plot_projections_and_annotations.py b/docs/gallery_code/general/plot_projections_and_annotations.py index 7ddee9531c..1a4701837a 100644 --- a/docs/gallery_code/general/plot_projections_and_annotations.py +++ b/docs/gallery_code/general/plot_projections_and_annotations.py @@ -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 diff --git a/docs/gallery_code/general/plot_rotated_pole_mapping.py b/docs/gallery_code/general/plot_rotated_pole_mapping.py index 0233ade6a7..3674e89e28 100644 --- a/docs/gallery_code/general/plot_rotated_pole_mapping.py +++ b/docs/gallery_code/general/plot_rotated_pole_mapping.py @@ -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 diff --git a/docs/gallery_code/general/plot_zonal_means.py b/docs/gallery_code/general/plot_zonal_means.py index 3f6e043547..47a7127d06 100644 --- a/docs/gallery_code/general/plot_zonal_means.py +++ b/docs/gallery_code/general/plot_zonal_means.py @@ -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 diff --git a/docs/gallery_code/meteorology/plot_COP_1d.py b/docs/gallery_code/meteorology/plot_COP_1d.py index 6cdbd50114..1f56a7b293 100644 --- a/docs/gallery_code/meteorology/plot_COP_1d.py +++ b/docs/gallery_code/meteorology/plot_COP_1d.py @@ -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 diff --git a/docs/gallery_code/meteorology/plot_COP_maps.py b/docs/gallery_code/meteorology/plot_COP_maps.py index 108407c09e..714ee8896b 100644 --- a/docs/gallery_code/meteorology/plot_COP_maps.py +++ b/docs/gallery_code/meteorology/plot_COP_maps.py @@ -19,7 +19,7 @@ Analyses, and Scenarios. Eos Trans. AGU, Vol 90, No. 21, doi:10.1029/2009EO210001. -""" +""" # noqa: D400 import os.path diff --git a/docs/gallery_code/meteorology/plot_TEC.py b/docs/gallery_code/meteorology/plot_TEC.py index 50619ca870..cb642af588 100644 --- a/docs/gallery_code/meteorology/plot_TEC.py +++ b/docs/gallery_code/meteorology/plot_TEC.py @@ -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 diff --git a/docs/gallery_code/meteorology/plot_deriving_phenomena.py b/docs/gallery_code/meteorology/plot_deriving_phenomena.py index bd9775e657..ef78d2f1c9 100644 --- a/docs/gallery_code/meteorology/plot_deriving_phenomena.py +++ b/docs/gallery_code/meteorology/plot_deriving_phenomena.py @@ -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 diff --git a/docs/gallery_code/meteorology/plot_hovmoller.py b/docs/gallery_code/meteorology/plot_hovmoller.py index 2e76be98d6..6c1f1a800a 100644 --- a/docs/gallery_code/meteorology/plot_hovmoller.py +++ b/docs/gallery_code/meteorology/plot_hovmoller.py @@ -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 diff --git a/docs/gallery_code/meteorology/plot_lagged_ensemble.py b/docs/gallery_code/meteorology/plot_lagged_ensemble.py index 32798c124f..a8887238d4 100644 --- a/docs/gallery_code/meteorology/plot_lagged_ensemble.py +++ b/docs/gallery_code/meteorology/plot_lagged_ensemble.py @@ -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 diff --git a/docs/gallery_code/meteorology/plot_wind_barbs.py b/docs/gallery_code/meteorology/plot_wind_barbs.py index 4f776144e6..9745a40db2 100644 --- a/docs/gallery_code/meteorology/plot_wind_barbs.py +++ b/docs/gallery_code/meteorology/plot_wind_barbs.py @@ -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 diff --git a/docs/gallery_code/meteorology/plot_wind_speed.py b/docs/gallery_code/meteorology/plot_wind_speed.py index a1820e980e..dde87824fd 100644 --- a/docs/gallery_code/meteorology/plot_wind_speed.py +++ b/docs/gallery_code/meteorology/plot_wind_speed.py @@ -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 diff --git a/docs/gallery_code/oceanography/plot_atlantic_profiles.py b/docs/gallery_code/oceanography/plot_atlantic_profiles.py index 3886c61aff..736ddbe7fb 100644 --- a/docs/gallery_code/oceanography/plot_atlantic_profiles.py +++ b/docs/gallery_code/oceanography/plot_atlantic_profiles.py @@ -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 diff --git a/docs/gallery_code/oceanography/plot_load_nemo.py b/docs/gallery_code/oceanography/plot_load_nemo.py index 52fbb33484..77c95e2353 100644 --- a/docs/gallery_code/oceanography/plot_load_nemo.py +++ b/docs/gallery_code/oceanography/plot_load_nemo.py @@ -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 diff --git a/docs/gallery_code/oceanography/plot_orca_projection.py b/docs/gallery_code/oceanography/plot_orca_projection.py index d9968de0ae..33e3ecac46 100644 --- a/docs/gallery_code/oceanography/plot_orca_projection.py +++ b/docs/gallery_code/oceanography/plot_orca_projection.py @@ -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 diff --git a/pyproject.toml b/pyproject.toml index ae1a0e63f8..acbb0c9c4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,8 +66,6 @@ extend-exclude = [ "um_cf_map.py", "docs/src/sphinxext", "tools", - # excluded else the gallery page title breaks the make html - "docs/gallery_code" # TREMTEST ] line-length = 88 src = [ @@ -96,13 +94,6 @@ ignore = [ "D212", # Multi-line docstring summary should start at the first line ] -# TREMTEST -#[too.ruff.per-file-ignores] -# Ignore D400: "First line should end witrh a period." -# Otherwise it breaks the gallery titles. -#"docs/gallery_code/general/plot_custom_file_loading.py" = ["D400"] -#"docs/gallery_code/general/*" = ["D400"] - [tool.ruff.lint.isort] force-sort-within-sections = true known-first-party = ["iris"] From a79c450c3c35d14efb90d52706a84bd1805bf9a4 Mon Sep 17 00:00:00 2001 From: Tremain Knight <2108488+tkknight@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:09:31 +0000 Subject: [PATCH 5/7] merge fix --- lib/iris/tests/graphics/__init__.py | 1 - lib/iris/tests/graphics/recreate_imagerepo.py | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/iris/tests/graphics/__init__.py b/lib/iris/tests/graphics/__init__.py index 595a2e415a..a1b6b24bcc 100644 --- a/lib/iris/tests/graphics/__init__.py +++ b/lib/iris/tests/graphics/__init__.py @@ -2,7 +2,6 @@ # # 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. -# !/usr/bin/env python """Contains Iris graphic testing utilities. By default, this module sets the matplotlib backend to "agg". But when diff --git a/lib/iris/tests/graphics/recreate_imagerepo.py b/lib/iris/tests/graphics/recreate_imagerepo.py index e91567be95..ae12eb447d 100755 --- a/lib/iris/tests/graphics/recreate_imagerepo.py +++ b/lib/iris/tests/graphics/recreate_imagerepo.py @@ -3,7 +3,6 @@ # # 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. -# !/usr/bin/env python """Updates imagerepo.json based on the baseline images. """ From 7ddbfcf0384f094975d81a93f7144d710f3dd324 Mon Sep 17 00:00:00 2001 From: Tremain Knight <2108488+tkknight@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:12:27 +0000 Subject: [PATCH 6/7] fix a ",." in docstring --- lib/iris/tests/test_plot.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/iris/tests/test_plot.py b/lib/iris/tests/test_plot.py index b846ebdda0..35133a39d5 100644 --- a/lib/iris/tests/test_plot.py +++ b/lib/iris/tests/test_plot.py @@ -782,9 +782,9 @@ def setUp(self): def load_cube_once(filename, constraint): - """Same syntax as load_cube, but will only load a file once,. + """Same syntax as load_cube, but will only load a file once. - then cache the answer in a dictionary. + Then cache the answer in a dictionary. """ global _load_cube_once_cache From 92e449de370b73ce2352a400c3195e219c089204 Mon Sep 17 00:00:00 2001 From: Tremain Knight <2108488+tkknight@users.noreply.github.com> Date: Mon, 18 Dec 2023 15:15:32 +0000 Subject: [PATCH 7/7] removed D400 ignore --- .ruff.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/.ruff.toml b/.ruff.toml index def056b85f..6eff54c7de 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -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"