From 417aa6bbd9b10d25cad7def54d47ef4d718bc38d Mon Sep 17 00:00:00 2001 From: Bill Little Date: Mon, 6 Mar 2023 11:15:57 +0000 Subject: [PATCH 1/3] adopt codespell --- .git-blame-ignore-revs | 18 +++++++++++++++ .pre-commit-config.yaml | 7 ++++++ .../experimental/ugrid/regions_combine.py | 2 +- .../benchmarks/sperf/combine_regions.py | 2 +- codecov.yml | 2 +- .../plot_projections_and_annotations.py | 2 +- .../general/plot_rotated_pole_mapping.py | 2 +- .../meteorology/plot_lagged_ensemble.py | 2 +- docs/src/IEP/IEP001.adoc | 2 +- docs/src/community/iris_xarray.rst | 2 +- docs/src/conf.py | 2 +- .../gitwash/configure_git.rst | 2 +- docs/src/developers_guide/release.rst | 2 +- docs/src/further_topics/ugrid/operations.rst | 2 +- .../plotting_examples/1d_with_legend.py | 2 +- docs/src/whatsnew/1.7.rst | 4 ++-- docs/src/whatsnew/2.0.rst | 2 +- docs/src/whatsnew/3.0.rst | 2 +- docs/src/whatsnew/3.2.rst | 2 +- docs/src/whatsnew/latest.rst | 7 ++++-- lib/iris/_concatenate.py | 2 +- lib/iris/_merge.py | 8 +++---- lib/iris/analysis/_area_weighted.py | 4 ++-- lib/iris/analysis/_interpolation.py | 2 +- lib/iris/analysis/_regrid.py | 4 ++-- lib/iris/analysis/cartography.py | 2 +- lib/iris/analysis/trajectory.py | 4 ++-- lib/iris/common/metadata.py | 4 ++-- lib/iris/common/resolve.py | 4 ++-- lib/iris/experimental/regrid.py | 12 +++++----- lib/iris/experimental/ugrid/mesh.py | 2 +- lib/iris/experimental/ugrid/utils.py | 2 +- .../fileformats/_nc_load_rules/helpers.py | 8 +++---- lib/iris/fileformats/cf.py | 2 +- lib/iris/fileformats/name.py | 2 +- lib/iris/fileformats/name_loaders.py | 4 ++-- lib/iris/fileformats/netcdf/saver.py | 6 ++--- lib/iris/fileformats/pp.py | 2 +- lib/iris/fileformats/rules.py | 6 ++--- lib/iris/io/__init__.py | 2 +- lib/iris/iterate.py | 2 +- lib/iris/palette.py | 2 +- lib/iris/pandas.py | 2 +- lib/iris/tests/experimental/test_raster.py | 2 +- lib/iris/tests/graphics/__init__.py | 4 ++-- .../integration/fast_load/test_fast_load.py | 2 +- lib/iris/tests/integration/test_Datums.py | 2 +- lib/iris/tests/stock/_stock_2d_latlons.py | 2 +- lib/iris/tests/test_basic_maths.py | 22 +++++++++---------- lib/iris/tests/test_cdm.py | 6 ++--- lib/iris/tests/test_cube_to_pp.py | 2 +- lib/iris/tests/test_netcdf.py | 12 +++++----- lib/iris/tests/test_plot.py | 4 ++-- lib/iris/tests/test_pp_module.py | 4 ++-- .../analysis/cartography/test_rotate_winds.py | 4 ++-- .../test_RectilinearInterpolator.py | 2 +- .../tests/unit/analysis/maths/__init__.py | 2 +- .../common/metadata/test__NamedTupleMeta.py | 2 +- .../metadata/test_metadata_manager_factory.py | 8 +++---- lib/iris/tests/unit/coords/test_Cell.py | 2 +- .../experimental/ugrid/mesh/test_MeshCoord.py | 2 +- .../name_loaders/test__cf_height_from_name.py | 2 +- .../actions/test__grid_mappings.py | 4 ++-- lib/iris/tests/unit/plot/test_plot.py | 2 +- .../cube_printout/test_Table.py | 2 +- lib/iris/util.py | 4 ++-- noxfile.py | 4 ++-- pyproject.toml | 4 ++++ tools/update_lockfiles.py | 2 +- 69 files changed, 148 insertions(+), 116 deletions(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 716560fab9..41c723c9ec 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -1,2 +1,20 @@ # Format: numpy array format (#5235) c18dcd8dafef0cc7bbbf80dfce66f76a46ce59c5 + +# style: flake8 (#3755) +7c86bc0168684345dc475457b1a77dadc77ce9bb + +# style: black (#3518) +ffcfad475e0593e1e40895453cf1df154e5f6f2c + +# style: isort (#4174) +15bbcc5ac3d539cb6e820148b66e7cf55d91c5d2 + +# style: blacken-docs (#4205) +1572e180243e492d8ff76fa8cdefb82ef6f90415 + +# style: sort-all (#4353) +64705dbc40881233aae45f051d96049150369e53 + +# style: codespell (#5186) +0b4277e69aa0b8541e8ad28ac57778928737af7c \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 92813ef1cb..a6c6edfd90 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,6 +28,13 @@ repos: # Don't commit to main branch. - id: no-commit-to-branch +- repo: https://github.com/codespell-project/codespell + rev: "v2.2.2" + hooks: + - id: codespell + types_or: [asciidoc, python, markdown, rst] + additional_dependencies: [tomli] + - repo: https://github.com/psf/black rev: 23.3.0 hooks: diff --git a/benchmarks/benchmarks/experimental/ugrid/regions_combine.py b/benchmarks/benchmarks/experimental/ugrid/regions_combine.py index 3b2d77a80a..c5f8fb564e 100644 --- a/benchmarks/benchmarks/experimental/ugrid/regions_combine.py +++ b/benchmarks/benchmarks/experimental/ugrid/regions_combine.py @@ -50,7 +50,7 @@ def _make_region_cubes(self, full_mesh_cube): i_faces = np.concatenate([i_faces[:, 2:], i_faces[:, :2]], axis=1) # flatten to get [2 3 4 0 1 (-) 8 9 10 6 7 (-) 13 14 15 11 12 ...] i_faces = i_faces.flatten() - # reduce back to orignal length, wrap any overflows into valid range + # reduce back to original length, wrap any overflows into valid range i_faces = i_faces[:n_faces] % n_faces # Divide into regions -- always slightly uneven, since 7 doesn't divide diff --git a/benchmarks/benchmarks/sperf/combine_regions.py b/benchmarks/benchmarks/sperf/combine_regions.py index d3d128c7d8..e27b3b1996 100644 --- a/benchmarks/benchmarks/sperf/combine_regions.py +++ b/benchmarks/benchmarks/sperf/combine_regions.py @@ -46,7 +46,7 @@ def _make_region_cubes(self, full_mesh_cube): i_faces = np.concatenate([i_faces[:, 2:], i_faces[:, :2]], axis=1) # flatten to get [2 3 4 0 1 (-) 8 9 10 6 7 (-) 13 14 15 11 12 ...] i_faces = i_faces.flatten() - # reduce back to orignal length, wrap any overflows into valid range + # reduce back to original length, wrap any overflows into valid range i_faces = i_faces[:n_faces] % n_faces # Divide into regions -- always slightly uneven, since 7 doesn't divide diff --git a/codecov.yml b/codecov.yml index bc1800b720..a0efbb9997 100644 --- a/codecov.yml +++ b/codecov.yml @@ -6,4 +6,4 @@ coverage: target: auto # coverage can drop by up to % while still posting success threshold: 3% - patch: off \ No newline at end of file + patch: off diff --git a/docs/gallery_code/general/plot_projections_and_annotations.py b/docs/gallery_code/general/plot_projections_and_annotations.py index 2cf42e66e0..c4254ad544 100644 --- a/docs/gallery_code/general/plot_projections_and_annotations.py +++ b/docs/gallery_code/general/plot_projections_and_annotations.py @@ -78,7 +78,7 @@ def make_plot(projection_name, projection_crs): y_points = y_lower + y_delta * np.concatenate( (zeros, steps, ones, steps[::-1]) ) - # Get the Iris coordinate sytem of the X coordinate (Y should be the same). + # Get the Iris coordinate system of the X coordinate (Y should be the same). cs_data1 = x_coord.coord_system # Construct an equivalent Cartopy coordinate reference system ("crs"). crs_data1 = cs_data1.as_cartopy_crs() diff --git a/docs/gallery_code/general/plot_rotated_pole_mapping.py b/docs/gallery_code/general/plot_rotated_pole_mapping.py index 8a0c80c707..30975a4828 100644 --- a/docs/gallery_code/general/plot_rotated_pole_mapping.py +++ b/docs/gallery_code/general/plot_rotated_pole_mapping.py @@ -40,7 +40,7 @@ def main(): plt.gca().coastlines() iplt.show() - # Plot #3: Contourf overlayed by coloured point data + # Plot #3: Contourf overlaid by coloured point data plt.figure() qplt.contourf(air_pressure) iplt.points(air_pressure, c=air_pressure.data) diff --git a/docs/gallery_code/meteorology/plot_lagged_ensemble.py b/docs/gallery_code/meteorology/plot_lagged_ensemble.py index db615a29f8..0639c7ac1d 100644 --- a/docs/gallery_code/meteorology/plot_lagged_ensemble.py +++ b/docs/gallery_code/meteorology/plot_lagged_ensemble.py @@ -115,7 +115,7 @@ def main(): # Get the time for the entire plot. time = last_time_coord.units.num2date(last_time_coord.bounds[0, 0]) - # Set a global title for the postage stamps with the date formated by + # Set a global title for the postage stamps with the date formatted by # "monthname year". time_string = time.strftime("%B %Y") plt.suptitle(f"Surface temperature ensemble forecasts for {time_string}") diff --git a/docs/src/IEP/IEP001.adoc b/docs/src/IEP/IEP001.adoc index d38b2e8478..e43969f3ce 100644 --- a/docs/src/IEP/IEP001.adoc +++ b/docs/src/IEP/IEP001.adoc @@ -119,7 +119,7 @@ cube.sel(height=1.5) The semantics of position-based slices will continue to match that of normal Python slices. The start position is included, the end position is excluded. -Value-based slices will be stricly inclusive, with both the start and end values included. This behaviour differs from normal Python slices but is in common with pandas. +Value-based slices will be strictly inclusive, with both the start and end values included. This behaviour differs from normal Python slices but is in common with pandas. Just as for normal Python slices, we do not need to provide the ability to control the include/exclude behaviour for slicing. diff --git a/docs/src/community/iris_xarray.rst b/docs/src/community/iris_xarray.rst index 859597da78..2250e3c0a3 100644 --- a/docs/src/community/iris_xarray.rst +++ b/docs/src/community/iris_xarray.rst @@ -11,7 +11,7 @@ you can be prepared, and to help you choose the best package for your use case. Overall Experience ------------------ -Iris is the more specialised package, focussed on making it as easy +Iris is the more specialised package, focused on making it as easy as possible to work with meteorological and climatological data. Iris is built to natively handle many key concepts, such as the CF conventions, coordinate systems and bounded coordinates. Iris offers a smaller toolkit of diff --git a/docs/src/conf.py b/docs/src/conf.py index 4d35190048..0e0160fbe8 100644 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -81,7 +81,7 @@ def autolog(message): # add some sample files from the developers guide.. sys.path.append(os.path.abspath(os.path.join("developers_guide"))) -# why isnt the iris path added to it is discoverable too? We dont need to, +# why isn't the iris path added to it is discoverable too? We dont need to, # the sphinext to generate the api rst knows where the source is. If it # is added then the travis build will likely fail. diff --git a/docs/src/developers_guide/gitwash/configure_git.rst b/docs/src/developers_guide/gitwash/configure_git.rst index fd8218487f..564ae51820 100644 --- a/docs/src/developers_guide/gitwash/configure_git.rst +++ b/docs/src/developers_guide/gitwash/configure_git.rst @@ -144,7 +144,7 @@ and it gives graph / text output something like this (but with color!):: | * 4aff2a8 - fixed bug 35, and added a test in test_bugfixes (2 weeks ago) [Hugo] |/ * a7ff2e5 - Added notes on discussion/proposal made during Data Array Summit. (2 weeks ago) [Corran Webster] - * 68f6752 - Initial implimentation of AxisIndexer - uses 'index_by' which needs to be changed to a call on an Axes object - this is all very sketchy right now. (2 weeks ago) [Corr + * 68f6752 - Initial implementation of AxisIndexer - uses 'index_by' which needs to be changed to a call on an Axes object - this is all very sketchy right now. (2 weeks ago) [Corr * 376adbd - Merge pull request #46 from terhorst/main (2 weeks ago) [Jonathan Terhorst] |\ | * b605216 - updated joshu example to current api (3 weeks ago) [Jonathan Terhorst] diff --git a/docs/src/developers_guide/release.rst b/docs/src/developers_guide/release.rst index 4b14876371..1e18677808 100644 --- a/docs/src/developers_guide/release.rst +++ b/docs/src/developers_guide/release.rst @@ -173,7 +173,7 @@ Ensure that the artifacts are successfully uploaded and available on from PyPI:: > conda deactivate - > conda env create --file ./requrements/ci/iris.yml + > conda env create --file ./requirements/iris.yml > . activate iris-dev > python -m pip install --no-deps scitools-iris diff --git a/docs/src/further_topics/ugrid/operations.rst b/docs/src/further_topics/ugrid/operations.rst index 152d4415b0..29a05ec044 100644 --- a/docs/src/further_topics/ugrid/operations.rst +++ b/docs/src/further_topics/ugrid/operations.rst @@ -897,7 +897,7 @@ previously initialised regridder: .. code-block:: python - # Extract a different cube defined on te same Mesh. + # Extract a different cube defined on the same Mesh. >>> mesh_cube2 = mesh_cubes.extract_cube("precipitation_flux") >>> print(mesh_cube2) precipitation_flux / (kg m-2 s-1) (-- : 1; -- : 13824) diff --git a/docs/src/userguide/plotting_examples/1d_with_legend.py b/docs/src/userguide/plotting_examples/1d_with_legend.py index 626335af45..6b29fc9e76 100644 --- a/docs/src/userguide/plotting_examples/1d_with_legend.py +++ b/docs/src/userguide/plotting_examples/1d_with_legend.py @@ -31,7 +31,7 @@ plt.grid(True) # Provide some axis labels -plt.ylabel("Temerature / kelvin") +plt.ylabel("Temperature / kelvin") plt.xlabel("Longitude / degrees") # And a sensible title diff --git a/docs/src/whatsnew/1.7.rst b/docs/src/whatsnew/1.7.rst index 44ebe9ec60..1d7c7c3f60 100644 --- a/docs/src/whatsnew/1.7.rst +++ b/docs/src/whatsnew/1.7.rst @@ -21,14 +21,14 @@ Features transparent; for example, before the introduction of biggus, MemoryErrors were likely for very large datasets:: - >>> result = extremely_large_cube.collapsed('time', iris.analyis.MEAN) + >>> result = extremely_large_cube.collapsed('time', iris.analysis.MEAN) MemoryError Now, for supported operations, the evaluation is lazy (i.e. it doesn't take place until the actual data is subsequently requested) and can handle data larger than available system memory:: - >>> result = extremely_large_cube.collapsed('time', iris.analyis.MEAN) + >>> result = extremely_large_cube.collapsed('time', iris.analysis.MEAN) >>> print(type(result)) diff --git a/docs/src/whatsnew/2.0.rst b/docs/src/whatsnew/2.0.rst index 400a395e90..4ef50a4101 100644 --- a/docs/src/whatsnew/2.0.rst +++ b/docs/src/whatsnew/2.0.rst @@ -36,7 +36,7 @@ Features * The *new* in-place arithmetic operators :data:`__iadd__`, :data:`__idiv__`, :data:`__imul__`, :data:`__isub__`, and :data:`__itruediv__` have been added to support :class:`~iris.cube.Cube` operations :data:`+=`, - :data:`/=`, :data:`*=`, and :data:`-=`. Note that, for **divison** + :data:`/=`, :data:`*=`, and :data:`-=`. Note that, for **division** *__future__.division* is always in effect. * Changes to the :class:`iris.coords.Coord`: diff --git a/docs/src/whatsnew/3.0.rst b/docs/src/whatsnew/3.0.rst index 145ab04d63..4107ae5d2b 100644 --- a/docs/src/whatsnew/3.0.rst +++ b/docs/src/whatsnew/3.0.rst @@ -142,7 +142,7 @@ v3.0.4 (22 July 2021) Firstly, ancillary-variables or cell-measures with long names can now widen the cube "dimensions map" to fit, whereas previously printing these cases caused an Exception. Secondly, cube units are now always printed, whereas previously they were missed out any time that the - "dimensions map" was widened to accomodate long coordinate names. + "dimensions map" was widened to accommodate long coordinate names. (:pull:`4233`)(:pull:`4238`) 💼 **Internal** diff --git a/docs/src/whatsnew/3.2.rst b/docs/src/whatsnew/3.2.rst index 312588343e..87a85f9061 100644 --- a/docs/src/whatsnew/3.2.rst +++ b/docs/src/whatsnew/3.2.rst @@ -167,7 +167,7 @@ v3.2.1 (11 Mar 2022) as well as some long-standing bugs with vertical coordinates and number formats. (:pull:`4411`) -#. `@rcomer`_ fixed :meth:`~iris.cube.Cube.subset` to alway return ``None`` if +#. `@rcomer`_ fixed :meth:`~iris.cube.Cube.subset` to always return ``None`` if no value match is found. (:pull:`4417`) #. `@wjbenfold`_ changed :meth:`iris.util.points_step` to stop it from warning diff --git a/docs/src/whatsnew/latest.rst b/docs/src/whatsnew/latest.rst index c1447f72c3..f395baeb76 100644 --- a/docs/src/whatsnew/latest.rst +++ b/docs/src/whatsnew/latest.rst @@ -20,6 +20,7 @@ This document explains the changes made to Iris for this release And finally, get in touch with us on :issue:`GitHub` if you have any issues or feature requests for improving Iris. Enjoy! + 📢 Announcements ================ @@ -68,10 +69,12 @@ This document explains the changes made to Iris for this release #. `@tkknight`_ migrated to `sphinx-design`_ over the legacy `sphinx-panels`_. (:pull:`5127`) + 💼 Internal =========== -#. N/A +#. `@bjlittle`_ added the `codespell`_ `pre-commit`_ ``git-hook`` to automate + spell checking within the code-base. (:pull:`5186`) .. comment @@ -85,4 +88,4 @@ This document explains the changes made to Iris for this release Whatsnew resources in alphabetical order: .. _sphinx-panels: https://github.com/executablebooks/sphinx-panels -.. _sphinx-design: https://github.com/executablebooks/sphinx-design \ No newline at end of file +.. _sphinx-design: https://github.com/executablebooks/sphinx-design diff --git a/lib/iris/_concatenate.py b/lib/iris/_concatenate.py index a383e4e01a..01a1bb689b 100644 --- a/lib/iris/_concatenate.py +++ b/lib/iris/_concatenate.py @@ -22,7 +22,7 @@ # # * Cope with auxiliary coordinate factories. # -# * Allow concatentation over a user specified dimension. +# * Allow concatenation over a user specified dimension. # diff --git a/lib/iris/_merge.py b/lib/iris/_merge.py index 5ca5f31a8e..0f748d6d34 100644 --- a/lib/iris/_merge.py +++ b/lib/iris/_merge.py @@ -298,7 +298,7 @@ class _CoordSignature( ): """ Criterion for identifying a specific type of :class:`iris.cube.Cube` - based on its scalar and vector coorinate data and metadata, and + based on its scalar and vector coordinate data and metadata, and auxiliary coordinate factories. Args: @@ -516,7 +516,7 @@ class _Relation(namedtuple("Relation", ["separable", "inseparable"])): * separable: A set of independent candidate dimension names. - * inseperable: + * inseparable: A set of dependent candidate dimension names. """ @@ -1419,7 +1419,7 @@ def _define_space(self, space, positions, indexes, function_matrix): """ - # Heuristic reordering of coordinate defintion indexes into + # Heuristic reordering of coordinate definition indexes into # preferred dimension order. def axis_and_name(name): axis_dict = {"T": 1, "Z": 2, "Y": 3, "X": 4} @@ -1467,7 +1467,7 @@ def axis_and_name(name): } else: # TODO: Consider appropriate sort order (ascending, - # decending) i.e. use CF positive attribute. + # descending) i.e. use CF positive attribute. cells = sorted(indexes[name]) points = np.array( [cell.point for cell in cells], diff --git a/lib/iris/analysis/_area_weighted.py b/lib/iris/analysis/_area_weighted.py index 3b728e9a43..edead3948a 100644 --- a/lib/iris/analysis/_area_weighted.py +++ b/lib/iris/analysis/_area_weighted.py @@ -433,7 +433,7 @@ def _spherical_area(y_bounds, x_bounds, radius=1.0): Args: * y_bounds: - An (n, 2) shaped NumPy array of latitide bounds in radians. + An (n, 2) shaped NumPy array of latitude bounds in radians. * x_bounds: An (m, 2) shaped NumPy array of longitude bounds in radians. * radius: @@ -586,7 +586,7 @@ def _regrid_area_weighted_array( y_dim = src_data.ndim - 2 # Create empty "pre-averaging" data array that will enable the - # src_data data coresponding to a given target grid point, + # src_data data corresponding to a given target grid point, # to be stacked per point. # Note that dtype is not preserved and that the array mask # allows for regions that do not overlap. diff --git a/lib/iris/analysis/_interpolation.py b/lib/iris/analysis/_interpolation.py index f5e89a9e51..34dcae3026 100644 --- a/lib/iris/analysis/_interpolation.py +++ b/lib/iris/analysis/_interpolation.py @@ -213,7 +213,7 @@ def __init__(self, src_cube, coords, method, extrapolation_mode): # Trigger any deferred loading of the source cube's data and snapshot # its state to ensure that the interpolator is impervious to external # changes to the original source cube. The data is loaded to prevent - # the snaphot having lazy data, avoiding the potential for the + # the snapshot having lazy data, avoiding the potential for the # same data to be loaded again and again. if src_cube.has_lazy_data(): src_cube.data diff --git a/lib/iris/analysis/_regrid.py b/lib/iris/analysis/_regrid.py index f1891a48e4..4592a0ede7 100644 --- a/lib/iris/analysis/_regrid.py +++ b/lib/iris/analysis/_regrid.py @@ -239,7 +239,7 @@ def _regrid_indices(cells, depth, points): x_indices = _regrid_indices(tx_cells, tx_depth, sx_points) y_indices = _regrid_indices(ty_cells, ty_depth, sy_points) - # Now construct a sparse M x N matix, where M is the flattened target + # Now construct a sparse M x N matrix, where M is the flattened target # space, and N is the flattened source space. The sparse matrix will then # be populated with those source cube points that contribute to a specific # target cube cell. @@ -1021,7 +1021,7 @@ def _create_cube( The dimensions of the X and Y coordinate within the source Cube. tgt_coords : tuple of :class:`iris.coords.Coord`\\ 's Either two 1D :class:`iris.coords.DimCoord`\\ 's, two 1D - :class:`iris.experimental.ugrid.DimCoord`\\ 's or two ND + :class:`iris.experimental.ugrid.DimCoord`\\ 's or two n-D :class:`iris.coords.AuxCoord`\\ 's representing the new grid's X and Y coordinates. num_tgt_dims : int diff --git a/lib/iris/analysis/cartography.py b/lib/iris/analysis/cartography.py index 5b11495d5a..0d17f0b38a 100644 --- a/lib/iris/analysis/cartography.py +++ b/lib/iris/analysis/cartography.py @@ -1013,7 +1013,7 @@ def _transform_distance_vectors_tolerance_mask( """ Return a mask that can be applied to data array to mask elements where the magnitude of vectors are not preserved due to numerical - errors introduced by the tranformation between coordinate systems. + errors introduced by the transformation between coordinate systems. Args: * src_crs (`cartopy.crs.Projection`): diff --git a/lib/iris/analysis/trajectory.py b/lib/iris/analysis/trajectory.py index 24f7a9dede..84ce89ab6f 100644 --- a/lib/iris/analysis/trajectory.py +++ b/lib/iris/analysis/trajectory.py @@ -347,7 +347,7 @@ def interpolate(cube, sample_points, method=None): for columns_coord in columns.dim_coords + columns.aux_coords: src_dims = cube.coord_dims(columns_coord) if not squish_my_dims.isdisjoint(src_dims): - # Mapping the cube indicies onto the coord + # Mapping the cube indices onto the coord initial_coord_inds = [initial_inds[ind] for ind in src_dims] # Making the final ones the same way as for the cube # 0 will always appear in the initial ones because we know this @@ -660,7 +660,7 @@ def _nearest_neighbour_indices_ndcoords(cube, sample_points, cache=None): for c, (coord, coord_dims) in enumerate( sample_space_coords_and_dims ): - # Index of this datum along this coordinate (could be nD). + # Index of this datum along this coordinate (could be n-D). if coord_dims: keys = tuple(ndi[ind] for ind in coord_dims) else: diff --git a/lib/iris/common/metadata.py b/lib/iris/common/metadata.py index cb3149fe58..7def79f51e 100644 --- a/lib/iris/common/metadata.py +++ b/lib/iris/common/metadata.py @@ -52,7 +52,7 @@ def hexdigest(item): """ - Calculate a hexidecimal string hash representation of the provided item. + Calculate a hexadecimal string hash representation of the provided item. Calculates a 64-bit non-cryptographic hash of the provided item, using the extremely fast ``xxhash`` hashing algorithm, and returns the hexdigest @@ -67,7 +67,7 @@ def hexdigest(item): The item that requires to have its hexdigest calculated. Returns: - The string hexidecimal representation of the item's 64-bit hash. + The string hexadecimal representation of the item's 64-bit hash. """ # Special case: deal with numpy arrays. diff --git a/lib/iris/common/resolve.py b/lib/iris/common/resolve.py index 19e4e44fc6..8d5d57d4a4 100644 --- a/lib/iris/common/resolve.py +++ b/lib/iris/common/resolve.py @@ -726,7 +726,7 @@ def _create_prepared_item( If container or type(coord) is DimCoord/AuxCoord (i.e. not MeshCoord), then points+bounds define the built AuxCoord/DimCoord. - Theses points+bounds come either from those args, or the 'coord'. + These points+bounds come either from those args, or the 'coord'. Alternatively, when container or type(coord) is MeshCoord, then points==bounds==None and the preparted item contains mesh/location/axis properties for the resulting MeshCoord. @@ -1014,7 +1014,7 @@ def _assign_mapping(extent, unmapped_local_items, free_items=None): # Map to the first available unmapped local dimension or # the first available free dimension. # Dimension shape doesn't matter here as the extent is 1, - # therefore broadcasting will take care of any discrepency + # therefore broadcasting will take care of any discrepancy # between src and tgt dimension extent. if unmapped_local_items: result, _ = unmapped_local_items.pop(0) diff --git a/lib/iris/experimental/regrid.py b/lib/iris/experimental/regrid.py index 7c5d8e99cc..76c6002d2b 100644 --- a/lib/iris/experimental/regrid.py +++ b/lib/iris/experimental/regrid.py @@ -295,23 +295,23 @@ def __init__(self, src_cube, tgt_grid_cube, method, projection=None): if src_x_coord.coord_system != src_y_coord.coord_system: raise ValueError( "'src_cube' lateral geographic coordinates have " - "differing coordinate sytems." + "differing coordinate systems." ) if src_x_coord.coord_system is None: raise ValueError( "'src_cube' lateral geographic coordinates have " - "no coordinate sytem." + "no coordinate system." ) tgt_x_coord, tgt_y_coord = get_xy_dim_coords(tgt_grid_cube) if tgt_x_coord.coord_system != tgt_y_coord.coord_system: raise ValueError( "'tgt_grid_cube' lateral geographic coordinates " - "have differing coordinate sytems." + "have differing coordinate systems." ) if tgt_x_coord.coord_system is None: raise ValueError( "'tgt_grid_cube' lateral geographic coordinates " - "have no coordinate sytem." + "have no coordinate system." ) if projection is None: @@ -572,12 +572,12 @@ def __call__(self, src_cube): if src_x_coord.coord_system != src_y_coord.coord_system: raise ValueError( "'src' lateral geographic coordinates have " - "differing coordinate sytems." + "differing coordinate systems." ) if src_cs is None: raise ValueError( "'src' lateral geographic coordinates have " - "no coordinate sytem." + "no coordinate system." ) # Check the source grid units. diff --git a/lib/iris/experimental/ugrid/mesh.py b/lib/iris/experimental/ugrid/mesh.py index 0d566da73f..af557c345c 100644 --- a/lib/iris/experimental/ugrid/mesh.py +++ b/lib/iris/experimental/ugrid/mesh.py @@ -2855,7 +2855,7 @@ def __init__( # N.B. at present, coords in a Mesh are stored+accessed by 'axis', which # means they must have a standard_name. So ... - # (a) the 'location' (face/edge) coord *always* has a useable phenomenon + # (a) the 'location' (face/edge) coord *always* has a usable phenomenon # identity. # (b) we still want to check that location+node coords have the same # phenomenon (i.e. physical meaning identity + units), **but** ... diff --git a/lib/iris/experimental/ugrid/utils.py b/lib/iris/experimental/ugrid/utils.py index 4efab6490b..a13a43d3fd 100644 --- a/lib/iris/experimental/ugrid/utils.py +++ b/lib/iris/experimental/ugrid/utils.py @@ -220,7 +220,7 @@ def recombine_submeshes( # Use the mesh_dim to transpose inputs + outputs, if required, as it is # simpler for all the array operations to always have the mesh dim *last*. if mesh_dim == mesh_cube.ndim - 1: - # Mesh dim is already the last one : no tranpose required + # Mesh dim is already the last one : no transpose required untranspose_dims = None else: dim_range = np.arange(mesh_cube.ndim, dtype=int) diff --git a/lib/iris/fileformats/_nc_load_rules/helpers.py b/lib/iris/fileformats/_nc_load_rules/helpers.py index 35163c47d5..8e6161bac5 100644 --- a/lib/iris/fileformats/_nc_load_rules/helpers.py +++ b/lib/iris/fileformats/_nc_load_rules/helpers.py @@ -347,7 +347,7 @@ def build_transverse_mercator_coordinate_system(engine, cf_grid_var): cf_grid_var, CF_ATTR_GRID_SCALE_FACTOR_AT_CENT_MERIDIAN, None ) - # The following accounts for the inconsistancy in the transverse + # The following accounts for the inconsistency in the transverse # mercator description within the CF spec. if longitude_of_central_meridian is None: longitude_of_central_meridian = getattr( @@ -670,7 +670,7 @@ def get_attr_units(cf_var, attributes): ): attr_units = cf_units._NO_UNIT_STRING - # Get any assoicated calendar for a time reference coordinate. + # Get any associated calendar for a time reference coordinate. if cf_units.as_unit(attr_units).is_time_reference(): attr_calendar = getattr(cf_var, CF_ATTR_CALENDAR, None) @@ -727,7 +727,7 @@ def get_cf_bounds_var(cf_coord_var): attr_bounds = getattr(cf_coord_var, CF_ATTR_BOUNDS, None) attr_climatology = getattr(cf_coord_var, CF_ATTR_CLIMATOLOGY, None) - # Determine bounds, prefering standard bounds over climatology. + # Determine bounds, preferring standard bounds over climatology. # NB. No need to raise a warning if the bounds/climatology # variable is missing, as that will already have been done by # iris.fileformats.cf. @@ -1270,7 +1270,7 @@ def _is_rotated(engine, cf_name, cf_attr_value): ################################################################################ def is_rotated_latitude(engine, cf_name): - """Determine whether the CF coodinate variable is rotated latitude.""" + """Determine whether the CF coordinate variable is rotated latitude.""" return _is_rotated(engine, cf_name, CF_VALUE_STD_NAME_GRID_LAT) diff --git a/lib/iris/fileformats/cf.py b/lib/iris/fileformats/cf.py index a21e1d975f..0b058abba6 100644 --- a/lib/iris/fileformats/cf.py +++ b/lib/iris/fileformats/cf.py @@ -1076,7 +1076,7 @@ def __enter__(self): # Note: ideally, the class would not do so much work in the __init__ call, and # would do all that here, after acquiring necessary permissions/locks. # But for legacy reasons, we can't do that. So **effectively**, the context - # (in terms of access control) alreday started, when we created the object. + # (in terms of access control) already started, when we created the object. return self def __exit__(self, exc_type, exc_value, traceback): diff --git a/lib/iris/fileformats/name.py b/lib/iris/fileformats/name.py index a0b799697d..9a779cc92d 100644 --- a/lib/iris/fileformats/name.py +++ b/lib/iris/fileformats/name.py @@ -8,7 +8,7 @@ def _get_NAME_loader(filename): """ - Return the approriate load function for a NAME file based + Return the appropriate load function for a NAME file based on the contents of its header. """ diff --git a/lib/iris/fileformats/name_loaders.py b/lib/iris/fileformats/name_loaders.py index b9b64a343e..0189a8806f 100644 --- a/lib/iris/fileformats/name_loaders.py +++ b/lib/iris/fileformats/name_loaders.py @@ -588,7 +588,7 @@ def _build_cell_methods(av_or_ints, coord): Args: * av_or_ints (iterable of strings): - An iterable of strings containing the colummn heading entries + An iterable of strings containing the column heading entries to be parsed. * coord (string or :class:`iris.coords.Coord`): The coordinate name (or :class:`iris.coords.Coord` instance) @@ -1079,7 +1079,7 @@ def load_NAMEIII_version2(filename): elif zunits == "Pa": z_name = "air_pressure" else: - ValueError("Vertical coordinate unkown") + ValueError("Vertical coordinate unknown") zindex = data.index(zgrid[0]) dim_coords.append("Z") diff --git a/lib/iris/fileformats/netcdf/saver.py b/lib/iris/fileformats/netcdf/saver.py index f7f4864f9e..e5e696d3c3 100644 --- a/lib/iris/fileformats/netcdf/saver.py +++ b/lib/iris/fileformats/netcdf/saver.py @@ -1036,7 +1036,7 @@ def _add_inner_related_vars( """ if coordlike_elements: - # Choose the approriate parent attribute + # Choose the appropriate parent attribute elem_type = type(coordlike_elements[0]) if elem_type in (AuxCoord, DimCoord): role_attribute_name = "coordinates" @@ -1190,7 +1190,7 @@ def _add_aux_factories(self, cube, cf_var_cube, dimension_names): warnings.warn(msg) else: # Override `standard_name`, `long_name`, and `axis` of the - # primary coord that signals the presense of a dimensionless + # primary coord that signals the presence of a dimensionless # vertical coord, then set the `formula_terms` attribute. primary_coord = factory.dependencies[factory_defn.primary] if primary_coord in primaries: @@ -1497,7 +1497,7 @@ def cf_valid_var_name(var_name): A var_name suitable for passing through for variable creation. """ - # Replace invalid charaters with an underscore ("_"). + # Replace invalid characters with an underscore ("_"). var_name = re.sub(r"[^a-zA-Z0-9]", "_", var_name) # Ensure the variable name starts with a letter. if re.match(r"^[^a-zA-Z]", var_name): diff --git a/lib/iris/fileformats/pp.py b/lib/iris/fileformats/pp.py index cff088cf89..ad0c6272ad 100644 --- a/lib/iris/fileformats/pp.py +++ b/lib/iris/fileformats/pp.py @@ -1678,7 +1678,7 @@ def load(filename, read_data=False, little_ended=False): def _interpret_fields(fields): """ - Turn the fields read with load and FF2PP._extract_field into useable + Turn the fields read with load and FF2PP._extract_field into usable fields. One of the primary purposes of this function is to either convert "deferred bytes" into "deferred arrays" or "loaded bytes" into actual numpy arrays (via the _create_field_data) function. diff --git a/lib/iris/fileformats/rules.py b/lib/iris/fileformats/rules.py index 51940b7c4d..707fd58757 100644 --- a/lib/iris/fileformats/rules.py +++ b/lib/iris/fileformats/rules.py @@ -404,15 +404,15 @@ def _load_pairs_from_fields_and_filenames( def load_pairs_from_fields(fields, converter): """ Convert an iterable of fields into an iterable of Cubes using the - provided convertor. + provided converter. Args: * fields: An iterable of fields. - * convertor: - An Iris convertor function, suitable for use with the supplied fields. + * converter: + An Iris converter function, suitable for use with the supplied fields. See the description in :class:`iris.fileformats.rules.Loader`. Returns: diff --git a/lib/iris/io/__init__.py b/lib/iris/io/__init__.py index 7dd08c723c..a4f700cb51 100644 --- a/lib/iris/io/__init__.py +++ b/lib/iris/io/__init__.py @@ -216,7 +216,7 @@ def load_files(filenames, callback, constraints=None): ) handler_map[handling_format_spec].append(fn) - # Call each iris format handler with the approriate filenames + # Call each iris format handler with the appropriate filenames for handling_format_spec in sorted(handler_map): fnames = handler_map[handling_format_spec] if handling_format_spec.constraint_aware_handler: diff --git a/lib/iris/iterate.py b/lib/iris/iterate.py index d6bac77d3b..cf16c9cbe6 100644 --- a/lib/iris/iterate.py +++ b/lib/iris/iterate.py @@ -233,7 +233,7 @@ def __init__(self, cubes, requested_dims_by_cube, ordered, coords_by_cube): break # If a coordinate with an equivalent definition (i.e. same # metadata) is not found in the master_dimensioned_coord_list, - # add the coords assocaited with the dimension to the list, + # add the coords associated with the dimension to the list, # add the size of the dimension to the master_dims_index and # store the offset. if not found: diff --git a/lib/iris/palette.py b/lib/iris/palette.py index a1c0a1e878..3ba17ffc97 100644 --- a/lib/iris/palette.py +++ b/lib/iris/palette.py @@ -57,7 +57,7 @@ def is_brewer(cmap): def _default_cmap_norm(args, kwargs): """ - This function injects default cmap and norm behavour into the keyword + This function injects default cmap and norm behaviour into the keyword arguments, based on the cube referenced within the positional arguments. """ cube = None diff --git a/lib/iris/pandas.py b/lib/iris/pandas.py index fb0740a53c..4d6681e94e 100644 --- a/lib/iris/pandas.py +++ b/lib/iris/pandas.py @@ -172,7 +172,7 @@ def as_cube( if pandas_array.ndim not in [1, 2]: raise ValueError( "Only 1D or 2D Pandas arrays " - "can currently be conveted to Iris cubes." + "can currently be converted to Iris cubes." ) # Make the copy work consistently across NumPy 1.6 and 1.7. diff --git a/lib/iris/tests/experimental/test_raster.py b/lib/iris/tests/experimental/test_raster.py index c654483bfd..ffd03e6f4d 100644 --- a/lib/iris/tests/experimental/test_raster.py +++ b/lib/iris/tests/experimental/test_raster.py @@ -42,7 +42,7 @@ def check_tiff_header(self, tiff_filename, expect_keys, expect_entries): def check_tiff(self, cube, header_keys, header_items): # Check that the cube saves correctly to TIFF : # * the header contains expected keys and (some) values - # * the data array retrives correctly + # * the data array retrieves correctly import iris.experimental.raster with self.temp_filename(".tif") as temp_filename: diff --git a/lib/iris/tests/graphics/__init__.py b/lib/iris/tests/graphics/__init__.py index 544d989564..5ee555cb6e 100755 --- a/lib/iris/tests/graphics/__init__.py +++ b/lib/iris/tests/graphics/__init__.py @@ -113,10 +113,10 @@ def write_repo_json(data: Dict[str, str]) -> None: string_data = {} for key, val in data.items(): string_data[key] = str(val) - with open(IMAGE_REPO_PATH, "wb") as fo: + with open(IMAGE_REPO_PATH, "wb") as fout: json.dump( string_data, - codecs.getwriter("utf-8")(fo), + codecs.getwriter("utf-8")(fout), indent=4, sort_keys=True, ) diff --git a/lib/iris/tests/integration/fast_load/test_fast_load.py b/lib/iris/tests/integration/fast_load/test_fast_load.py index a510ef7257..318292615b 100644 --- a/lib/iris/tests/integration/fast_load/test_fast_load.py +++ b/lib/iris/tests/integration/fast_load/test_fast_load.py @@ -419,7 +419,7 @@ def test_load_raw(self): expected = CubeList(fldset_1 + fldset_2) else: # 'Raw' cubes have combined (vector) times within each file. - # The 'other' phenomenon appears seperately. + # The 'other' phenomenon appears separately. expected = CubeList( [ CubeList(fldset_1[:2]).merge_cube(), diff --git a/lib/iris/tests/integration/test_Datums.py b/lib/iris/tests/integration/test_Datums.py index 6953534f2d..43287c7040 100755 --- a/lib/iris/tests/integration/test_Datums.py +++ b/lib/iris/tests/integration/test_Datums.py @@ -3,7 +3,7 @@ # This file is part of Iris and is released under the LGPL license. # See COPYING and COPYING.LESSER in the root of the repository for full # licensing details. -"""Integration tests for :class:`iris.coord_systems` datum suppport.""" +"""Integration tests for :class:`iris.coord_systems` datum support.""" # Import iris.tests first so that some things can be initialised before # importing anything else. diff --git a/lib/iris/tests/stock/_stock_2d_latlons.py b/lib/iris/tests/stock/_stock_2d_latlons.py index b7fda5fa40..4733a15305 100644 --- a/lib/iris/tests/stock/_stock_2d_latlons.py +++ b/lib/iris/tests/stock/_stock_2d_latlons.py @@ -118,7 +118,7 @@ def sample_2d_latlons(regional=False, rotated=False, transformed=False): """ Construct small 2d cubes with 2d X and Y coordinates. - This makes cubes with 'expanded' coordinates (4 bounds per cell), analagous + This makes cubes with 'expanded' coordinates (4 bounds per cell), analogous to ORCA data. The coordinates are always geographical, so either it has a coord system or they are "true" lats + lons. diff --git a/lib/iris/tests/test_basic_maths.py b/lib/iris/tests/test_basic_maths.py index 6c08dc1f9e..4d92b9a92c 100644 --- a/lib/iris/tests/test_basic_maths.py +++ b/lib/iris/tests/test_basic_maths.py @@ -589,9 +589,9 @@ def test_apply_ufunc(self): in_place=False, ) - ans = a.data**2 + answer = a.data**2 - self.assertArrayEqual(b.data, ans) + self.assertArrayEqual(b.data, answer) self.assertEqual(b.name(), "more_thingness") self.assertEqual(b.units, cf_units.Unit("m^2")) @@ -603,10 +603,10 @@ def vec_mag(u, v): vec_mag_ufunc = np.frompyfunc(vec_mag, 2, 1) b = iris.analysis.maths.apply_ufunc(vec_mag_ufunc, a, c) - ans = a.data**2 + c.data**2 + answer = a.data**2 + c.data**2 b2 = b**2 - self.assertArrayAlmostEqual(b2.data, ans) + self.assertArrayAlmostEqual(b2.data, answer) class TestIFunc(tests.IrisTest): @@ -620,9 +620,9 @@ def test_ifunc(self): my_ifunc = iris.analysis.maths.IFunc(np.square, lambda x: x.units**2) b = my_ifunc(a, new_name="more_thingness", in_place=False) - ans = a.data**2 + answer = a.data**2 - self.assertArrayEqual(b.data, ans) + self.assertArrayEqual(b.data, answer) self.assertEqual(b.name(), "more_thingness") self.assertEqual(b.units, cf_units.Unit("m^2")) @@ -637,9 +637,9 @@ def vec_mag(u, v): ) b = my_ifunc(a, c) - ans = (a.data**2 + c.data**2) ** 0.5 + answer = (a.data**2 + c.data**2) ** 0.5 - self.assertArrayAlmostEqual(b.data, ans) + self.assertArrayAlmostEqual(b.data, answer) def vec_mag_data_func(u_data, v_data): return np.sqrt(u_data**2 + v_data**2) @@ -654,10 +654,10 @@ def vec_mag_data_func(u_data, v_data): cs_ifunc = iris.analysis.maths.IFunc(np.cumsum, lambda a: a.units) b = cs_ifunc(a, axis=1) - ans = a.data.copy() - ans = np.cumsum(ans, axis=1) + answer = a.data.copy() + answer = np.cumsum(answer, axis=1) - self.assertArrayAlmostEqual(b.data, ans) + self.assertArrayAlmostEqual(b.data, answer) @tests.skip_data diff --git a/lib/iris/tests/test_cdm.py b/lib/iris/tests/test_cdm.py index 8f2a9b474d..0abb35c566 100644 --- a/lib/iris/tests/test_cdm.py +++ b/lib/iris/tests/test_cdm.py @@ -486,7 +486,7 @@ def test_axis(self): coords = cube.coords(axis="x") self.assertEqual([coord.name() for coord in coords], ["longitude"]) - # Renaming shoudn't be enough + # Renaming shouldn't be enough cube.coord("an_other").rename("time") coords = cube.coords(axis="t") self.assertEqual([coord.name() for coord in coords], []) @@ -718,7 +718,7 @@ def test_cube_slice_zero_len_slice(self): def test_cube_slice_with_non_existant_coords(self): with self.assertRaises(iris.exceptions.CoordinateNotFoundError): - self.t.slices(["dim2", "dim1", "doesnt exist"]) + self.t.slices(["dim2", "dim1", "doesn't exist"]) def test_cube_extract_coord_with_non_describing_coordinates(self): with self.assertRaises(ValueError): @@ -1478,7 +1478,7 @@ def test_coord_conversion(self): # Invalid coords invalid_choices = [ - iris.analysis.MEAN, # Caused by mixing up argument order in call to cube.collasped for example + iris.analysis.MEAN, # Caused by mixing up argument order in call to cube.collapsed for example None, ["grid_latitude", None], [lat, None], diff --git a/lib/iris/tests/test_cube_to_pp.py b/lib/iris/tests/test_cube_to_pp.py index f2c0a9ae30..a6fc5e3149 100644 --- a/lib/iris/tests/test_cube_to_pp.py +++ b/lib/iris/tests/test_cube_to_pp.py @@ -348,7 +348,7 @@ def test_pp_save_rules(self): os.remove(temp_filename) - # Test mutiple process flags + # Test multiple process flags multiple_bit_values = ((128, 64), (4096, 1024), (8192, 1024)) # Maps lbproc value to the process flags that should be created diff --git a/lib/iris/tests/test_netcdf.py b/lib/iris/tests/test_netcdf.py index d182de84f6..6438140ed9 100644 --- a/lib/iris/tests/test_netcdf.py +++ b/lib/iris/tests/test_netcdf.py @@ -96,7 +96,7 @@ def test_load_global_xyzt_gems(self): cubes = sorted(cubes, key=lambda cube: cube.name()) self.assertCML(cubes, ("netcdf", "netcdf_global_xyzt_gems.cml")) - # Check the masked array fill value is propogated through the data + # Check the masked array fill value is propagated through the data # manager loading. lnsp = cubes[1] self.assertTrue(ma.isMaskedArray(lnsp.data)) @@ -1029,11 +1029,11 @@ def test_attributes(self): } for k, v in aglobals.items(): self.cube.attributes[k] = v - # Should be overriden. + # Should be overridden. aover = {"Conventions": "TEST"} for k, v in aover.items(): self.cube.attributes[k] = v - # Should be data varible attributes. + # Should be data variable attributes. avars = { "standard_error_multiplier": 23, "flag_masks": "a", @@ -1057,14 +1057,14 @@ def test_attributes(self): getattr(ds, gkey), aglobals.get(gkey) ) ) - # Should be overriden. + # Should be overridden. for okey in aover: if getattr(ds, okey) == aover.get(okey): exceptions.append( "{} != {}".format(getattr(ds, okey), avars.get(okey)) ) dv = ds["temp"] - # Should be data varible attributes; + # Should be data variable attributes; # except STASH -> um_stash_source. for vkey in avars: if vkey != "STASH" and (getattr(dv, vkey) != avars.get(vkey)): @@ -1405,7 +1405,7 @@ def test_process_flags(self): process_flag = cube.attributes["ukmo__process_flags"][0] self.assertEqual(process_flag, process_desc) - # Test mutiple process flags + # Test multiple process flags multiple_bit_values = ((128, 64), (4096, 1024), (8192, 1024)) # Maps lbproc value to the process flags that should be created diff --git a/lib/iris/tests/test_plot.py b/lib/iris/tests/test_plot.py index f4f41f6aa4..55c912f423 100644 --- a/lib/iris/tests/test_plot.py +++ b/lib/iris/tests/test_plot.py @@ -193,7 +193,7 @@ def test_coord_coord_map(self): self.check_graphic() def test_cube_cube(self): - # plot two phenomena against eachother, in this case just dummy data + # plot two phenomena against each other, in this case just dummy data cube1 = self.cube1d.copy() cube2 = self.cube1d.copy() cube1.rename("some phenomenon") @@ -668,7 +668,7 @@ class CheckForWarningsMetaclass(type): """ Metaclass that adds a further test for each base class test that checks that each test raises a UserWarning. Each base - class test is then overriden to ignore warnings in order to + class test is then overridden to ignore warnings in order to check the underlying functionality. """ diff --git a/lib/iris/tests/test_pp_module.py b/lib/iris/tests/test_pp_module.py index 7eebfb07b3..ca7f1c50eb 100644 --- a/lib/iris/tests/test_pp_module.py +++ b/lib/iris/tests/test_pp_module.py @@ -155,10 +155,10 @@ def test_lbtim_access(self): def test_t1_t2_access(self): field = self.r[0] - calander = "360_day" + calendar = "360_day" self.assertEqual( field.t1.timetuple(), - cftime.datetime(1994, 12, 1, 0, 0, calendar=calander).timetuple(), + cftime.datetime(1994, 12, 1, 0, 0, calendar=calendar).timetuple(), ) def test_save_single(self): diff --git a/lib/iris/tests/unit/analysis/cartography/test_rotate_winds.py b/lib/iris/tests/unit/analysis/cartography/test_rotate_winds.py index e522e4f077..212a39bf2d 100644 --- a/lib/iris/tests/unit/analysis/cartography/test_rotate_winds.py +++ b/lib/iris/tests/unit/analysis/cartography/test_rotate_winds.py @@ -55,7 +55,7 @@ def uv_cubes_3d(ref_cube, n_realization=3): """ Return 3d u, v cubes with a grid in a rotated pole CRS taken from the provided 2d cube, by adding a realization dimension - coordinate bound to teh zeroth dimension. + coordinate bound to the zeroth dimension. """ lat = ref_cube.coord("grid_latitude") @@ -451,7 +451,7 @@ def test_rotated_to_osgb(self): assert anom[~ut.data.mask].max() == pytest.approx(0.3227935) def test_rotated_to_unrotated(self): - # Suffiently accurate so that no mask is introduced. + # Sufficiently accurate so that no mask is introduced. u, v = uv_cubes() ut, vt = rotate_winds(u, v, iris.coord_systems.GeogCS(6371229)) self.assertFalse(ma.isMaskedArray(ut.data)) diff --git a/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py b/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py index 6c3999a6f4..a91a08dcb8 100644 --- a/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py +++ b/lib/iris/tests/unit/analysis/interpolation/test_RectilinearInterpolator.py @@ -132,7 +132,7 @@ def setUp(self): def test_interpolate_bad_coord_name(self): with self.assertRaises(iris.exceptions.CoordinateNotFoundError): RectilinearInterpolator( - self.cube, ["doesnt exist"], LINEAR, EXTRAPOLATE + self.cube, ["doesn't exist"], LINEAR, EXTRAPOLATE ) def test_interpolate_data_single(self): diff --git a/lib/iris/tests/unit/analysis/maths/__init__.py b/lib/iris/tests/unit/analysis/maths/__init__.py index 558a6fccfe..c259bdeff6 100644 --- a/lib/iris/tests/unit/analysis/maths/__init__.py +++ b/lib/iris/tests/unit/analysis/maths/__init__.py @@ -155,7 +155,7 @@ def test_slice(self): # of the mesh-coords, which don't match to the originals. # FOR NOW: remove those, for a result matching the other ones. # TODO: coord equivalence may need reviewing, either for cube - # maths or for coord equivalance generally. + # maths or for coord equivalence generally. # cf. https://github.com/SciTools/iris/issues/4671 if cube.mesh and dim == cube.mesh_dim(): for co in cube.coords(mesh_coords=True): diff --git a/lib/iris/tests/unit/common/metadata/test__NamedTupleMeta.py b/lib/iris/tests/unit/common/metadata/test__NamedTupleMeta.py index 4ffeb7a67a..155c4f99b8 100644 --- a/lib/iris/tests/unit/common/metadata/test__NamedTupleMeta.py +++ b/lib/iris/tests/unit/common/metadata/test__NamedTupleMeta.py @@ -121,7 +121,7 @@ class MetadataChild(MetadataParent): expected = dict(zip(members_parent, values_parent)) self.assertEqual(metadata_parent._asdict(), expected) - # Check the dependant child class... + # Check the dependent child class... expected = ["MetadataChildNamedtuple", "MetadataParent"] self.assertEqual(self.names(MetadataChild.__bases__), expected) expected = [ diff --git a/lib/iris/tests/unit/common/metadata/test_metadata_manager_factory.py b/lib/iris/tests/unit/common/metadata/test_metadata_manager_factory.py index 5ecf0b90d5..cbb29b7161 100644 --- a/lib/iris/tests/unit/common/metadata/test_metadata_manager_factory.py +++ b/lib/iris/tests/unit/common/metadata/test_metadata_manager_factory.py @@ -167,10 +167,10 @@ def setUp(self): def test_pickle(self): for protocol in range(pickle.HIGHEST_PROTOCOL + 1): with self.temp_filename(suffix=".pkl") as fname: - with open(fname, "wb") as fo: - pickle.dump(self.metadata, fo, protocol=protocol) - with open(fname, "rb") as fi: - metadata = pickle.load(fi) + with open(fname, "wb") as fout: + pickle.dump(self.metadata, fout, protocol=protocol) + with open(fname, "rb") as fin: + metadata = pickle.load(fin) self.assertEqual(metadata, self.metadata) diff --git a/lib/iris/tests/unit/coords/test_Cell.py b/lib/iris/tests/unit/coords/test_Cell.py index 81370bd0de..d191993d51 100644 --- a/lib/iris/tests/unit/coords/test_Cell.py +++ b/lib/iris/tests/unit/coords/test_Cell.py @@ -31,7 +31,7 @@ def assert_raises_on_comparison(self, cell, other, exception_type, regexp): cell >= other def test_PartialDateTime_bounded_cell(self): - # Check that bounded comparisions to a PartialDateTime + # Check that bounded comparisons to a PartialDateTime # raise an exception. These are not supported as they # depend on the calendar. dt = PartialDateTime(month=6) diff --git a/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py b/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py index 03e2793fd9..dda0b9a5a9 100644 --- a/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py +++ b/lib/iris/tests/unit/experimental/ugrid/mesh/test_MeshCoord.py @@ -273,7 +273,7 @@ def _expected_elements_regexp( # Printed name is standard or long -- we don't have a case with neither coord_name = standard_name or long_name # Construct regexp in 'sections' - # NB each consumes upto first non-space in the next line + # NB each consumes up to first non-space in the next line regexp = f"MeshCoord : {coord_name} / [^\n]+\n *" regexp += r"mesh: \\n *" regexp += f"location: '{location}'\n *" diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py b/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py index 7ce66c3fef..078f65d572 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__cf_height_from_name.py @@ -205,7 +205,7 @@ def test_height_above_sea_level(self): self.assertEqual(com, res) def test_malformed_height_above_ground(self): - # Parse height above ground level, with additonal stuff at the string + # Parse height above ground level, with additional stuff at the string # end (agl). data = "Z = 50.00000 m agl and stuff" res = _cf_height_from_name(data) diff --git a/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__grid_mappings.py b/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__grid_mappings.py index a367e7709c..99a1b66ae4 100644 --- a/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__grid_mappings.py +++ b/lib/iris/tests/unit/fileformats/nc_load_rules/actions/test__grid_mappings.py @@ -53,7 +53,7 @@ def _make_testcase_cdl( # we can mimic a missing grid-mapping by changing the varname from that # which the data-variable refers to, with "gridmapvar_name=xxx". # Likewise, an invalid (unrecognised) grid-mapping can be mimicked by - # selecting an unkown 'grid_mapping_name' property, with + # selecting an unknown 'grid_mapping_name' property, with # "gridmapvar_mappropertyname=xxx". if mapping_type_name is None: # Default grid-mapping and coords are standard lat-lon. @@ -463,7 +463,7 @@ def test_mapping_rotated(self): # All non-latlon coordinate systems ... # These all have projection-x/y coordinates with units of metres. # They all work the same way. - # NOTE: various mapping types *require* certain addtional properties + # NOTE: various mapping types *require* certain additional properties # - without which an error will occur during translation. # - run_testcase/_make_testcase_cdl know how to provide these # diff --git a/lib/iris/tests/unit/plot/test_plot.py b/lib/iris/tests/unit/plot/test_plot.py index edbef3934a..1ed2da1b13 100644 --- a/lib/iris/tests/unit/plot/test_plot.py +++ b/lib/iris/tests/unit/plot/test_plot.py @@ -72,7 +72,7 @@ def test_plot_longitude(self): class TestTrajectoryWrap(tests.IrisTest): """ Test that a line plot of geographic coordinates wraps around the end of the - coordinates rather than plotting accross the map. + coordinates rather than plotting across the map. """ diff --git a/lib/iris/tests/unit/representation/cube_printout/test_Table.py b/lib/iris/tests/unit/representation/cube_printout/test_Table.py index 2ff6738998..e5dba52c61 100644 --- a/lib/iris/tests/unit/representation/cube_printout/test_Table.py +++ b/lib/iris/tests/unit/representation/cube_printout/test_Table.py @@ -60,7 +60,7 @@ def test_copy(self): def test_add_row(self): table = Table() self.assertEqual(table.n_columns, None) - # Add onw row. + # Add one row. table.add_row(["one", "two", "three"], aligns=["left", "left", "left"]) self.assertEqual(len(table.rows), 1) self.assertEqual(table.n_columns, 3) diff --git a/lib/iris/util.py b/lib/iris/util.py index 93e54916d6..1efc19b5aa 100644 --- a/lib/iris/util.py +++ b/lib/iris/util.py @@ -1801,7 +1801,7 @@ def demote_dim_coord_to_aux_coord(cube, name_or_coord): @functools.wraps(np.meshgrid) def _meshgrid(*xi, **kwargs): """ - @numpy v1.13, the dtype of each output nD coordinate is the same as its + @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, where the output dtype is cast up to its highest resolution, regardlessly. @@ -1953,7 +1953,7 @@ def _mask_array(array, points_to_mask, in_place=False): points_to_mask = al.ma.filled(points_to_mask, False) # Get broadcasted views of the arrays. Note that broadcast_arrays does not - # preserve masks, so we need to explicitly handle any exising mask on array. + # preserve masks, so we need to explicitly handle any existing mask on array. array_mask = al.ma.getmaskarray(array) array_data, array_mask, points_to_mask = al.broadcast_arrays( diff --git a/noxfile.py b/noxfile.py index d34155ecaf..8f9f8b72f9 100755 --- a/noxfile.py +++ b/noxfile.py @@ -87,8 +87,8 @@ def cache_venv(session: nox.sessions.Session) -> None: cache = session_cachefile(session) with open(lockfile, "rb") as fi: hexdigest = hashlib.sha256(fi.read()).hexdigest() - with open(cache, "w") as fo: - fo.write(hexdigest) + with open(cache, "w") as fout: + fout.write(hexdigest) def cache_cartopy(session: nox.sessions.Session) -> None: diff --git a/pyproject.toml b/pyproject.toml index b44187191b..a97f47d0b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -62,3 +62,7 @@ exclude_lines = [ "pragma: no cover", "if __name__ == .__main__.:" ] + +[tool.codespell] +ignore-words-list = "alpha-numeric,degreee,discontiguities,lazyness,meaned,nin" +skip = "_build,*.css,*.ipynb,*.js,*.html,*.svg,*.xml,.git,generated" diff --git a/tools/update_lockfiles.py b/tools/update_lockfiles.py index c620804fde..073f86cda6 100755 --- a/tools/update_lockfiles.py +++ b/tools/update_lockfiles.py @@ -54,7 +54,7 @@ fname = '.'.join(fname.split('.')[:-1]) # conda-lock --filename-template expects a string with a "...{platform}..." - # placeholder in it, so we have to build the .lock filname without + # placeholder in it, so we have to build the .lock filename without # using .format ofile_template = Path(args.output_dir) / (fname+'-{platform}.lock') subprocess.call([ From 8685278da97261ae458abf6373523764b084f150 Mon Sep 17 00:00:00 2001 From: Bill Little Date: Tue, 28 Mar 2023 10:04:03 +0100 Subject: [PATCH 2/3] update .git-blame-ignore-revs --- .git-blame-ignore-revs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 41c723c9ec..f6cae020f3 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -17,4 +17,4 @@ ffcfad475e0593e1e40895453cf1df154e5f6f2c 64705dbc40881233aae45f051d96049150369e53 # style: codespell (#5186) -0b4277e69aa0b8541e8ad28ac57778928737af7c \ No newline at end of file +417aa6bbd9b10d25cad7def54d47ef4d718bc38d From 3038bb2b39a0d8feee8c97a5ddb9ea9f3d543fca Mon Sep 17 00:00:00 2001 From: Bill Little Date: Tue, 18 Apr 2023 15:46:07 +0100 Subject: [PATCH 3/3] review actions --- docs/src/common_links.inc | 1 + docs/src/developers_guide/contributing_ci_tests.rst | 8 ++++++++ docs/src/whatsnew/3.5.rst | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/src/common_links.inc b/docs/src/common_links.inc index 55461369ff..10a96ff420 100644 --- a/docs/src/common_links.inc +++ b/docs/src/common_links.inc @@ -6,6 +6,7 @@ .. _flake8: https://flake8.pycqa.org/en/stable/ .. _.flake8.yml: https://github.com/SciTools/iris/blob/main/.flake8 .. _cirrus-ci: https://cirrus-ci.com/github/SciTools/iris +.. _codespell: https://github.com/codespell-project/codespell .. _conda: https://docs.conda.io/en/latest/ .. _contributor: https://github.com/SciTools/scitools.org.uk/blob/master/contributors.json .. _core developers: https://github.com/SciTools/scitools.org.uk/blob/master/contributors.json diff --git a/docs/src/developers_guide/contributing_ci_tests.rst b/docs/src/developers_guide/contributing_ci_tests.rst index 8fa3361cb7..36c1b402b6 100644 --- a/docs/src/developers_guide/contributing_ci_tests.rst +++ b/docs/src/developers_guide/contributing_ci_tests.rst @@ -117,6 +117,14 @@ pull-requests given the `Iris`_ GitHub repository `.pre-commit-config.yaml`_. See the `pre-commit.ci dashboard`_ for details of recent past and active Iris jobs. +.. note:: + + The `codespell`_ ``pre-commit`` hook checks the spelling of the whole codebase + and documentation. This hook is configured in the ``[tool.codespell]`` section + of the ``pyproject.toml`` file. + + Append to the ``ignore-words-list`` option any **valid words** that are + considered **not** a typo and should **not** be corrected by `codespell`_. .. _.pre-commit-config.yaml: https://github.com/SciTools/iris/blob/main/.pre-commit-config.yaml .. _pre-commit.ci dashboard: https://results.pre-commit.ci/repo/github/5312648 diff --git a/docs/src/whatsnew/3.5.rst b/docs/src/whatsnew/3.5.rst index c5dfb9a1b4..f90586a7ac 100644 --- a/docs/src/whatsnew/3.5.rst +++ b/docs/src/whatsnew/3.5.rst @@ -45,7 +45,7 @@ This document explains the changes made to Iris for this release :ref:`documentation page` for further information. (:pull:`5144`) -#. `@rcomer`_ enabled lazy evaluation of :obj:`~iris.analysis.RMS` calcuations +#. `@rcomer`_ enabled lazy evaluation of :obj:`~iris.analysis.RMS` calculations with weights. (:pull:`5017`) #. `@schlunma`_ allowed the usage of cubes, coordinates, cell measures, or