From 1e01a4a692cbc551b657e618900c5296c0daf619 Mon Sep 17 00:00:00 2001 From: "stephen.worsley" Date: Tue, 5 Nov 2019 17:10:17 +0000 Subject: [PATCH 1/3] simplify class definitions --- .../documenting/docstrings_attribute.py | 2 +- lib/iris/_concatenate.py | 6 +++--- lib/iris/_constraints.py | 6 +++--- lib/iris/_cube_coord_common.py | 2 +- lib/iris/_data_manager.py | 2 +- lib/iris/_merge.py | 2 +- lib/iris/analysis/__init__.py | 16 ++++++++-------- lib/iris/analysis/_area_weighted.py | 2 +- lib/iris/analysis/_interpolation.py | 2 +- lib/iris/analysis/_regrid.py | 4 ++-- lib/iris/analysis/_scipy_interpolate.py | 2 +- lib/iris/analysis/maths.py | 2 +- lib/iris/analysis/trajectory.py | 6 +++--- lib/iris/config.py | 2 +- lib/iris/cube.py | 4 ++-- lib/iris/experimental/regrid.py | 8 ++++---- lib/iris/experimental/representation.py | 4 ++-- lib/iris/fileformats/_ff.py | 6 +++--- .../_structured_array_identification.py | 2 +- lib/iris/fileformats/abf.py | 2 +- lib/iris/fileformats/cf.py | 2 +- lib/iris/fileformats/netcdf.py | 8 ++++---- lib/iris/fileformats/nimrod.py | 2 +- lib/iris/fileformats/pp.py | 4 ++-- lib/iris/fileformats/rules.py | 2 +- .../um/_fast_load_structured_fields.py | 2 +- lib/iris/io/format_picker.py | 6 +++--- lib/iris/iterate.py | 2 +- lib/iris/tests/__init__.py | 2 +- .../integration/fast_load/test_fast_load.py | 10 +++++----- .../tests/integration/plot/test_vector_plots.py | 2 +- lib/iris/tests/integration/test_pickle.py | 2 +- .../tests/integration/test_regrid_equivalence.py | 2 +- lib/iris/tests/pp.py | 2 +- lib/iris/tests/test_cdm.py | 4 ++-- lib/iris/tests/test_cell.py | 2 +- lib/iris/tests/test_constraints.py | 2 +- lib/iris/tests/test_coord_api.py | 4 ++-- lib/iris/tests/test_cube.py | 2 +- lib/iris/tests/test_cube_to_pp.py | 2 +- lib/iris/tests/test_merge.py | 2 +- lib/iris/tests/test_netcdf.py | 2 +- lib/iris/tests/test_pandas.py | 2 +- lib/iris/tests/test_plot.py | 6 +++--- lib/iris/tests/test_pp_module.py | 6 +++--- ...test_UnstructuredNearestNeighbourRegridder.py | 2 +- lib/iris/tests/unit/coords/__init__.py | 2 +- lib/iris/tests/unit/cube/test_Cube.py | 4 ++-- .../tests/unit/fileformats/abf/test_ABFField.py | 2 +- .../tests/unit/fileformats/netcdf/test_Saver.py | 2 +- .../test_build_dimension_coordinate.py | 2 +- .../test_ArrayStructure.py | 2 +- .../test_optimal_array_structure.py | 2 +- .../unit/lazy_data/test_as_concrete_data.py | 2 +- .../unit/lazy_data/test_co_realise_cubes.py | 2 +- lib/iris/tests/unit/merge/test_ProtoCube.py | 2 +- lib/iris/tests/unit/plot/__init__.py | 2 +- lib/iris/tests/unit/plot/_blockplot_common.py | 4 ++-- lib/iris/tests/unit/time/test_PartialDateTime.py | 2 +- .../unit/util/test__slice_data_with_keys.py | 6 +++--- lib/iris/time.py | 2 +- tools/translator/__init__.py | 2 +- 62 files changed, 103 insertions(+), 103 deletions(-) diff --git a/docs/iris/src/developers_guide/documenting/docstrings_attribute.py b/docs/iris/src/developers_guide/documenting/docstrings_attribute.py index 24e4eec5d1..9c8a07b310 100644 --- a/docs/iris/src/developers_guide/documenting/docstrings_attribute.py +++ b/docs/iris/src/developers_guide/documenting/docstrings_attribute.py @@ -1,4 +1,4 @@ -class ExampleClass(object): +class ExampleClass: """ Class Summary diff --git a/lib/iris/_concatenate.py b/lib/iris/_concatenate.py index 322a8a0398..bd748be37f 100644 --- a/lib/iris/_concatenate.py +++ b/lib/iris/_concatenate.py @@ -281,7 +281,7 @@ def _none_sort(item): return concatenated_cubes -class _CubeSignature(object): +class _CubeSignature: """ Template for identifying a specific type of :class:`iris.cube.Cube` based on its metadata, coordinates and cell_measures. @@ -460,7 +460,7 @@ def match(self, other, error_on_mismatch): return match -class _CoordSignature(object): +class _CoordSignature: """ Template for identifying a specific type of :class:`iris.cube.Cube` based on its coordinates. @@ -579,7 +579,7 @@ def _calculate_extents(self): self.dim_extents.append(_CoordExtent(points, bounds)) -class _ProtoCube(object): +class _ProtoCube: """ Framework for concatenating multiple source-cubes over one common dimension. diff --git a/lib/iris/_constraints.py b/lib/iris/_constraints.py index dc6bd2e5d4..356d1147ad 100644 --- a/lib/iris/_constraints.py +++ b/lib/iris/_constraints.py @@ -17,7 +17,7 @@ import iris.exceptions -class Constraint(object): +class Constraint: """ Constraints are the mechanism by which cubes can be pattern matched and filtered according to specific criteria. @@ -199,7 +199,7 @@ def _CIM_extract(self, cube): self.rhs._CIM_extract(cube)) -class _CoordConstraint(object): +class _CoordConstraint: """Represents the atomic elements which might build up a Constraint.""" def __init__(self, coord_name, coord_thing): """ @@ -280,7 +280,7 @@ def call_func(c): return cube_cim -class _ColumnIndexManager(object): +class _ColumnIndexManager: """ A class to represent column aligned slices which can be operated on using ``&``, ``|`` or ``^``. diff --git a/lib/iris/_cube_coord_common.py b/lib/iris/_cube_coord_common.py index e7a5c9721d..877d99de25 100644 --- a/lib/iris/_cube_coord_common.py +++ b/lib/iris/_cube_coord_common.py @@ -100,7 +100,7 @@ def update(self, other, **kwargs): dict.update(self, other, **kwargs) -class CFVariableMixin(object): +class CFVariableMixin: _DEFAULT_NAME = 'unknown' # the name default string diff --git a/lib/iris/_data_manager.py b/lib/iris/_data_manager.py index 73fcc3db52..3deb0bfd1d 100644 --- a/lib/iris/_data_manager.py +++ b/lib/iris/_data_manager.py @@ -16,7 +16,7 @@ from iris.util import array_equal -class DataManager(object): +class DataManager: """ Provides a well defined API for management of real or lazy data. diff --git a/lib/iris/_merge.py b/lib/iris/_merge.py index 6460cdbb10..9c6813259c 100644 --- a/lib/iris/_merge.py +++ b/lib/iris/_merge.py @@ -1054,7 +1054,7 @@ def derive_space(groups, relation_matrix, positions, function_matrix=None): return space -class ProtoCube(object): +class ProtoCube: """ Framework for merging source-cubes into one or more higher dimensional cubes. diff --git a/lib/iris/analysis/__init__.py b/lib/iris/analysis/__init__.py index b698eaa849..7c06483683 100644 --- a/lib/iris/analysis/__init__.py +++ b/lib/iris/analysis/__init__.py @@ -60,7 +60,7 @@ 'AreaWeighted', 'Nearest', 'UnstructuredNearest') -class _CoordGroup(object): +class _CoordGroup: """ Represents a list of coordinates, one for each given cube. Which can be operated on conveniently. @@ -349,7 +349,7 @@ def no_data_dim_fn(cube, coord): return result -class _Aggregator(object): +class _Aggregator: """ The :class:`_Aggregator` base class provides common aggregation functionality. @@ -1823,7 +1823,7 @@ def interp_order(length): """ -class _Groupby(object): +class _Groupby: """ Convenience class to determine group slices over one or more group-by coordinates. @@ -2149,7 +2149,7 @@ def clear_phenomenon_identity(cube): # ############################################################################### -class Linear(object): +class Linear: """ This class describes the linear interpolation and regridding scheme for interpolating or regridding over one or more orthogonal coordinates, @@ -2272,7 +2272,7 @@ def regridder(self, src_grid, target_grid): self._normalised_extrapolation_mode()) -class AreaWeighted(object): +class AreaWeighted: """ This class describes an area-weighted regridding scheme for regridding between 'ordinary' horizontal grids with separated X and Y coordinates in a @@ -2342,7 +2342,7 @@ def regridder(self, src_grid_cube, target_grid_cube): mdtol=self.mdtol) -class Nearest(object): +class Nearest: """ This class describes the nearest-neighbour interpolation and regridding scheme for interpolating or regridding over one or more orthogonal @@ -2455,7 +2455,7 @@ def regridder(self, src_grid, target_grid): self.extrapolation_mode) -class UnstructuredNearest(object): +class UnstructuredNearest: """ This is a nearest-neighbour regridding scheme for regridding data whose horizontal (X- and Y-axis) coordinates are mapped to the *same* dimensions, @@ -2546,7 +2546,7 @@ def regridder(self, src_cube, target_grid): return UnstructuredNearestNeigbourRegridder(src_cube, target_grid) -class PointInCell(object): +class PointInCell: """ This class describes the point-in-cell regridding scheme for use typically with :meth:`iris.cube.Cube.regrid()`. diff --git a/lib/iris/analysis/_area_weighted.py b/lib/iris/analysis/_area_weighted.py index 23c71bd8d8..8d3ad30c91 100644 --- a/lib/iris/analysis/_area_weighted.py +++ b/lib/iris/analysis/_area_weighted.py @@ -11,7 +11,7 @@ import iris.experimental.regrid as eregrid -class AreaWeightedRegridder(object): +class AreaWeightedRegridder: """ This class provides support for performing area-weighted regridding. diff --git a/lib/iris/analysis/_interpolation.py b/lib/iris/analysis/_interpolation.py index 49fc04899d..256317c996 100644 --- a/lib/iris/analysis/_interpolation.py +++ b/lib/iris/analysis/_interpolation.py @@ -169,7 +169,7 @@ def snapshot_grid(cube): return x.copy(), y.copy() -class RectilinearInterpolator(object): +class RectilinearInterpolator: """ This class provides support for performing nearest-neighbour or linear interpolation over one or more orthogonal dimensions. diff --git a/lib/iris/analysis/_regrid.py b/lib/iris/analysis/_regrid.py index d734083ff3..7aa816b994 100644 --- a/lib/iris/analysis/_regrid.py +++ b/lib/iris/analysis/_regrid.py @@ -329,7 +329,7 @@ def _regrid_weighted_curvilinear_to_rectilinear__perform( return cube -class CurvilinearRegridder(object): +class CurvilinearRegridder: """ This class provides support for performing point-in-cell regridding between a curvilinear source grid and a rectilinear target grid. @@ -447,7 +447,7 @@ def __call__(self, src): return result -class RectilinearRegridder(object): +class RectilinearRegridder: """ This class provides support for performing nearest-neighbour or linear regridding between source and target grids. diff --git a/lib/iris/analysis/_scipy_interpolate.py b/lib/iris/analysis/_scipy_interpolate.py index 55f955c122..cf9e2621e5 100644 --- a/lib/iris/analysis/_scipy_interpolate.py +++ b/lib/iris/analysis/_scipy_interpolate.py @@ -43,7 +43,7 @@ def _ndim_coords_from_arrays(points, ndim=None): # source: https://github.com/scipy/scipy/blob/b94a5d5ccc08dddbc88453477ff2625\ # 9aeaafb32/scipy/interpolate/interpolate.py#L1400 -class _RegularGridInterpolator(object): +class _RegularGridInterpolator: """ Interpolation on a regular grid in arbitrary dimensions diff --git a/lib/iris/analysis/maths.py b/lib/iris/analysis/maths.py index 73aff490c5..564a4b0107 100644 --- a/lib/iris/analysis/maths.py +++ b/lib/iris/analysis/maths.py @@ -841,7 +841,7 @@ def _math_op_common(cube, operation_function, new_unit, new_dtype=None, return new_cube -class IFunc(object): +class IFunc: """ :class:`IFunc` class for functions that can be applied to an iris cube. """ diff --git a/lib/iris/analysis/trajectory.py b/lib/iris/analysis/trajectory.py index 2395eecd0e..74396da351 100644 --- a/lib/iris/analysis/trajectory.py +++ b/lib/iris/analysis/trajectory.py @@ -23,7 +23,7 @@ from iris.util import _meshgrid -class _Segment(object): +class _Segment: """A single trajectory line segment: Two points, as described in the Trajectory class.""" def __init__(self, p0, p1): @@ -41,7 +41,7 @@ def __init__(self, p0, p1): self.length = math.sqrt(squares) -class Trajectory(object): +class Trajectory: """A series of given waypoints with pre-calculated sample points.""" def __init__(self, waypoints, sample_count=10): @@ -656,7 +656,7 @@ def _nearest_neighbour_indices_ndcoords(cube, sample_points, cache=None): return result -class UnstructuredNearestNeigbourRegridder(object): +class UnstructuredNearestNeigbourRegridder: """ Encapsulate the operation of :meth:`iris.analysis.trajectory.interpolate` with given source and target grids. diff --git a/lib/iris/config.py b/lib/iris/config.py index 54a7f35cd8..3de44161c1 100644 --- a/lib/iris/config.py +++ b/lib/iris/config.py @@ -108,7 +108,7 @@ def get_dir_option(section, option, default=None): # Runtime options -class NetCDF(object): +class NetCDF: """Control Iris NetCDF options.""" def __init__(self, conventions_override=None): diff --git a/lib/iris/cube.py b/lib/iris/cube.py index f97d6617db..7e4f716219 100644 --- a/lib/iris/cube.py +++ b/lib/iris/cube.py @@ -78,7 +78,7 @@ def name(self, default='unknown'): XML_NAMESPACE_URI = "urn:x-iris:cubeml-0.2" -class _CubeFilter(object): +class _CubeFilter: """ A constraint, paired with a list of cubes matching that constraint. @@ -117,7 +117,7 @@ def merged(self, unique=False): return _CubeFilter(self.constraint, self.cubes.merge(unique)) -class _CubeFilterCollection(object): +class _CubeFilterCollection: """ A list of _CubeFilter instances. diff --git a/lib/iris/experimental/regrid.py b/lib/iris/experimental/regrid.py index 78e27c1701..bdc45cc810 100644 --- a/lib/iris/experimental/regrid.py +++ b/lib/iris/experimental/regrid.py @@ -823,7 +823,7 @@ def regrid_weighted_curvilinear_to_rectilinear(src_cube, weights, grid_cube): return result -class PointInCell(object): +class PointInCell: """ This class describes the point-in-cell regridding scheme for use typically with :meth:`iris.cube.Cube.regrid()`. @@ -857,7 +857,7 @@ def __init__(self, weights=None): '"iris.analysis.PointInCell".') -class _ProjectedUnstructuredRegridder(object): +class _ProjectedUnstructuredRegridder: """ This class provides regridding that uses scipy.interpolate.griddata. @@ -1163,7 +1163,7 @@ def __call__(self, src_cube): return new_cube -class ProjectedUnstructuredLinear(object): +class ProjectedUnstructuredLinear: """ This class describes the linear regridding scheme which uses the scipy.interpolate.griddata to regrid unstructured data on to a grid. @@ -1220,7 +1220,7 @@ def regridder(self, src_cube, target_grid): 'linear', self.projection) -class ProjectedUnstructuredNearest(object): +class ProjectedUnstructuredNearest: """ This class describes the nearest regridding scheme which uses the scipy.interpolate.griddata to regrid unstructured data on to a grid. diff --git a/lib/iris/experimental/representation.py b/lib/iris/experimental/representation.py index 21ff36f33c..5a2a29d089 100644 --- a/lib/iris/experimental/representation.py +++ b/lib/iris/experimental/representation.py @@ -13,7 +13,7 @@ import re -class CubeRepresentation(object): +class CubeRepresentation: """ Produce representations of a :class:`~iris.cube.Cube`. @@ -327,7 +327,7 @@ def repr_html(self): content=content) -class CubeListRepresentation(object): +class CubeListRepresentation: _template = """