diff --git a/.ruff.toml b/.ruff.toml index 6832346226..c35507b5c3 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -34,7 +34,6 @@ lint.ignore = [ "D100", # Missing docstring in public module "D103", # Missing docstring in public function "D200", # One-line docstring should fit on one line - "D202", # No blank lines allowed after function docstring "D205", # 1 blank line required between summary line and description "D401", # First line of docstring should be in imperative mood: ... diff --git a/benchmarks/benchmarks/experimental/ugrid/regions_combine.py b/benchmarks/benchmarks/experimental/ugrid/regions_combine.py index a4df9aa8c7..b47082590b 100644 --- a/benchmarks/benchmarks/experimental/ugrid/regions_combine.py +++ b/benchmarks/benchmarks/experimental/ugrid/regions_combine.py @@ -68,7 +68,6 @@ def _make_region_cubes(self, full_mesh_cube): def setup_cache(self): """Cache all the necessary source data on disk.""" - # Control dask, to minimise memory usage + allow largest data. self.fix_dask_settings() @@ -106,7 +105,6 @@ def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True): NOTE: various test classes override + extend this. """ - # Load source cubes (full-mesh and regions) with PARSE_UGRID_ON_LOAD.context(): self.full_mesh_cube = load_cube( @@ -143,7 +141,6 @@ def fix_dask_settings(self): which is optimised for space saving so we can test largest data. """ - import dask.config as dcfg # Use single-threaded, to avoid process-switching costs and minimise memory usage. diff --git a/benchmarks/benchmarks/generate_data/stock.py b/benchmarks/benchmarks/generate_data/stock.py index 058eac01b1..a04eff6701 100644 --- a/benchmarks/benchmarks/generate_data/stock.py +++ b/benchmarks/benchmarks/generate_data/stock.py @@ -56,7 +56,6 @@ def create_file__xios_2d_face_half_levels( todo: is create_file__xios_2d_face_half_levels still appropriate now we can properly save Mesh Cubes? """ - return _create_file__xios_common( func_name="create_file__xios_2d_face_half_levels", dataset_name=dataset_name, @@ -75,7 +74,6 @@ def create_file__xios_3d_face_half_levels( todo: is create_file__xios_3d_face_half_levels still appropriate now we can properly save Mesh Cubes? """ - return _create_file__xios_common( func_name="create_file__xios_3d_face_half_levels", dataset_name=dataset_name, diff --git a/benchmarks/benchmarks/sperf/combine_regions.py b/benchmarks/benchmarks/sperf/combine_regions.py index 1012ccd932..e591a120c9 100644 --- a/benchmarks/benchmarks/sperf/combine_regions.py +++ b/benchmarks/benchmarks/sperf/combine_regions.py @@ -64,7 +64,6 @@ def _make_region_cubes(self, full_mesh_cube): def setup_cache(self): """Cache all the necessary source data on disk.""" - # Control dask, to minimise memory usage + allow largest data. self.fix_dask_settings() @@ -102,7 +101,6 @@ def setup(self, n_cubesphere, imaginary_data=True, create_result_cube=True): NOTE: various test classes override + extend this. """ - # Load source cubes (full-mesh and regions) with PARSE_UGRID_ON_LOAD.context(): self.full_mesh_cube = load_cube( @@ -142,7 +140,6 @@ def fix_dask_settings(self): which is optimised for space saving so we can test largest data. """ - import dask.config as dcfg # Use single-threaded, to avoid process-switching costs and minimise memory usage. diff --git a/benchmarks/bm_runner.py b/benchmarks/bm_runner.py index 0195d259fe..406c8eb3ae 100644 --- a/benchmarks/bm_runner.py +++ b/benchmarks/bm_runner.py @@ -68,7 +68,6 @@ def _check_requirements(package: str) -> None: def _prep_data_gen_env() -> None: """Create/access a separate, unchanging environment for generating test data.""" - python_version = "3.11" data_gen_var = "DATA_GEN_PYTHON" if data_gen_var in environ: diff --git a/docs/gallery_code/general/plot_custom_file_loading.py b/docs/gallery_code/general/plot_custom_file_loading.py index 53781ba044..81aad4a15a 100644 --- a/docs/gallery_code/general/plot_custom_file_loading.py +++ b/docs/gallery_code/general/plot_custom_file_loading.py @@ -89,11 +89,12 @@ def load_NAME_III(filename): - """Loads the Met Office's NAME III grid output files returning headers, column + """Loads 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. """ - # Loading a file gives a generator of lines which can be progressed using # the next() function. This will come in handy as we wish to progress # through the file line by line. @@ -179,7 +180,6 @@ def load_NAME_III(filename): def NAME_to_cube(filenames, callback): """Returns 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 eda8a3a53a..5536823fb4 100644 --- a/docs/gallery_code/meteorology/plot_COP_maps.py +++ b/docs/gallery_code/meteorology/plot_COP_maps.py @@ -31,10 +31,7 @@ def cop_metadata_callback(cube, field, filename): - """A function which adds an "Experiment" coordinate which comes from the - filename. - """ - + """Function which adds 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/test_gallery_examples.py b/docs/gallery_tests/test_gallery_examples.py index 93f361a62a..83f2c93217 100644 --- a/docs/gallery_tests/test_gallery_examples.py +++ b/docs/gallery_tests/test_gallery_examples.py @@ -16,7 +16,6 @@ def gallery_examples(): """Generator to yield all current gallery examples.""" - for example_file in GALLERY_DIR.glob("*/plot*.py"): yield example_file.stem @@ -30,7 +29,6 @@ def test_plot_example( iris_future_defaults, ): """Test that all figures from example code match KGO.""" - module = importlib.import_module(example) # Run example. diff --git a/lib/iris/_concatenate.py b/lib/iris/_concatenate.py index 97c2840958..b5c92fd6f9 100644 --- a/lib/iris/_concatenate.py +++ b/lib/iris/_concatenate.py @@ -759,7 +759,6 @@ def __init__(self, cube): @property def axis(self): """Return the nominated dimension of concatenation.""" - return self._axis def concatenate(self): diff --git a/lib/iris/_lazy_data.py b/lib/iris/_lazy_data.py index 81af368203..55a4222675 100644 --- a/lib/iris/_lazy_data.py +++ b/lib/iris/_lazy_data.py @@ -58,7 +58,9 @@ def _optimum_chunksize_internals( dims_fixed=None, dask_array_chunksize=dask.config.get("array.chunk-size"), ): - """Reduce or increase an initial chunk shape to get close to a chosen ideal + """Reduce or increase an initial chunk shap. + + Reduce or increase an initial chunk shape to get close to a chosen ideal size, while prioritising the splitting of the earlier (outer) dimensions and keeping intact the later (inner) ones. @@ -100,7 +102,6 @@ def _optimum_chunksize_internals( "chunks = [c[0] for c in normalise_chunks('auto', ...)]". """ - # Set the chunksize limit. if limit is None: # Fetch the default 'optimal' chunksize from the dask config. diff --git a/lib/iris/_merge.py b/lib/iris/_merge.py index 3bed7ef5ee..79427d401a 100644 --- a/lib/iris/_merge.py +++ b/lib/iris/_merge.py @@ -167,7 +167,6 @@ class _CoordPayload(namedtuple("CoordPayload", ["scalar", "vector", "factory_def def as_signature(self): """Construct and return a :class:`_CoordSignature` from the payload.""" - return _CoordSignature( self.scalar.defns, self.vector.dim_coords_and_dims, @@ -1072,11 +1071,12 @@ class ProtoCube: """ def __init__(self, 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. - """ + Create a new ProtoCube from the given cube and record the cube as a + source-cube. + """ # Default hint ordering for candidate dimension coordinates. self._hints = [ "time", @@ -1533,7 +1533,6 @@ def _nd_index(self, position): within the merged cube. """ - index = [] # Determine the index of the source-cube cell for each dimension. @@ -1634,7 +1633,6 @@ def _build_signature(self, cube): The cube signature. """ - return _CubeSignature( cube.metadata, cube.shape, diff --git a/lib/iris/_representation/cube_printout.py b/lib/iris/_representation/cube_printout.py index b1e5238eb0..fc8efb7cd6 100644 --- a/lib/iris/_representation/cube_printout.py +++ b/lib/iris/_representation/cube_printout.py @@ -268,7 +268,6 @@ def _decorated_table(table, name_padding=None): Note: 'name_padding' sets a minimum width for the name column (#0). """ - # Copy the input table + extract the header + its columns. table = table.copy() header = table.rows[0] diff --git a/lib/iris/analysis/_regrid.py b/lib/iris/analysis/_regrid.py index d4ccd6c203..0f50e47f5b 100644 --- a/lib/iris/analysis/_regrid.py +++ b/lib/iris/analysis/_regrid.py @@ -51,7 +51,6 @@ def _regrid_weighted_curvilinear_to_rectilinear__prepare(src_cube, weights, grid The 'regrid info' returned can be re-used over many cubes. """ - # Get the source cube x and y 2D auxiliary coordinates. sx, sy = src_cube.coord(axis="x"), src_cube.coord(axis="y") # Get the target grid cube x and y dimension coordinates. diff --git a/lib/iris/analysis/cartography.py b/lib/iris/analysis/cartography.py index 01c71b177a..68fad28d9c 100644 --- a/lib/iris/analysis/cartography.py +++ b/lib/iris/analysis/cartography.py @@ -1012,7 +1012,6 @@ def _transform_distance_vectors(u_dist, v_dist, ds, dx2, dy2): along the x and y directions of the target crs at each location. """ - # Scale input distance vectors --> source-coordinate differentials. u1, v1 = u_dist / ds.dx1, v_dist / ds.dy1 # Transform vectors into the target system. diff --git a/lib/iris/analysis/geometry.py b/lib/iris/analysis/geometry.py index a07ef61a76..0e44990155 100644 --- a/lib/iris/analysis/geometry.py +++ b/lib/iris/analysis/geometry.py @@ -26,7 +26,6 @@ def _extract_relevant_cube_slice(cube, geometry): If cube and geometry don't overlap, returns None. """ - # Validate the input parameters if not cube.coords(axis="x") or not cube.coords(axis="y"): raise ValueError("The cube must contain x and y axes.") @@ -177,7 +176,6 @@ def geometry_area_weights(cube, geometry, normalize=False): Default is False. """ - # extract smallest subcube containing geometry shape = cube.shape extraction_results = _extract_relevant_cube_slice(cube, geometry) diff --git a/lib/iris/analysis/maths.py b/lib/iris/analysis/maths.py index 0d865952ce..6cbdeb70ac 100644 --- a/lib/iris/analysis/maths.py +++ b/lib/iris/analysis/maths.py @@ -741,7 +741,6 @@ def apply_ufunc(ufunc, cube, other=None, new_unit=None, new_name=None, in_place= See more at :doc:`/userguide/real_and_lazy_data`. """ - if not isinstance(ufunc, np.ufunc): ufunc_name = getattr(ufunc, "__name__", "function passed to apply_ufunc") emsg = f"{ufunc_name} is not recognised, it is not an instance of numpy.ufunc" @@ -1090,7 +1089,6 @@ def ws_units_func(u_cube, v_cube): cs_cube = cs_ifunc(cube, axis=1) """ - self._data_func_name = getattr( data_func, "__name__", "data_func argument passed to IFunc" ) diff --git a/lib/iris/analysis/stats.py b/lib/iris/analysis/stats.py index 2f5b125e06..1fe958500b 100644 --- a/lib/iris/analysis/stats.py +++ b/lib/iris/analysis/stats.py @@ -71,7 +71,6 @@ def pearsonr( This operation is non-lazy. """ - # Assign larger cube to cube_1 if cube_b.ndim > cube_a.ndim: cube_1 = cube_b diff --git a/lib/iris/common/resolve.py b/lib/iris/common/resolve.py index 992e6134c4..b35397ee58 100644 --- a/lib/iris/common/resolve.py +++ b/lib/iris/common/resolve.py @@ -1295,7 +1295,6 @@ def _metadata_resolve(self): 'aux_coords' or 'dim_coords' of the participating cubes. """ - # Determine the cube dim, aux and scalar coordinate items # for each individual cube. self.lhs_cube_category = self._categorise_items(self.lhs_cube) diff --git a/lib/iris/coord_systems.py b/lib/iris/coord_systems.py index 33214ef5e0..d4d1aa66f7 100644 --- a/lib/iris/coord_systems.py +++ b/lib/iris/coord_systems.py @@ -1025,7 +1025,6 @@ def __init__( It is only valid to provide one of true_scale_lat and scale_factor_at_projection_origin """ - #: True latitude of planar origin in degrees. self.central_lat = float(central_lat) @@ -1140,7 +1139,6 @@ def __init__( """ - super().__init__( central_lat=central_lat, central_lon=central_lon, @@ -1200,7 +1198,6 @@ def __init__( secant_latitudes=(33, 45) """ - #: True latitude of planar origin in degrees. self.central_lat = _arg_default(central_lat, 39.0) diff --git a/lib/iris/coords.py b/lib/iris/coords.py index a1595530f9..14371ac3ee 100644 --- a/lib/iris/coords.py +++ b/lib/iris/coords.py @@ -1335,7 +1335,6 @@ def __common_cmp__(self, other, operator_method): Non-Cell vs Cell comparison is used to define Constraint matching. """ - if (isinstance(other, list) and len(other) == 1) or ( isinstance(other, np.ndarray) and other.shape == (1,) ): @@ -2019,7 +2018,6 @@ def contiguous_bounds(self): def is_monotonic(self): """Return True if, and only if, this Coord is monotonic.""" - if self.ndim != 1: raise iris.exceptions.CoordinateMultiDimError(self) @@ -2120,7 +2118,6 @@ def collapsed(self, dims_to_collapse=None): Replaces the points & bounds with a simple bounded region. """ - # Ensure dims_to_collapse is a tuple to be able to pass # through to numpy if isinstance(dims_to_collapse, (int, np.integer)): diff --git a/lib/iris/cube.py b/lib/iris/cube.py index d60dd342b4..04cee11969 100644 --- a/lib/iris/cube.py +++ b/lib/iris/cube.py @@ -242,7 +242,6 @@ def insert(self, index, cube): def xml(self, checksum=False, order=True, byteorder=True): """Return a string of the XML that this list of cubes represents.""" - doc = Document() cubes_xml_element = doc.createElement("cubes") cubes_xml_element.setAttribute("xmlns", XML_NAMESPACE_URI) @@ -1152,7 +1151,6 @@ def _sort_xml_attrs(cls, doc): def _walk_nodes(node): """Note: _walk_nodes is called recursively on child elements.""" - # we don't want to copy the children here, so take a shallow copy new_node = node.cloneNode(deep=False) @@ -1665,7 +1663,6 @@ def add_ancillary_variable(self, ancillary_variable, data_dims=None): Raises a ValueError if an ancillary variable with identical metadata already exists on the cube. """ - if self.ancillary_variables(ancillary_variable): raise iris.exceptions.CannotAddError( "Duplicate ancillary variables not permitted" @@ -4548,7 +4545,6 @@ def rolling_window(self, coord, aggregator, window, **kwargs): possible windows of size 3 from the original cube. """ # noqa: D214, D406, D407, D410, D411 - # Update weights kwargs (if necessary) to handle different types of # weights weights_info = None diff --git a/lib/iris/experimental/ugrid/mesh.py b/lib/iris/experimental/ugrid/mesh.py index dfd0d74552..79e67593d2 100644 --- a/lib/iris/experimental/ugrid/mesh.py +++ b/lib/iris/experimental/ugrid/mesh.py @@ -1440,7 +1440,6 @@ def connectivity( :class:`Mesh` that matched the given criteria. """ - result = self._connectivity_manager.filter( item=item, standard_name=standard_name, diff --git a/lib/iris/fileformats/_ff.py b/lib/iris/fileformats/_ff.py index 336c4aa699..5e65c92996 100644 --- a/lib/iris/fileformats/_ff.py +++ b/lib/iris/fileformats/_ff.py @@ -316,7 +316,6 @@ def __init__(self, filename, word_depth=DEFAULT_FF_WORD_DEPTH): FFHeader object. """ - #: File name of the FieldsFile. self.ff_filename = filename self._word_depth = word_depth @@ -411,7 +410,6 @@ def shape(self, name): Dimension tuple. """ - if name in _FF_HEADER_POINTERS: value = getattr(self, name)[1:] else: @@ -465,7 +463,6 @@ def __init__(self, filename, read_data=False, word_depth=DEFAULT_FF_WORD_DEPTH): ... print(field) """ - self._ff_header = FFHeader(filename, word_depth=word_depth) self._word_depth = word_depth self._filename = filename @@ -823,7 +820,6 @@ def _parse_binary_stream(file_like, dtype=np.float64, count=-1): object and generate as many values as possible. """ - # There are a wide range of types supported, we just need to know the byte # size of the object, so we just make sure we've go an instance of a # np.dtype diff --git a/lib/iris/fileformats/_nc_load_rules/actions.py b/lib/iris/fileformats/_nc_load_rules/actions.py index 92d46c6693..1532340d00 100644 --- a/lib/iris/fileformats/_nc_load_rules/actions.py +++ b/lib/iris/fileformats/_nc_load_rules/actions.py @@ -544,7 +544,6 @@ def run_actions(engine): The specific cube being translated is "engine.cube". """ - # default (all cubes) action, always runs action_default(engine) # This should run the default rules. diff --git a/lib/iris/fileformats/_nc_load_rules/helpers.py b/lib/iris/fileformats/_nc_load_rules/helpers.py index 31cc4aaa6c..6a135a211c 100644 --- a/lib/iris/fileformats/_nc_load_rules/helpers.py +++ b/lib/iris/fileformats/_nc_load_rules/helpers.py @@ -275,7 +275,6 @@ def _split_cell_methods(nc_cell_methods: str) -> List[re.Match]: Validation of anything other than being laid out in the expected format is left to the calling function. """ - # Find name candidates name_start_inds = [] for m in _CM_PARSE_NAME.finditer(nc_cell_methods): @@ -346,7 +345,6 @@ def parse_cell_methods(nc_cell_methods): results are not affected. """ - cell_methods = [] if nc_cell_methods is not None: for m in _split_cell_methods(nc_cell_methods): @@ -952,7 +950,6 @@ def get_attr_units(cf_var, attributes): ################################################################################ def get_names(cf_coord_var, coord_name, attributes): """Determine the standard_name, long_name and var_name attributes.""" - standard_name = getattr(cf_coord_var, CF_ATTR_STD_NAME, None) long_name = getattr(cf_coord_var, CF_ATTR_LONG_NAME, None) cf_name = str(cf_coord_var.cf_name) @@ -1058,7 +1055,6 @@ def build_dimension_coordinate( engine, cf_coord_var, coord_name=None, coord_system=None ): """Create a dimension coordinate (DimCoord) and add it to the cube.""" - cf_var = engine.cf_var cube = engine.cube attributes = {} @@ -1190,7 +1186,6 @@ def build_auxiliary_coordinate( engine, cf_coord_var, coord_name=None, coord_system=None ): """Create an auxiliary coordinate (AuxCoord) and add it to the cube.""" - cf_var = engine.cf_var cube = engine.cube attributes = {} @@ -1499,7 +1494,6 @@ def is_time_period(engine, cf_name): ################################################################################ def is_grid_mapping(engine, cf_name, grid_mapping): """Determine whether the CF grid mapping variable is of the appropriate type.""" - is_valid = False cf_var = engine.cf_var.cf_group[cf_name] attr_mapping_name = getattr(cf_var, CF_ATTR_GRID_MAPPING_NAME, None) @@ -1513,7 +1507,6 @@ def is_grid_mapping(engine, cf_name, grid_mapping): ################################################################################ def _is_rotated(engine, cf_name, cf_attr_value): """Determine whether the CF coordinate variable is rotated.""" - is_valid = False cf_var = engine.cf_var.cf_group[cf_name] attr_std_name = getattr(cf_var, CF_ATTR_STD_NAME, None) @@ -1547,7 +1540,6 @@ def has_supported_mercator_parameters(engine, cf_name): Determine whether the CF grid mapping variable has the supported values for the parameters of the Mercator projection. """ - is_valid = True cf_grid_var = engine.cf_var.cf_group[cf_name] @@ -1572,7 +1564,6 @@ def has_supported_polar_stereographic_parameters(engine, cf_name): """Determine whether the CF grid mapping variable has the supported values for the parameters of the Polar Stereographic projection. """ - is_valid = True cf_grid_var = engine.cf_var.cf_group[cf_name] diff --git a/lib/iris/fileformats/abf.py b/lib/iris/fileformats/abf.py index 3f7a6b18e0..13b0d8aa8d 100644 --- a/lib/iris/fileformats/abf.py +++ b/lib/iris/fileformats/abf.py @@ -116,7 +116,6 @@ def _read(self): def to_cube(self): """Return a new :class:`~iris.cube.Cube` from this ABFField.""" - cube = iris.cube.Cube(self.data) # Name. diff --git a/lib/iris/fileformats/cf.py b/lib/iris/fileformats/cf.py index 905e64ebc1..ec0d66f8c2 100644 --- a/lib/iris/fileformats/cf.py +++ b/lib/iris/fileformats/cf.py @@ -695,7 +695,6 @@ def cf_label_data(self, cf_data_var): str labels """ - if not isinstance(cf_data_var, CFDataVariable): raise TypeError( "cf_data_var argument should be of type CFDataVariable. Got %r." @@ -763,7 +762,6 @@ def cf_label_dimensions(self, cf_data_var): Tuple of label data dimension names. """ - if not isinstance(cf_data_var, CFDataVariable): raise TypeError( "cf_data_var argument should be of type CFDataVariable. Got %r." @@ -1086,7 +1084,6 @@ def __repr__(self): def _translate(self): """Classify the netCDF variables into CF-netCDF variables.""" - netcdf_variable_names = list(self._dataset.variables.keys()) # Identify all CF coordinate variables first. This must be done diff --git a/lib/iris/fileformats/name_loaders.py b/lib/iris/fileformats/name_loaders.py index 3f4b2d13c6..545b242994 100644 --- a/lib/iris/fileformats/name_loaders.py +++ b/lib/iris/fileformats/name_loaders.py @@ -130,7 +130,6 @@ def _build_lat_lon_for_NAME_field( """Return regular latitude and longitude coordinates extracted from the provided header dictionary. """ - if x_or_y == "X": start = header["X grid origin"] step = header["X grid resolution"] @@ -234,7 +233,6 @@ def _parse_units(units): An instance of :class:`cf_units.Unit`. """ - unit_mapper = { "Risks/m3": "1", # Used for Bluetongue "TCID50s/m3": "1", # Used for Foot and Mouth @@ -284,7 +282,6 @@ def _cf_height_from_name(z_coord, lower_bound=None, upper_bound=None): interpretation of the supplied field heading. """ - # NAMEII - integer/float support. # Match against height agl, asl and Pa. pattern = re.compile( @@ -955,7 +952,6 @@ def load_NAMEIII_version2(filename): A generator :class:`iris.cube.Cube` instances. """ - # loading a file gives a generator of lines which can be progressed # using the next() method. This will come in handy as we wish to # progress through the file line by line. diff --git a/lib/iris/fileformats/nimrod.py b/lib/iris/fileformats/nimrod.py index 8cf109eed5..778c7b3251 100644 --- a/lib/iris/fileformats/nimrod.py +++ b/lib/iris/fileformats/nimrod.py @@ -204,7 +204,6 @@ def _read_header_subset(self, infile, names, dtype): def _read_header(self, infile): """Load the 512 byte header (surrounded by 4-byte length).""" - leading_length = struct.unpack(">L", infile.read(4))[0] if leading_length != 512: raise TranslationError("Expected header leading_length of 512") diff --git a/lib/iris/plot.py b/lib/iris/plot.py index 23d11bbdd4..d8e9426035 100644 --- a/lib/iris/plot.py +++ b/lib/iris/plot.py @@ -234,7 +234,6 @@ def _broadcast_2d(u, v): def _string_coord_axis_tick_labels(string_axes, axes=None): """Apply tick labels for string coordinates.""" - ax = axes if axes else plt.gca() for axis, ticks in string_axes.items(): # Define a tick formatter. This will assign a label to all ticks @@ -860,7 +859,6 @@ def _replace_axes_with_cartopy_axes(cartopy_proj): instance of :class:`cartopy.mpl.geoaxes.GeoAxes` then no action is taken. """ - ax = plt.gca() if not isinstance(ax, cartopy.mpl.geoaxes.GeoAxes): fig = ax.get_figure() @@ -1229,7 +1227,6 @@ def orography_at_bounds(cube, facecolor="#888888", coords=None, axes=None): This function does not maintain laziness when called; it realises data. See more at :doc:`/userguide/real_and_lazy_data`. """ - # XXX Needs contiguous orography corners to work. raise NotImplementedError( "This operation is temporarily not provided " @@ -1268,7 +1265,6 @@ def orography_at_points(cube, facecolor="#888888", coords=None, axes=None): This function does not maintain laziness when called; it realises data. See more at :doc:`/userguide/real_and_lazy_data`. """ - style_args = {"facecolor": facecolor} def vert_plot(u_coord, orography, style_args): @@ -1843,7 +1839,6 @@ def citation(text, figure=None, axes=None): provided. """ - if text is not None and len(text): if figure is None and not axes: figure = plt.gcf() diff --git a/lib/iris/quickplot.py b/lib/iris/quickplot.py index fcb0b0d5b7..1fa2edd630 100644 --- a/lib/iris/quickplot.py +++ b/lib/iris/quickplot.py @@ -50,7 +50,6 @@ 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.""" - if axes is None: axes = plt.gca() diff --git a/lib/iris/tests/stock/netcdf.py b/lib/iris/tests/stock/netcdf.py index c1dd5cb631..5721433103 100644 --- a/lib/iris/tests/stock/netcdf.py +++ b/lib/iris/tests/stock/netcdf.py @@ -89,7 +89,6 @@ def _add_standard_data(nc_path, unlimited_dim_size=0): dimension size, 'dimension coordinates' and a possible unlimited dimension. """ - ds = _thread_safe_nc.DatasetWrapper(nc_path, "r+") unlimited_dim_names = [ diff --git a/lib/iris/tests/unit/analysis/test_MAX_RUN.py b/lib/iris/tests/unit/analysis/test_MAX_RUN.py index d7cc714609..9e314aad7e 100644 --- a/lib/iris/tests/unit/analysis/test_MAX_RUN.py +++ b/lib/iris/tests/unit/analysis/test_MAX_RUN.py @@ -26,7 +26,6 @@ def setUp(self): Uses 1 and 3 rather than 1 and 0 to check that lambda is being applied. """ - self.data_1ds = [ (np.array([3, 1, 1, 3, 3, 3]), 2), # One run (np.array([3, 1, 1, 3, 1, 3]), 2), # Two runs @@ -60,7 +59,6 @@ def setUp(self): Uses 1 and 3 rather than 1 and 0 to check that lambda is being applied. """ - self.data_1ds = [ ( ma.masked_array( diff --git a/lib/iris/tests/unit/coord_categorisation/test_coord_categorisation.py b/lib/iris/tests/unit/coord_categorisation/test_coord_categorisation.py index 2fc3db9b05..7730831e52 100644 --- a/lib/iris/tests/unit/coord_categorisation/test_coord_categorisation.py +++ b/lib/iris/tests/unit/coord_categorisation/test_coord_categorisation.py @@ -162,7 +162,6 @@ def test_add_season_nonstandard(cube, time_coord): ) def test_add_season_year(cube, time_coord, backwards, nonstandard): """Specific test to account for the extra use_year_at_season_start argument.""" - kwargs = dict( cube=cube, coord=time_coord, diff --git a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py index bc0daf14bc..48f9910099 100644 --- a/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py +++ b/lib/iris/tests/unit/experimental/ugrid/mesh/test_Mesh.py @@ -1181,7 +1181,6 @@ def test_face_dimension_set(self): def test_remove_connectivities(self): """Do what 1D test could not - test removal of optional connectivity.""" - # Add an optional connectivity. self.mesh.add_connectivities(self.FACE_FACE) # Attempt to remove a non-existent connectivity. diff --git a/lib/iris/tests/unit/fileformats/netcdf/saver/test_Saver__ugrid.py b/lib/iris/tests/unit/fileformats/netcdf/saver/test_Saver__ugrid.py index 290cf0cfaf..241ff5a5cc 100644 --- a/lib/iris/tests/unit/fileformats/netcdf/saver/test_Saver__ugrid.py +++ b/lib/iris/tests/unit/fileformats/netcdf/saver/test_Saver__ugrid.py @@ -654,7 +654,6 @@ def test_alternate_cube_dim_order(self): def test_mixed_aux_coords(self): """``coordinates`` attribute should include mesh location coords and 'normal' coords.""" - cube = make_cube() mesh_dim = cube.mesh_dim() mesh_len = cube.shape[mesh_dim] diff --git a/lib/iris/tests/unit/plot/test_plot.py b/lib/iris/tests/unit/plot/test_plot.py index c4f65fb1a6..6adf1c4cf5 100644 --- a/lib/iris/tests/unit/plot/test_plot.py +++ b/lib/iris/tests/unit/plot/test_plot.py @@ -103,7 +103,6 @@ def check_paths(self, expected_path, expected_path_crs, lines, axes): plotted on the given geoaxes. """ - self.assertEqual( 1, len(lines), "Expected a single line, got {}".format(len(lines)) ) diff --git a/lib/iris/util.py b/lib/iris/util.py index 686238fa61..d030924a52 100644 --- a/lib/iris/util.py +++ b/lib/iris/util.py @@ -193,7 +193,6 @@ def describe_diff(cube_a, cube_b, output_file=None): :meth:`iris.cube.Cube.is_compatible()` """ - if output_file is None: output_file = sys.stdout @@ -253,7 +252,6 @@ def guess_coord_axis(coord): property ``ignore_axis`` to ``False``. """ - axis = None if hasattr(coord, "ignore_axis") and coord.ignore_axis is True: @@ -1030,7 +1028,6 @@ def clip_string(the_str, clip_length=70, rider="..."): This function does maintain laziness when called; it doesn't realise data. See more at :doc:`/userguide/real_and_lazy_data`. """ - if clip_length >= len(the_str) or clip_length <= 0: return the_str else: @@ -1064,7 +1061,6 @@ def format_array(arr): See more at :doc:`/userguide/real_and_lazy_data`. """ - max_line_len = 50 result = np.array2string( @@ -1232,7 +1228,6 @@ def squeeze(cube): See more at :doc:`/userguide/real_and_lazy_data`. """ - slices = [0 if cube.shape[dim] == 1 else slice(None) for dim in range(cube.ndim)] squeezed = cube[tuple(slices)]