diff --git a/.ruff.toml b/.ruff.toml index 5a39e2bbf8..5d78ecdb57 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -29,7 +29,6 @@ lint.ignore = [ "D102", # Missing docstring in public method # (D-3) Temporary, before an initial review, either fix ocurrences or move to (2). "D103", # Missing docstring in public function - "D401", # First line of docstring should be in imperative mood: ... # pyupgrade (UP) # https://docs.astral.sh/ruff/rules/#pyupgrade-up diff --git a/benchmarks/benchmarks/__init__.py b/benchmarks/benchmarks/__init__.py index de03ff3fea..87a77fa5a4 100644 --- a/benchmarks/benchmarks/__init__.py +++ b/benchmarks/benchmarks/__init__.py @@ -10,7 +10,7 @@ def disable_repeat_between_setup(benchmark_object): - """Decorator for benchmarks where object persistence would be inappropriate. + """Benchmarks where object persistence would be inappropriate (decorator). E.g: * Benchmarking data realisation @@ -86,7 +86,7 @@ def addedmem_mb(self): @staticmethod def decorator(decorated_func): - """Decorates this benchmark to track growth in resident memory during execution. + """Benchmark to track growth in resident memory during execution. Intended for use on ASV ``track_`` benchmarks. Applies the :class:`TrackAddedMemoryAllocation` context manager to the benchmark @@ -107,7 +107,9 @@ def _wrapper(*args, **kwargs): def on_demand_benchmark(benchmark_object): - """Decorator. Disables these benchmark(s) unless ON_DEMAND_BENCHARKS env var is set. + """Disables these benchmark(s) unless ON_DEMAND_BENCHARKS env var is set. + + This is a decorator. For benchmarks that, for whatever reason, should not be run by default. E.g: diff --git a/benchmarks/benchmarks/cperf/load.py b/benchmarks/benchmarks/cperf/load.py index 9ace3ad56b..cafc4631c0 100644 --- a/benchmarks/benchmarks/cperf/load.py +++ b/benchmarks/benchmarks/cperf/load.py @@ -10,7 +10,7 @@ @on_demand_benchmark class SingleDiagnosticLoad(SingleDiagnosticMixin): def time_load(self, _, __, ___): - """The 'real world comparison'. + """Perform a 'real world comparison'. * UM coords are always realised (DimCoords). * LFRic coords are not realised by default (MeshCoords). @@ -26,7 +26,7 @@ def time_load(self, _, __, ___): assert coord.has_lazy_bounds() == expecting_lazy_coords def time_load_w_realised_coords(self, _, __, ___): - """A valuable extra comparison where both UM and LFRic coords are realised.""" + """Valuable extra comparison where both UM and LFRic coords are realised.""" cube = self.load() for coord_name in "longitude", "latitude": coord = cube.coord(coord_name) diff --git a/benchmarks/benchmarks/cube.py b/benchmarks/benchmarks/cube.py index fc07d55111..4548d4c28d 100644 --- a/benchmarks/benchmarks/cube.py +++ b/benchmarks/benchmarks/cube.py @@ -45,7 +45,7 @@ def setup(self): raise NotImplementedError def create(self): - """Generic cube creation. + """Create a cube (generic). cube_kwargs allow dynamic inclusion of different components; specified in subclasses. diff --git a/benchmarks/benchmarks/experimental/ugrid/regions_combine.py b/benchmarks/benchmarks/experimental/ugrid/regions_combine.py index 36feb65cbe..10711d0349 100644 --- a/benchmarks/benchmarks/experimental/ugrid/regions_combine.py +++ b/benchmarks/benchmarks/experimental/ugrid/regions_combine.py @@ -92,7 +92,7 @@ def setup_cache(self): ) def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True): - """The combine-tests "standard" setup operation. + """Combine-tests "standard" setup operation. Load the source cubes (full-mesh + region) from disk. These are specific to the cubesize parameter. diff --git a/benchmarks/benchmarks/generate_data/stock.py b/benchmarks/benchmarks/generate_data/stock.py index a04eff6701..17f3b23f92 100644 --- a/benchmarks/benchmarks/generate_data/stock.py +++ b/benchmarks/benchmarks/generate_data/stock.py @@ -49,7 +49,7 @@ def _external(func_name_, temp_file_dir, **kwargs_): def create_file__xios_2d_face_half_levels( temp_file_dir, dataset_name, n_faces=866, n_times=1 ): - """Wrapper for :meth:`iris.tests.stock.netcdf.create_file__xios_2d_face_half_levels`. + """Create file wrapper for :meth:`iris.tests.stock.netcdf.create_file__xios_2d_face_half_levels`. Have taken control of temp_file_dir @@ -67,7 +67,7 @@ def create_file__xios_2d_face_half_levels( def create_file__xios_3d_face_half_levels( temp_file_dir, dataset_name, n_faces=866, n_times=1, n_levels=38 ): - """Wrapper for :meth:`iris.tests.stock.netcdf.create_file__xios_3d_face_half_levels`. + """Create file wrapper for :meth:`iris.tests.stock.netcdf.create_file__xios_3d_face_half_levels`. Have taken control of temp_file_dir @@ -84,7 +84,7 @@ def create_file__xios_3d_face_half_levels( def sample_mesh(n_nodes=None, n_faces=None, n_edges=None, lazy_values=False): - """Wrapper for :meth:iris.tests.stock.mesh.sample_mesh`.""" + """Sample mesh wrapper for :meth:iris.tests.stock.mesh.sample_mesh`.""" def _external(*args, **kwargs): from iris.experimental.ugrid import save_mesh @@ -112,7 +112,7 @@ def _external(*args, **kwargs): def sample_meshcoord(sample_mesh_kwargs=None, location="face", axis="x"): - """Wrapper for :meth:`iris.tests.stock.mesh.sample_meshcoord`. + """Sample meshcoord wrapper for :meth:`iris.tests.stock.mesh.sample_meshcoord`. Parameters deviate from the original as cannot pass a :class:`iris.experimental.ugrid.Mesh to the separate Python instance - must diff --git a/benchmarks/benchmarks/sperf/combine_regions.py b/benchmarks/benchmarks/sperf/combine_regions.py index adc51ef6dc..7d677ed74f 100644 --- a/benchmarks/benchmarks/sperf/combine_regions.py +++ b/benchmarks/benchmarks/sperf/combine_regions.py @@ -83,7 +83,7 @@ def setup_cache(self): ) def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True): - """The combine-tests "standard" setup operation. + """Combine-tests "standard" setup operation. Load the source cubes (full-mesh + region) from disk. These are specific to the cubesize parameter. diff --git a/benchmarks/bm_runner.py b/benchmarks/bm_runner.py index 741ecb8580..10dc5f469a 100644 --- a/benchmarks/bm_runner.py +++ b/benchmarks/bm_runner.py @@ -332,7 +332,7 @@ def add_asv_arguments(self) -> None: @staticmethod @abstractmethod def func(args: argparse.Namespace): - """The function to return when the subparser is parsed. + """Return when the subparser is parsed. `func` is then called, performing the user's selected sub-command. diff --git a/docs/gallery_code/general/plot_custom_file_loading.py b/docs/gallery_code/general/plot_custom_file_loading.py index c7a560ff0f..06de887614 100644 --- a/docs/gallery_code/general/plot_custom_file_loading.py +++ b/docs/gallery_code/general/plot_custom_file_loading.py @@ -90,7 +90,7 @@ def load_NAME_III(filename): - """Loads the Met Office's NAME III grid output files. + """Load the Met Office's NAME III grid output files. Loads the Met Office's NAME III grid output files returning headers, column definitions and data arrays as 3 separate lists. @@ -180,7 +180,7 @@ def load_NAME_III(filename): def NAME_to_cube(filenames, callback): - """Returns a generator of cubes given a list of filenames and a callback.""" + """Return a generator of cubes given a list of filenames and a callback.""" for filename in filenames: header, column_headings, data_arrays = load_NAME_III(filename) diff --git a/docs/gallery_code/meteorology/plot_COP_maps.py b/docs/gallery_code/meteorology/plot_COP_maps.py index 43f25425e5..1c5e865a8f 100644 --- a/docs/gallery_code/meteorology/plot_COP_maps.py +++ b/docs/gallery_code/meteorology/plot_COP_maps.py @@ -32,7 +32,7 @@ def cop_metadata_callback(cube, field, filename): - """Function which adds an "Experiment" coordinate which comes from the filename.""" + """Add an "Experiment" coordinate which comes from the filename.""" # Extract the experiment name (such as A1B or E1) from the filename (in # this case it is just the start of the file name, before the first "."). fname = os.path.basename(filename) # filename without path. diff --git a/docs/gallery_tests/conftest.py b/docs/gallery_tests/conftest.py index ff352f5d01..564a2892a2 100644 --- a/docs/gallery_tests/conftest.py +++ b/docs/gallery_tests/conftest.py @@ -18,7 +18,7 @@ @pytest.fixture def image_setup_teardown(): - """Setup and teardown fixture. + """Perform setup and teardown fixture. Ensures all figures are closed before and after test to prevent one test polluting another if it fails with a figure unclosed. diff --git a/docs/gallery_tests/test_gallery_examples.py b/docs/gallery_tests/test_gallery_examples.py index 37f2858ee9..39e8fe0507 100644 --- a/docs/gallery_tests/test_gallery_examples.py +++ b/docs/gallery_tests/test_gallery_examples.py @@ -17,7 +17,7 @@ def gallery_examples(): - """Generator to yield all current gallery examples.""" + """Entry point for generator to yield all current gallery examples.""" for example_file in GALLERY_DIR.glob("*/plot*.py"): yield example_file.stem diff --git a/lib/iris/_concatenate.py b/lib/iris/_concatenate.py index 8be766ea85..214cfa00cc 100644 --- a/lib/iris/_concatenate.py +++ b/lib/iris/_concatenate.py @@ -151,7 +151,7 @@ def name(self): class _DerivedCoordAndDims( namedtuple("DerivedCoordAndDims", ["coord", "dims", "aux_factory"]) ): - """Container for a derived coordinate and dimnesions(s). + """Container for a derived coordinate and dimensions(s). Container for a derived coordinate, the associated AuxCoordFactory, and the associated data dimension(s) spanned over a :class:`iris.cube.Cube`. @@ -385,10 +385,7 @@ class _CubeSignature: """ def __init__(self, cube): - """Represents the cube metadata and associated coordinate metadata. - - Represents the cube metadata and associated coordinate metadata that - allows suitable cubes for concatenation to be identified. + """Represent the cube metadata and associated coordinate metadata. Parameters ---------- @@ -733,10 +730,7 @@ class _ProtoCube: """Framework for concatenating multiple source-cubes over one common dimension.""" def __init__(self, cube): - """Create a new _ProtoCube and record the cube as a source-cube. - - Create a new _ProtoCube from the given cube and record the cube - as a source-cube. + """Create a new _ProtoCube from the given cube and record the cube as a source-cube. Parameters ---------- diff --git a/lib/iris/_data_manager.py b/lib/iris/_data_manager.py index da7a19c95b..6db1d16889 100644 --- a/lib/iris/_data_manager.py +++ b/lib/iris/_data_manager.py @@ -117,7 +117,7 @@ def __ne__(self, other): return result def __repr__(self): - """Returns an string representation of the instance.""" + """Return an string representation of the instance.""" fmt = "{cls}({data!r})" result = fmt.format(data=self.core_data(), cls=type(self).__name__) @@ -269,7 +269,7 @@ def shape(self): return self.core_data().shape def copy(self, data=None): - """Returns a deep copy of this :class:`~iris._data_manager.DataManager` instance. + """Return a deep copy of this :class:`~iris._data_manager.DataManager` instance. Parameters ---------- diff --git a/lib/iris/_merge.py b/lib/iris/_merge.py index e31a4cabc7..7705dd6bea 100644 --- a/lib/iris/_merge.py +++ b/lib/iris/_merge.py @@ -1182,7 +1182,7 @@ def _report_duplicate(self, nd_indexes, group_by_nd_index): raise iris.exceptions.DuplicateDataError(msg) def merge(self, unique=True): - """Returns the list of cubes resulting from merging the registered source-cubes. + """Return the list of cubes resulting from merging the registered source-cubes. Parameters ---------- @@ -1319,7 +1319,7 @@ def register(self, cube, error_on_mismatch=False): return match def _guess_axis(self, name): - """Returns a "best guess" axis name of the candidate dimension. + """Return a "best guess" axis name of the candidate dimension. Heuristic categoration of the candidate dimension (i.e. scalar_defn index) into either label 'T', 'Z', 'Y', 'X' @@ -1564,7 +1564,7 @@ def _get_cube(self, data): return cube def _nd_index(self, position): - """Returns the n-dimensional index of thr source-cube, within the merged cube.""" + """Return the n-dimensional index of thr source-cube, within the merged cube.""" index = [] # Determine the index of the source-cube cell for each dimension. diff --git a/lib/iris/_representation/cube_printout.py b/lib/iris/_representation/cube_printout.py index 3031014faa..47c0b8b631 100644 --- a/lib/iris/_representation/cube_printout.py +++ b/lib/iris/_representation/cube_printout.py @@ -134,7 +134,7 @@ class CubePrinter: N_INDENT_EXTRA = 4 def __init__(self, cube_or_summary): - """An object that provides a printout of a cube. + """Object that provides a printout of a cube. Parameters ---------- diff --git a/lib/iris/analysis/_interpolation.py b/lib/iris/analysis/_interpolation.py index 04e1e39074..59863e3485 100644 --- a/lib/iris/analysis/_interpolation.py +++ b/lib/iris/analysis/_interpolation.py @@ -158,7 +158,7 @@ def get_xy_coords(cube, dim_coords=False): def snapshot_grid(cube): - """Helper function that returns deep copies of lateral (dimension) coordinates from a cube.""" + """Return deep copies of lateral (dimension) coordinates from a cube.""" x, y = get_xy_dim_coords(cube) return x.copy(), y.copy() diff --git a/lib/iris/analysis/_regrid.py b/lib/iris/analysis/_regrid.py index 77b3a306d8..321194d1fc 100644 --- a/lib/iris/analysis/_regrid.py +++ b/lib/iris/analysis/_regrid.py @@ -407,7 +407,7 @@ def __init__(self, src_grid_cube, target_grid_cube, weights=None): @staticmethod def _get_horizontal_coord(cube, axis): - """Gets the horizontal coordinate on the supplied cube along the specified axis. + """Get the horizontal coordinate on the supplied cube along the specified axis. Parameters ---------- diff --git a/lib/iris/analysis/cartography.py b/lib/iris/analysis/cartography.py index 1ce760db5d..58c10c1926 100644 --- a/lib/iris/analysis/cartography.py +++ b/lib/iris/analysis/cartography.py @@ -376,7 +376,7 @@ def _quadrant_area(radian_lat_bounds, radian_lon_bounds, radius_of_earth): def area_weights(cube, normalize=False): - r"""Returns an array of area weights, with the same dimensions as the cube. + r"""Return an array of area weights, with the same dimensions as the cube. This is a 2D lat/lon area weights array, repeated over the non lat/lon dimensions. diff --git a/lib/iris/analysis/maths.py b/lib/iris/analysis/maths.py index 61dc033883..216d7e3892 100644 --- a/lib/iris/analysis/maths.py +++ b/lib/iris/analysis/maths.py @@ -323,7 +323,7 @@ def _add_subtract_common( dim=None, in_place=False, ): - """Function which shares common code between addition and subtraction of cubes. + """Share common code between addition and subtraction of cubes. Parameters ---------- @@ -532,7 +532,7 @@ def divide(cube, other, dim=None, in_place=False): def exponentiate(cube, exponent, in_place=False): - """Returns the result of the given cube to the power of a scalar. + """Return the result of the given cube to the power of a scalar. Parameters ---------- @@ -821,7 +821,7 @@ def _binary_op_common( in_place=False, sanitise_metadata=True, ): - """Function which shares common code between binary operations. + """Share common code between binary operations. Parameters ---------- @@ -1172,7 +1172,7 @@ def __call__( new_name=None, **kwargs_data_func, ): - """Applies the ifunc to the cube(s). + """Apply the ifunc to the cube(s). Parameters ---------- diff --git a/lib/iris/analysis/trajectory.py b/lib/iris/analysis/trajectory.py index 61871fdc51..9adb409970 100644 --- a/lib/iris/analysis/trajectory.py +++ b/lib/iris/analysis/trajectory.py @@ -37,7 +37,7 @@ class Trajectory: """A series of given waypoints with pre-calculated sample points.""" def __init__(self, waypoints, sample_count=10): - """Defines a trajectory using a sequence of waypoints. + """Define a trajectory using a sequence of waypoints. Parameters ---------- @@ -128,7 +128,7 @@ def _get_interp_points(self): return [(k, v) for k, v in points.items()] def _src_cube_anon_dims(self, cube): - """A helper method to locate the index of anonymous dimensions. + """Locate the index of anonymous dimensions. A helper method to locate the index of anonymous dimensions on the interpolation target, ``cube``. @@ -712,7 +712,7 @@ class UnstructuredNearestNeigbourRegridder: # TODO: cache the necessary bits of the operation so reuse can actually # be more efficient. def __init__(self, src_cube, target_grid_cube): - """A nearest-neighbour regridder. + """Nearest-neighbour regridder. A nearest-neighbour regridder to perform regridding from the source grid to the target grid. diff --git a/lib/iris/common/_split_attribute_dicts.py b/lib/iris/common/_split_attribute_dicts.py index b59ad37269..17b3014fb1 100644 --- a/lib/iris/common/_split_attribute_dicts.py +++ b/lib/iris/common/_split_attribute_dicts.py @@ -66,7 +66,9 @@ def _convert_pairedkeys_dict_to_splitattrs(dic): def adjust_for_split_attribute_dictionaries(operation): - """Decorator to make a function of attribute-dictionaries work with split attributes. + """Generate attribute-dictionaries to work with split attributes. + + Decorator to make a function of attribute-dictionaries work with split attributes. The wrapped function of attribute-dictionaries is currently always one of "equals", "combine" or "difference", with signatures like : @@ -91,6 +93,7 @@ def adjust_for_split_attribute_dictionaries(operation): "Split" dictionaries are all of class :class:`~iris.cube.CubeAttrsDict`, since the only usage of 'split' attribute dictionaries is in Cubes (i.e. they are not used for cube components). + """ @wraps(operation) diff --git a/lib/iris/common/lenient.py b/lib/iris/common/lenient.py index 0180716ac6..4822d88b92 100644 --- a/lib/iris/common/lenient.py +++ b/lib/iris/common/lenient.py @@ -28,7 +28,7 @@ def _lenient_client(*dargs, services=None): - """Decorator implementing the lenient client protocol. + """Allow a client function/method to declare at runtime. Decorator that allows a client function/method to declare at runtime that it is executing and requires lenient behaviour from a prior registered @@ -129,7 +129,7 @@ def lenient_client_inner(*args, **kwargs): def _lenient_service(*dargs): - """Decorator implementing the lenient service protocol. + """Implement the lenient service protocol. Decorator that allows a function/method to declare that it supports lenient behaviour as a service. @@ -223,7 +223,7 @@ def _qualname(func): class Lenient(threading.local): def __init__(self, **kwargs): - """A container for managing the run-time lenient features and options. + """Container for managing the run-time lenient features and options. Parameters ---------- @@ -330,7 +330,7 @@ def configure_state(state): class _Lenient(threading.local): def __init__(self, *args, **kwargs): - """A container for managing the run-time lenient services and client options. + """Container for managing the run-time lenient services and client options. A container for managing the run-time lenient services and client options for pre-defined functions/methods. diff --git a/lib/iris/common/metadata.py b/lib/iris/common/metadata.py index 71d51fe6d7..92c3d34f3e 100644 --- a/lib/iris/common/metadata.py +++ b/lib/iris/common/metadata.py @@ -241,7 +241,7 @@ def __str__(self): return f"{type(self).__name__}({', '.join(field_strings)})" def _api_common(self, other, func_service, func_operation, action, lenient=None): - """Common entry-point for lenient metadata API methods. + """Perform common entry-point for lenient metadata API methods. Parameters ---------- @@ -683,7 +683,7 @@ def from_metadata(cls, other): return result def name(self, default=None, token=False): - """Returns a string name representing the identity of the metadata. + """Return a string name representing the identity of the metadata. First it tries standard name, then it tries the long name, then the NetCDF variable name, before falling-back to a default value, @@ -1561,7 +1561,7 @@ def values(self): def metadata_manager_factory(cls, **kwargs): - """Factory function for manufacturing metadata instances. + """Manufacturing metadata instances. A class instance factory function responsible for manufacturing metadata instances dynamically at runtime. diff --git a/lib/iris/common/mixin.py b/lib/iris/common/mixin.py index 762d1b1fe6..2d9605de83 100644 --- a/lib/iris/common/mixin.py +++ b/lib/iris/common/mixin.py @@ -119,7 +119,7 @@ def __setitem__(self, key, value): dict.__setitem__(self, key, value) def update(self, other, **kwargs): - """Standard ``dict.update()`` operation.""" + """Perform standard ``dict.update()`` operation.""" # Gather incoming keys keys = [] if hasattr(other, "keys"): @@ -143,7 +143,7 @@ def name(self, default=None, token=None): return self._metadata_manager.name(default=default, token=token) def rename(self, name): - """Changes the human-readable name. + """Change the human-readable name. If 'name' is a valid standard name it will assign it to :attr:`standard_name`, otherwise it will assign it to diff --git a/lib/iris/coord_categorisation.py b/lib/iris/coord_categorisation.py index 14330487b6..96407632c5 100644 --- a/lib/iris/coord_categorisation.py +++ b/lib/iris/coord_categorisation.py @@ -204,7 +204,7 @@ def add_hour(cube, coord, name="hour"): def _months_in_season(season): - """Returns a list of month numbers corresponding to each month in the given season.""" + """Return a list of month numbers corresponding to each month in the given season.""" cyclic_months = "jfmamjjasondjfmamjjasond" m0 = cyclic_months.find(season.lower()) if m0 < 0: diff --git a/lib/iris/coord_systems.py b/lib/iris/coord_systems.py index b96f6166c0..adc9895ed9 100644 --- a/lib/iris/coord_systems.py +++ b/lib/iris/coord_systems.py @@ -79,7 +79,7 @@ def __ne__(self, other): return not (self == other) def xml_element(self, doc, attrs=None): - """Default behaviour for coord systems.""" + """Perform default behaviour for coord systems.""" # attrs - optional list of (k,v) items, used for alternate output xml_element_name = type(self).__name__ @@ -496,7 +496,7 @@ def __init__( north_pole_grid_longitude=None, ellipsoid=None, ): - """Constructs a coordinate system with rotated pole, on an optional :class:`GeogCS`. + """Construct a coordinate system with rotated pole, on an optional :class:`GeogCS`. Args: @@ -604,7 +604,7 @@ def __init__( scale_factor_at_central_meridian=None, ellipsoid=None, ): - """Constructs a TransverseMercator object. + """Construct a TransverseMercator object. Args: @@ -725,7 +725,7 @@ def __init__( false_northing=None, ellipsoid=None, ): - """Constructs an Orthographic coord system. + """Construct an Orthographic coord system. Args: @@ -809,7 +809,7 @@ def __init__( false_northing=None, ellipsoid=None, ): - """Constructs a Vertical Perspective coord system. + """Construct a Vertical Perspective coord system. Args: @@ -901,7 +901,7 @@ def __init__( false_northing=None, ellipsoid=None, ): - """Constructs a Geostationary coord system. + """Construct a Geostationary coord system. Args: @@ -1005,7 +1005,7 @@ def __init__( ellipsoid=None, scale_factor_at_projection_origin=None, ): - """Constructs a Stereographic coord system. + """Construct a Stereographic coord system. Parameters ---------- @@ -1177,7 +1177,7 @@ def __init__( secant_latitudes=None, ellipsoid=None, ): - """Constructs a LambertConformal coord system. + """Construct a LambertConformal coord system. Kwargs: @@ -1283,7 +1283,7 @@ def __init__( false_easting=None, false_northing=None, ): - """Constructs a Mercator coord system. + """Construct a Mercator coord system. Kwargs: @@ -1388,7 +1388,7 @@ def __init__( false_northing=None, ellipsoid=None, ): - """Constructs a Lambert Azimuthal Equal Area coord system. + """Construct a Lambert Azimuthal Equal Area coord system. Kwargs: @@ -1469,7 +1469,7 @@ def __init__( standard_parallels=None, ellipsoid=None, ): - """Constructs a Albers Conical Equal Area coord system. + """Construct a Albers Conical Equal Area coord system. Kwargs: @@ -1574,7 +1574,7 @@ def __init__( scale_factor_at_projection_origin=None, ellipsoid=None, ): - """Constructs an ObliqueMercator object. + """Construct an ObliqueMercator object. Parameters ---------- @@ -1689,7 +1689,7 @@ def __init__( scale_factor_at_projection_origin=None, ellipsoid=None, ): - """Constructs a RotatedMercator object. + """Construct a RotatedMercator object. Parameters ---------- diff --git a/lib/iris/coords.py b/lib/iris/coords.py index caa421d11c..bf3fe1eb78 100644 --- a/lib/iris/coords.py +++ b/lib/iris/coords.py @@ -67,7 +67,7 @@ def __init__( units=None, attributes=None, ): - """Constructs a single dimensional metadata object. + """Construct a single dimensional metadata object. Parameters ---------- @@ -119,7 +119,7 @@ def __init__( self._bounds_dm = None # Only ever set on Coord-derived instances. def __getitem__(self, keys): - """Returns a new dimensional metadata whose values are obtained by conventional array indexing. + """Return a new dimensional metadata whose values are obtained by conventional array indexing. .. note:: @@ -156,7 +156,7 @@ def __getitem__(self, keys): return new_metadata def copy(self, values=None): - """Returns a copy of this dimensional metadata object. + """Return a copy of this dimensional metadata object. Parameters ---------- @@ -234,11 +234,11 @@ def _values(self, values): self._values_dm.data = values def _lazy_values(self): - """Returns a lazy array representing the dimensional metadata values.""" + """Return a lazy array representing the dimensional metadata values.""" return self._values_dm.lazy_data() def _core_values(self): - """The values array of this dimensional metadata which may be a NumPy array or a dask array.""" + """Value array of this dimensional metadata which may be a NumPy array or a dask array.""" result = self._values_dm.core_data() if not _lazy.is_lazy_data(result): result = result.view() @@ -246,7 +246,7 @@ def _core_values(self): return result def _has_lazy_values(self): - """Indicates whether the metadata's values array is a lazy dask array or not.""" + """Indicate whether the metadata's values array is a lazy dask array or not.""" return self._values_dm.has_lazy_data() def summary( @@ -619,7 +619,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. + """Perform common code which is called by add, sub, mul and div. Mode constant is one of ADD, SUB, MUL, DIV, RDIV @@ -772,7 +772,7 @@ def ndim(self): return self._values_dm.ndim def has_bounds(self): - """Indicates whether the current dimensional metadata object has a bounds array.""" + """Indicate whether the current dimensional metadata object has a bounds array.""" # Allows for code to handle unbounded dimensional metadata agnostic of # whether the metadata is a coordinate or not. return False @@ -880,7 +880,7 @@ def _xml_array_repr(data): return result def _value_type_name(self): - """A simple, readable name for the data type of the dimensional metadata values.""" + """Provide a simple name for the data type of the dimensional metadata values.""" dtype = self._core_values().dtype kind = dtype.kind if kind in "SU": @@ -905,7 +905,7 @@ def __init__( units=None, attributes=None, ): - """Constructs a single ancillary variable. + """Construct a single ancillary variable. Parameters ---------- @@ -963,7 +963,7 @@ def lazy_data(self): return super()._lazy_values() def core_data(self): - """The data array at the core of this ancillary variable. + """Return data array at the core of this ancillary variable. The data array at the core of this ancillary variable, which may be a NumPy array or a dask array. @@ -972,7 +972,7 @@ def core_data(self): return super()._core_values() def has_lazy_data(self): - """Indicates whether the ancillary variable's data array is a lazy dask array or not.""" + """Indicate whether the ancillary variable's data array is a lazy dask array or not.""" return super()._has_lazy_values() def cube_dims(self, cube): @@ -1003,7 +1003,7 @@ def __init__( attributes=None, measure=None, ): - """Constructs a single cell measure. + """Construct a single cell measure. Parameters ---------- @@ -1147,7 +1147,7 @@ def __new__( def _get_2d_coord_bound_grid(bounds): - """Creates a grid using the bounds of a 2D coordinate with 4 sided cells. + """Create a grid using the bounds of a 2D coordinate with 4 sided cells. Assumes that the four vertices of the cells are in an anti-clockwise order (bottom-left, bottom-right, top-right, top-left). @@ -1277,7 +1277,7 @@ def __hash__(self): return hash((self.point, bound)) def __eq__(self, other): - """Compares Cell equality depending on the type of the object to be compared.""" + """Compare Cell equality depending on the type of the object to be compared.""" if isinstance(other, (int, float, np.number)) or hasattr(other, "timetuple"): if self.bound is not None: return self.contains_point(other) @@ -1312,7 +1312,7 @@ def __common_cmp__(self, other, operator_method): Cell vs Cell comparison is used to define a strict order. Non-Cell vs Cell comparison is used to define Constraint matching. - """ + """ # noqa: D401 if (isinstance(other, list) and len(other) == 1) or ( isinstance(other, np.ndarray) and other.shape == (1,) ): @@ -1507,7 +1507,7 @@ def __init__( self._ignore_axis = DEFAULT_IGNORE_AXIS def copy(self, points=None, bounds=None): - """Returns a copy of this coordinate. + """Return a copy of this coordinate. points : A points array for the new coordinate. @@ -1711,11 +1711,11 @@ def lazy_bounds(self): return lazy_bounds def core_points(self): - """The points array at the core of this coord, which may be a NumPy array or a dask array.""" + """Core points array at the core of this coord, which may be a NumPy array or a dask array.""" return super()._core_values() def core_bounds(self): - """The points array at the core of this coord, which may be a NumPy array or a dask array.""" + """Core bounds. The points array at the core of this coord, which may be a NumPy array or a dask array.""" result = None if self.has_bounds(): result = self._bounds_dm.core_data() @@ -1775,7 +1775,7 @@ def convert_units(self, unit): super().convert_units(unit=unit) def cells(self): - """Returns an iterable of Cell instances for this Coord. + """Return an iterable of Cell instances for this Coord. For example:: @@ -1825,7 +1825,7 @@ def _sanity_check_bounds(self): ) def _discontiguity_in_bounds(self, rtol=1e-5, atol=1e-8): - """Checks that the bounds of the coordinate are contiguous. + """Check that the bounds of the coordinate are contiguous. rtol : float, optional Relative tolerance that is used when checking contiguity. Defaults @@ -2067,7 +2067,7 @@ def has_bounds(self): return self._bounds_dm is not None def cell(self, index): - """The point/bound cell at the given coordinate index. + """Point/bound cell at the given coordinate index. Return the single :class:`Cell` instance which results from slicing the points/bounds with the given index. @@ -2286,7 +2286,7 @@ def guess_bounds(self, bound_position=0.5): self.bounds = self._guess_bounds(bound_position) def intersect(self, other, return_indices=False): - """Returns a new coordinate from the intersection of two coordinates. + """Return a new coordinate from the intersection of two coordinates. Both coordinates must be compatible as defined by :meth:`~iris.coords.Coord.is_compatible`. @@ -2331,7 +2331,7 @@ def intersect(self, other, return_indices=False): return self[self_intersect_indices] def nearest_neighbour_index(self, point): - """Returns the index of the cell nearest to the given point. + """Return the index of the cell nearest to the given point. Only works for one-dimensional coordinates. diff --git a/lib/iris/cube.py b/lib/iris/cube.py index df0f719aca..5997eaacf5 100644 --- a/lib/iris/cube.py +++ b/lib/iris/cube.py @@ -66,13 +66,13 @@ def __len__(self): return len(self.cubes) def add(self, cube): - """Adds the appropriate (sub)cube to the list of cubes where it matches the constraint.""" + """Add the appropriate (sub)cube to the list of cubes where it matches the constraint.""" sub_cube = self.constraint.extract(cube) if sub_cube is not None: self.cubes.append(sub_cube) def merged(self, unique=False): - """Returns a new :class:`_CubeFilter` by merging the list of cubes. + """Return a new :class:`_CubeFilter` by merging the list of cubes. Parameters ---------- @@ -89,7 +89,7 @@ class _CubeFilterCollection: @staticmethod def from_cubes(cubes, constraints=None): - """Creates a new collection from an iterable of cubes, and some optional constraints.""" + """Create a new collection from an iterable of cubes, and some optional constraints.""" constraints = iris._constraints.list_of_constraints(constraints) pairs = [_CubeFilter(constraint) for constraint in constraints] collection = _CubeFilterCollection(pairs) @@ -101,12 +101,12 @@ def __init__(self, pairs): self.pairs = pairs def add_cube(self, cube): - """Adds the given :class:`~iris.cube.Cube` to all of the relevant constraint pairs.""" + """Add the given :class:`~iris.cube.Cube` to all of the relevant constraint pairs.""" for pair in self.pairs: pair.add(cube) def cubes(self): - """Returns all the cubes in this collection concatenated into a single :class:`CubeList`.""" + """Return all the cubes in this collection concatenated into a single :class:`CubeList`.""" result = CubeList() for pair in self.pairs: result.extend(pair.cubes) @@ -137,7 +137,7 @@ def __init__(self, *args, **kwargs): self._assert_is_cube(cube) def __str__(self): - """Runs short :meth:`Cube.summary` on every cube.""" + """Run short :meth:`Cube.summary` on every cube.""" result = [ "%s: %s" % (i, cube.summary(shorten=True)) for i, cube in enumerate(self) ] @@ -148,7 +148,7 @@ def __str__(self): return result def __repr__(self): - """Runs repr on every cube.""" + """Run repr on every cube.""" return "[%s]" % ",\n".join([repr(cube) for cube in self]) @staticmethod @@ -401,7 +401,7 @@ def merge_cube(self): return merged_cube def merge(self, unique=True): - """Returns the :class:`CubeList` resulting from merging this :class:`CubeList`. + """Return the :class:`CubeList` resulting from merging this :class:`CubeList`. Parameters ---------- @@ -1182,7 +1182,7 @@ def __init__( cell_measures_and_dims=None, ancillary_variables_and_dims=None, ): - """Creates a cube with data and optional metadata. + """Create a cube with data and optional metadata. Not typically used - normally cubes are obtained by loading data (e.g. :func:`iris.load`) or from manipulating existing cubes. @@ -1338,7 +1338,7 @@ def attributes(self) -> CubeAttrsDict: @attributes.setter def attributes(self, attributes: Optional[Mapping]): - """An override to CfVariableMixin.attributes.setter. + """Override to CfVariableMixin.attributes.setter. An override to CfVariableMixin.attributes.setter, which ensures that Cube attributes are stored in a way which distinguishes global + local ones. @@ -1465,7 +1465,7 @@ def add_cell_method(self, cell_method): self.cell_methods += (cell_method,) def add_aux_coord(self, coord, data_dims=None): - """Adds a CF auxiliary coordinate to the cube. + """Add a CF auxiliary coordinate to the cube. Parameters ---------- @@ -1574,7 +1574,7 @@ def _add_unique_aux_coord(self, coord, data_dims): self._aux_coords_and_dims.append((coord, data_dims)) def add_aux_factory(self, aux_factory): - """Adds an auxiliary coordinate factory to the cube. + """Add an auxiliary coordinate factory to the cube. Parameters ---------- @@ -1606,7 +1606,7 @@ def coordsonly(coords_and_dims): self._aux_factories.append(aux_factory) def add_cell_measure(self, cell_measure, data_dims=None): - """Adds a CF cell measure to the cube. + """Add a CF cell measure to the cube. Parameters ---------- @@ -1639,7 +1639,7 @@ def add_cell_measure(self, cell_measure, data_dims=None): ) def add_ancillary_variable(self, ancillary_variable, data_dims=None): - """Adds a CF ancillary variable to the cube. + """Add a CF ancillary variable to the cube. Parameters ---------- @@ -1738,7 +1738,7 @@ def _add_unique_dim_coord(self, dim_coord, data_dim): self._dim_coords_and_dims.append((dim_coord, int(data_dim))) def remove_aux_factory(self, aux_factory): - """Removes the given auxiliary coordinate factory from the cube.""" + """Remove the given auxiliary coordinate factory from the cube.""" self._aux_factories.remove(aux_factory) def _remove_coord(self, coord): @@ -1757,7 +1757,7 @@ def _remove_coord(self, coord): self.remove_aux_factory(aux_factory) def remove_coord(self, coord): - """Removes a coordinate from the cube. + """Remove a coordinate from the cube. Parameters ---------- @@ -1777,7 +1777,7 @@ def remove_coord(self, coord): factory.update(coord) def remove_cell_measure(self, cell_measure): - """Removes a cell measure from the cube. + """Remove a cell measure from the cube. Parameters ---------- @@ -1814,7 +1814,7 @@ def remove_cell_measure(self, cell_measure): ] def remove_ancillary_variable(self, ancillary_variable): - """Removes an ancillary variable from the cube. + """Remove an ancillary variable from the cube. Parameters ---------- @@ -1927,7 +1927,7 @@ def cell_measure_dims(self, cell_measure): return matches[0] def ancillary_variable_dims(self, ancillary_variable): - """Returns a tuple of the data dimensions relevant to the given AncillaryVariable. + """Return a tuple of the data dimensions relevant to the given AncillaryVariable. Parameters ---------- @@ -2777,7 +2777,7 @@ def aux_factories(self): return tuple(self._aux_factories) def summary(self, shorten=False, name_padding=35): - """String summary of the Cube. + """Summary of the Cube. String summary of the Cube with name+units, a list of dim coord names versus length and, optionally, a summary of all other components. @@ -3587,7 +3587,7 @@ def remap_cube_metadata(metadata_and_dims): ) def xml(self, checksum=False, order=True, byteorder=True): - """Returns a fully valid CubeML string representation of the Cube.""" + """Return a fully valid CubeML string representation of the Cube.""" doc = Document() cube_xml_element = self._xml_element( @@ -3760,7 +3760,7 @@ def _order(array): return cube_xml_element def copy(self, data=None): - """Returns a deep copy of this cube. + """Return a deep copy of this cube. Parameters ---------- @@ -4866,9 +4866,9 @@ def keys(self): def sorted_axes(axes): - """Returns the axis names sorted alphabetically. + """Return the axis names sorted alphabetically. - Returns the axis names sorted alphabetically, with the exception that + Return the axis names sorted alphabetically, with the exception that 't', 'z', 'y', and, 'x' are sorted to the end. """ diff --git a/lib/iris/experimental/raster.py b/lib/iris/experimental/raster.py index 8d37e39df3..ba7efc68b0 100644 --- a/lib/iris/experimental/raster.py +++ b/lib/iris/experimental/raster.py @@ -107,7 +107,7 @@ def _gdal_write_array(x_min, x_step, y_max, y_step, coord_system, data, fname, f def export_geotiff(cube, fname): - """Writes cube data to raster file format as a PixelIsArea GeoTiff image. + """Write cube data to raster file format as a PixelIsArea GeoTiff image. .. deprecated:: 3.2.0 diff --git a/lib/iris/experimental/regrid.py b/lib/iris/experimental/regrid.py index dac191c64d..74b356722f 100644 --- a/lib/iris/experimental/regrid.py +++ b/lib/iris/experimental/regrid.py @@ -736,9 +736,9 @@ def __init__(self, projection=None): warn_deprecated(wmsg) def regridder(self, src_cube, target_grid): - """Creates a nearest-neighbour regridder to perform regridding. + """Create a nearest-neighbour regridder to perform regridding. - Creates a nearest-neighbour regridder to perform regridding, using + Create a nearest-neighbour regridder to perform regridding, using scipy.interpolate.griddata from unstructured source points to the target grid. The regridding calculation is performed in the given projection. diff --git a/lib/iris/experimental/representation.py b/lib/iris/experimental/representation.py index 85923a12d8..0b98c24395 100644 --- a/lib/iris/experimental/representation.py +++ b/lib/iris/experimental/representation.py @@ -288,7 +288,7 @@ def _make_content(self): return "\n".join(element for element in elements) def repr_html(self): - """The `repr` interface for Jupyter.""" + """Represent html, the `repr` interface for Jupyter.""" # Deal with the header first. header = self._make_header() diff --git a/lib/iris/experimental/stratify.py b/lib/iris/experimental/stratify.py index a6ac06a8d2..3e5fb1da9f 100644 --- a/lib/iris/experimental/stratify.py +++ b/lib/iris/experimental/stratify.py @@ -14,7 +14,7 @@ def _copy_coords_without_z_dim(src, tgt, z_dim): - """Helper function to copy across non z-dimenson coordinates between cubes. + """Copy across non z-dimenson coordinates between cubes. Parameters ---------- diff --git a/lib/iris/experimental/ugrid/load.py b/lib/iris/experimental/ugrid/load.py index 0ed1757353..b8665a499e 100644 --- a/lib/iris/experimental/ugrid/load.py +++ b/lib/iris/experimental/ugrid/load.py @@ -101,7 +101,7 @@ def context(self): def _meshes_from_cf(cf_reader): - """Common behaviour for extracting meshes from a CFReader. + """Mesh from cf, common behaviour for extracting meshes from a CFReader. Simple now, but expected to increase in complexity as Mesh sharing develops. diff --git a/lib/iris/experimental/ugrid/mesh.py b/lib/iris/experimental/ugrid/mesh.py index b12178da83..147b1fd513 100644 --- a/lib/iris/experimental/ugrid/mesh.py +++ b/lib/iris/experimental/ugrid/mesh.py @@ -119,7 +119,7 @@ def __init__( start_index=0, location_axis=0, ): - """Constructs a single connectivity. + """Construct a single connectivity. Parameters ---------- @@ -494,7 +494,7 @@ def lazy_indices(self): return super()._lazy_values() def core_indices(self): - """The indices array at the core of this connectivity. + """Return the indices array at the core of this connectivity. The indices array at the core of this connectivity, which may be a NumPy array or a Dask array. diff --git a/lib/iris/fileformats/_ff.py b/lib/iris/fileformats/_ff.py index e3749fe72d..301a45736e 100644 --- a/lib/iris/fileformats/_ff.py +++ b/lib/iris/fileformats/_ff.py @@ -804,7 +804,7 @@ def __iter__(self): def _parse_binary_stream(file_like, dtype=np.float64, count=-1): - """Replacement :func:`numpy.fromfile` due to python3 performance issues. + """Parse binary stream, replacement :func:`numpy.fromfile` due to python3 performance issues. Parameters ---------- @@ -835,7 +835,7 @@ def _parse_binary_stream(file_like, dtype=np.float64, count=-1): def load_cubes(filenames, callback, constraints=None): - """Loads cubes from a list of fields files filenames. + """Load cubes from a list of fields files filenames. Parameters ---------- @@ -859,7 +859,7 @@ def load_cubes(filenames, callback, constraints=None): def load_cubes_32bit_ieee(filenames, callback, constraints=None): - """Loads cubes from a list of 32bit ieee converted fieldsfiles filenames. + """Load cubes from a list of 32bit ieee converted fieldsfiles filenames. See Also -------- diff --git a/lib/iris/fileformats/_nc_load_rules/actions.py b/lib/iris/fileformats/_nc_load_rules/actions.py index 1532340d00..8f408716e6 100644 --- a/lib/iris/fileformats/_nc_load_rules/actions.py +++ b/lib/iris/fileformats/_nc_load_rules/actions.py @@ -103,7 +103,7 @@ def inner(engine, *args, **kwargs): @action_function def action_default(engine): - """Standard operations for every cube.""" + """Perform standard operations for every cube.""" hh.build_cube_metadata(engine) diff --git a/lib/iris/fileformats/abf.py b/lib/iris/fileformats/abf.py index 13b0d8aa8d..76f3573882 100644 --- a/lib/iris/fileformats/abf.py +++ b/lib/iris/fileformats/abf.py @@ -192,7 +192,7 @@ def to_cube(self): def load_cubes(filespecs, callback=None): - """Loads cubes from a list of ABF filenames. + """Load cubes from a list of ABF filenames. Args: diff --git a/lib/iris/fileformats/nimrod.py b/lib/iris/fileformats/nimrod.py index 778c7b3251..009535dc8f 100644 --- a/lib/iris/fileformats/nimrod.py +++ b/lib/iris/fileformats/nimrod.py @@ -290,7 +290,7 @@ def _read_data(self, infile): def load_cubes(filenames, callback=None): - """Loads cubes from a list of NIMROD filenames. + """Load cubes from a list of NIMROD filenames. Parameters ---------- diff --git a/lib/iris/fileformats/pp.py b/lib/iris/fileformats/pp.py index e224e26b41..fa95d0dab1 100644 --- a/lib/iris/fileformats/pp.py +++ b/lib/iris/fileformats/pp.py @@ -277,11 +277,11 @@ def __new__(cls, model, section, item): Args ---- - model + model : A positive integer less than 100, or None. - section + section : A non-negative integer less than 100, or None. - item + item : A positive integer less than 1000, or None. """ diff --git a/lib/iris/fileformats/pp_load_rules.py b/lib/iris/fileformats/pp_load_rules.py index 01d1add197..f93f177ba8 100644 --- a/lib/iris/fileformats/pp_load_rules.py +++ b/lib/iris/fileformats/pp_load_rules.py @@ -857,7 +857,7 @@ def _convert_scalar_pseudo_level_coords(lbuser5): def convert(f): - """Converts a PP field into the corresponding items of Cube metadata. + """Convert a PP field into the corresponding items of Cube metadata. Parameters ---------- diff --git a/lib/iris/fileformats/rules.py b/lib/iris/fileformats/rules.py index 59d0655198..bf6ae4de34 100644 --- a/lib/iris/fileformats/rules.py +++ b/lib/iris/fileformats/rules.py @@ -142,7 +142,7 @@ class _ReferenceError(Exception): def _dereference_args(factory, reference_targets, regrid_cache, cube): - """Converts all the arguments for a factory into concrete coordinates.""" + """Convert all the arguments for a factory into concrete coordinates.""" args = [] for arg in factory.args: if isinstance(arg, Reference): diff --git a/lib/iris/fileformats/um/_fast_load.py b/lib/iris/fileformats/um/_fast_load.py index c37d0abc32..12441acdcc 100644 --- a/lib/iris/fileformats/um/_fast_load.py +++ b/lib/iris/fileformats/um/_fast_load.py @@ -155,7 +155,7 @@ def iter_fields_decorated_with_load_indices(fields_iter): def _convert_collation(collation): - """Converts a FieldCollation into the corresponding items of Cube metadata. + """Convert a FieldCollation into the corresponding items of Cube metadata. Parameters ---------- diff --git a/lib/iris/fileformats/um/_fast_load_structured_fields.py b/lib/iris/fileformats/um/_fast_load_structured_fields.py index 17b3d4f9a0..6b09227491 100644 --- a/lib/iris/fileformats/um/_fast_load_structured_fields.py +++ b/lib/iris/fileformats/um/_fast_load_structured_fields.py @@ -236,7 +236,7 @@ def _calculate_structure(self): def _um_collation_key_function(field): - """Standard collation key definition for fast structured field loading. + """Collation key definition for fast structured field loading. The elements used here are the minimum sufficient to define the 'phenomenon', as described for :meth:`group_structured_fields`. diff --git a/lib/iris/fileformats/um/_ff_replacement.py b/lib/iris/fileformats/um/_ff_replacement.py index d8dee81b36..ee40bacafa 100644 --- a/lib/iris/fileformats/um/_ff_replacement.py +++ b/lib/iris/fileformats/um/_ff_replacement.py @@ -51,7 +51,7 @@ def um_to_pp(filename, read_data=False, word_depth=None): def load_cubes(filenames, callback, constraints=None, _loader_kwargs=None): - """Loads cubes from filenames of UM fieldsfile-like files. + """Load cubes from filenames of UM fieldsfile-like files. Parameters ---------- @@ -81,7 +81,7 @@ def load_cubes(filenames, callback, constraints=None, _loader_kwargs=None): def load_cubes_32bit_ieee(filenames, callback, constraints=None): - """Loads cubes from filenames of 32bit ieee converted UM fieldsfile-like files. + """Load cubes from filenames of 32bit ieee converted UM fieldsfile-like files. See Also -------- diff --git a/lib/iris/palette.py b/lib/iris/palette.py index 078d9b73ba..e180b649a8 100644 --- a/lib/iris/palette.py +++ b/lib/iris/palette.py @@ -136,7 +136,7 @@ def cmap_norm(cube): def auto_palette(func): - """Decorator wrapper function to control the default behaviour. + """Auto palette decorator wrapper function to control the default behaviour. Decorator wrapper function to control the default behaviour of the matplotlib cmap and norm keyword arguments. diff --git a/lib/iris/plot.py b/lib/iris/plot.py index 7974b8fd0e..57e338c86a 100644 --- a/lib/iris/plot.py +++ b/lib/iris/plot.py @@ -1229,7 +1229,7 @@ def _fill_orography(cube, coords, mode, vert_plot, horiz_plot, style_args): def orography_at_bounds(cube, facecolor="#888888", coords=None, axes=None): - """Plots orography defined at cell boundaries from the given Cube. + """Plot orography defined at cell boundaries from the given Cube. Notes ----- @@ -1267,7 +1267,7 @@ def horiz_plot(v_coord, orography, style_args): def orography_at_points(cube, facecolor="#888888", coords=None, axes=None): - """Plots orography defined at sample points from the given Cube. + """Plot orography defined at sample points from the given Cube. Notes ----- @@ -1444,7 +1444,7 @@ def _scatter_args(u, v, data, *args, **kwargs): def _vector_component_args(x_points, y_points, u_data, *args, **kwargs): - """Callback from _draw_2d_from_points for 'quiver' and 'streamlines'. + """Vector component callback from _draw_2d_from_points for 'quiver' and 'streamlines'. Returns arguments (x, y, u, v), to be passed to the underlying matplotlib call. @@ -1681,7 +1681,7 @@ def scatter(x, y, *args, **kwargs): def fill_between(x, y1, y2, *args, **kwargs): - """Plots y1 and y2 against x, and fills the space between them. + """Plot y1 and y2 against x, and fills the space between them. Args: diff --git a/lib/iris/quickplot.py b/lib/iris/quickplot.py index ce52fbdb6b..1c1eaf5a56 100644 --- a/lib/iris/quickplot.py +++ b/lib/iris/quickplot.py @@ -49,7 +49,7 @@ def _title(cube_or_coord, with_units): def _label(cube, mode, result=None, ndims=2, coords=None, axes=None): - """Puts labels on the current plot using the given cube.""" + """Put labels on the current plot using the given cube.""" if axes is None: axes = plt.gca() diff --git a/lib/iris/util.py b/lib/iris/util.py index 9ae1ceb919..878c62e2f1 100644 --- a/lib/iris/util.py +++ b/lib/iris/util.py @@ -95,7 +95,7 @@ def broadcast_to_shape(array, shape, dim_map): def delta(ndarray, dimension, circular=False): - """Calculates the difference between values along a given dimension. + """Calculate the difference between values along a given dimension. Parameters ---------- @@ -1216,9 +1216,9 @@ def _handle_dimensional_metadata(cube, dm_item, cube_add_method, expand_extras): def squeeze(cube): - """Removes any dimension of length one. + """Remove any dimension of length one. - Removes any dimension of length one. If it has an associated DimCoord or + Remove any dimension of length one. If it has an associated DimCoord or AuxCoord, this becomes a scalar coord. Parameters @@ -1417,9 +1417,9 @@ def points_step(points): def unify_time_units(cubes): - """Performs an in-place conversion of the time units. + """Perform an in-place conversion of the time units. - Performs an in-place conversion of the time units of all time coords in the + Perform an in-place conversion of the time units of all time coords in the cubes in a given iterable. One common epoch is defined for each calendar found in the cubes to prevent units being defined with inconsistencies between epoch and calendar. During this process, all time coordinates have @@ -1521,7 +1521,7 @@ def _is_circular(points, modulus, bounds=None): def promote_aux_coord_to_dim_coord(cube, name_or_coord): - r"""Promotes an auxiliary to a dimension coordinate on the cube. + r"""Promote an auxiliary to a dimension coordinate on the cube. This AuxCoord must be associated with a single cube dimension. If the AuxCoord is associated with a dimension that already has a DimCoord, that @@ -1730,7 +1730,7 @@ def demote_dim_coord_to_aux_coord(cube, name_or_coord): @functools.wraps(np.meshgrid) def _meshgrid(*xi, **kwargs): - """Ensures consistent meshgrid behaviour across numpy versions. + """Ensure consistent meshgrid behaviour across numpy versions. @numpy v1.13, the dtype of each output n-D coordinate is the same as its associated input 1D coordinate. This is not the case prior to numpy v1.13, diff --git a/noxfile.py b/noxfile.py index da71144913..a30b6ce784 100644 --- a/noxfile.py +++ b/noxfile.py @@ -39,7 +39,7 @@ def session_lockfile(session: nox.sessions.Session) -> Path: def session_cachefile(session: nox.sessions.Session) -> Path: - """Returns the path of the session lockfile cache.""" + """Return the path of the session lockfile cache.""" lockfile = session_lockfile(session) tmp_dir = Path(session.create_tmp()) cache = tmp_dir / lockfile.name @@ -55,7 +55,7 @@ def venv_populated(session: nox.sessions.Session) -> bool: def venv_changed(session: nox.sessions.Session) -> bool: - """Returns True if the installed session is different. + """Return True if the installed session is different. Compares to that specified in the lockfile. """ diff --git a/pyproject.toml b/pyproject.toml index 19e3d26cdf..4325de0e0e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -110,6 +110,7 @@ known-first-party = ["iris"] # https://docs.astral.sh/ruff/rules/undocumented-public-module/ "D100", # Missing docstring in public module "D205", # 1 blank line required between summary line and description + "D401", # 1 First line of docstring should be in imperative mood ] [tool.ruff.lint.pydocstyle] diff --git a/setup.py b/setup.py index 004c6b2301..28e7a003a9 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,7 @@ def run(self): def custom_command(cmd, help=""): - """Factory function to generate a custom command. + """Create custom command with factory function. Custom command will add additional behaviour to build the CF standard names module.