diff --git a/lib/iris/tests/_shared_utils.py b/lib/iris/tests/_shared_utils.py index 3f1aba3398..4a0d275cdd 100644 --- a/lib/iris/tests/_shared_utils.py +++ b/lib/iris/tests/_shared_utils.py @@ -19,7 +19,7 @@ import re import shutil import subprocess -from typing import AnyStr +from typing import Optional import warnings import xml.dom.minidom import zlib @@ -380,7 +380,7 @@ def sort_key(line): dimension_lines = slice(lines.index("dimensions:") + 1, lines.index("variables:")) lines[dimension_lines] = sorted(lines[dimension_lines], key=sort_key) - cdl = "\n".join(lines) + "\n" + cdl = "\n".join(lines) + "\n" # type: ignore[assignment] _check_same(cdl, reference_path, type_comparison_name="CDL") @@ -543,9 +543,7 @@ def assert_repr(request: pytest.FixtureRequest, obj, reference_filename): def _check_same(item, reference_path, type_comparison_name="CML"): if _check_reference_file(reference_path): with open(reference_path, "rb") as reference_fh: - reference = "".join( - part.decode("utf-8") for part in reference_fh.readlines() - ) + reference = "".join(part.decode("utf-8") for part in reference_fh) _assert_str_same(reference, item, reference_path, type_comparison_name) else: _ensure_folder(reference_path) @@ -966,7 +964,7 @@ def wrapped(*args, **kwargs): return wrapped -def env_bin_path(exe_name: AnyStr = None): +def env_bin_path(exe_name: Optional[str] = None): """Return a Path object for (an executable in) the environment bin directory. Parameters diff --git a/lib/iris/tests/conftest.py b/lib/iris/tests/conftest.py index c75e1ae71c..2a3341d8c0 100644 --- a/lib/iris/tests/conftest.py +++ b/lib/iris/tests/conftest.py @@ -9,6 +9,7 @@ """ from collections import defaultdict +from typing import Callable import pytest @@ -27,7 +28,7 @@ def test_call_counter(): @pytest.fixture -def _unique_id(request: pytest.FixtureRequest, test_call_counter) -> callable: +def _unique_id(request: pytest.FixtureRequest, test_call_counter) -> Callable: """Provide a function returning a unique ID of calling test and call number. Example: ``iris.tests.unit.test_cube.TestCube.test_data.my_param.0`` diff --git a/lib/iris/tests/graphics/__init__.py b/lib/iris/tests/graphics/__init__.py index 7855f6a037..7fb2074ca0 100644 --- a/lib/iris/tests/graphics/__init__.py +++ b/lib/iris/tests/graphics/__init__.py @@ -18,7 +18,7 @@ from pathlib import Path import sys import threading -from typing import Callable, Dict, Union +from typing import Callable, Dict, Iterator, Union import filelock import pytest @@ -285,7 +285,7 @@ def skip_plot(fn: Callable) -> Callable: @pytest.fixture -def _check_graphic_caller(_unique_id) -> callable: +def _check_graphic_caller(_unique_id) -> Iterator[Callable]: """Provide a function calling :func:`check_graphic` with safe configuration. Ensures a safe Matplotlib setup (and tears down afterwards), and generates diff --git a/lib/iris/tests/integration/plot/test_animate.py b/lib/iris/tests/integration/plot/test_animate.py index 9008a53b84..59f269e9f7 100644 --- a/lib/iris/tests/integration/plot/test_animate.py +++ b/lib/iris/tests/integration/plot/test_animate.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Integration tests for :func:`iris.plot.animate`.""" + import numpy as np import pytest diff --git a/lib/iris/tests/integration/plot/test_colorbar.py b/lib/iris/tests/integration/plot/test_colorbar.py index a1d498f200..e02e51db78 100644 --- a/lib/iris/tests/integration/plot/test_colorbar.py +++ b/lib/iris/tests/integration/plot/test_colorbar.py @@ -6,6 +6,7 @@ :func:`matplotlib.pyplot.colorbar`. """ + import numpy as np import pytest diff --git a/lib/iris/tests/integration/plot/test_netcdftime.py b/lib/iris/tests/integration/plot/test_netcdftime.py index 9c1d4cf5e6..408c04cb3b 100644 --- a/lib/iris/tests/integration/plot/test_netcdftime.py +++ b/lib/iris/tests/integration/plot/test_netcdftime.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test plot of time coord with non-standard calendar.""" + from cf_units import Unit import cftime import numpy as np diff --git a/lib/iris/tests/integration/plot/test_plot_2d_coords.py b/lib/iris/tests/integration/plot/test_plot_2d_coords.py index 1b3c850bbe..f4e23fad7b 100644 --- a/lib/iris/tests/integration/plot/test_plot_2d_coords.py +++ b/lib/iris/tests/integration/plot/test_plot_2d_coords.py @@ -4,7 +4,6 @@ # See LICENSE in the root of the repository for full licensing details. """Test plots with two dimensional coordinates.""" - import cartopy.crs as ccrs import matplotlib.pyplot as plt import numpy as np diff --git a/lib/iris/tests/unit/common/metadata/test_CubeMetadata.py b/lib/iris/tests/unit/common/metadata/test_CubeMetadata.py index c678a285d9..0b4725da42 100644 --- a/lib/iris/tests/unit/common/metadata/test_CubeMetadata.py +++ b/lib/iris/tests/unit/common/metadata/test_CubeMetadata.py @@ -6,11 +6,8 @@ # Import iris.tests first so that some things can be initialised before # importing anything else. -from typing import Any, ClassVar - -from copy import deepcopy - from copy import deepcopy +from typing import Any, ClassVar import pytest diff --git a/lib/iris/tests/unit/concatenate/test_concatenate.py b/lib/iris/tests/unit/concatenate/test_concatenate.py index 9521c3af48..448ffb5e7b 100644 --- a/lib/iris/tests/unit/concatenate/test_concatenate.py +++ b/lib/iris/tests/unit/concatenate/test_concatenate.py @@ -51,7 +51,6 @@ def test_concat_1d_with_same_time_units(self, simple_1d_time_cubes): class _MessagesMixin: - @pytest.fixture() def placeholder(self): # Shim to allow sample_cubes to have identical signature in both parent and subclasses diff --git a/lib/iris/tests/unit/fileformats/abf/test_ABFField.py b/lib/iris/tests/unit/fileformats/abf/test_ABFField.py index 2c3cb703fe..2f06c914ca 100644 --- a/lib/iris/tests/unit/fileformats/abf/test_ABFField.py +++ b/lib/iris/tests/unit/fileformats/abf/test_ABFField.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.fileformats.abf.ABFField` class.""" + from iris.fileformats.abf import ABFField diff --git a/lib/iris/tests/unit/fileformats/cf/test_CFGroup.py b/lib/iris/tests/unit/fileformats/cf/test_CFGroup.py index d1efc5b0ba..3724a2f628 100644 --- a/lib/iris/tests/unit/fileformats/cf/test_CFGroup.py +++ b/lib/iris/tests/unit/fileformats/cf/test_CFGroup.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the :class:`iris.fileformats.cf.CFGroup` class.""" + from unittest.mock import MagicMock import pytest diff --git a/lib/iris/tests/unit/fileformats/cf/test_CFReader.py b/lib/iris/tests/unit/fileformats/cf/test_CFReader.py index 8a9aad48a0..42019bb9f8 100644 --- a/lib/iris/tests/unit/fileformats/cf/test_CFReader.py +++ b/lib/iris/tests/unit/fileformats/cf/test_CFReader.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.fileformats.cf.CFReader` class.""" + from unittest import mock import numpy as np @@ -366,8 +367,8 @@ def _setup_class(self, mocker): file_format="NetCDF4", variables=self.variables, ncattrs=ncattrs ) - # @pytest.fixture(autouse=True) - # def _setup(self, mocker): + # @pytest.fixture(autouse=True) + # def _setup(self, mocker): # Restrict the CFReader functionality to only performing # translations and building first level cf-groups for variables. mocker.patch("iris.fileformats.cf.CFReader._reset") @@ -406,4 +407,3 @@ def test_ugrid_coords(self): def test_is_cf_ugrid_group(self): assert isinstance(self.cf_group, CFGroup) - diff --git a/lib/iris/tests/unit/fileformats/dot/test__dot_path.py b/lib/iris/tests/unit/fileformats/dot/test__dot_path.py index c72207dfcb..679f74c51d 100644 --- a/lib/iris/tests/unit/fileformats/dot/test__dot_path.py +++ b/lib/iris/tests/unit/fileformats/dot/test__dot_path.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.dot._dot_path`.""" + import os.path import subprocess diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py b/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py index 6b7d576cf5..b6cf87f5a6 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__build_cell_methods.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.name_loaders._build_cell_methods`.""" + import pytest import iris.coords diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py b/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py index ce8fbdff06..39067fdf2f 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__build_lat_lon_for_NAME_timeseries.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.analysis.name_loaders._build_lat_lon_for_NAME_timeseries`.""" + from iris.fileformats.name_loaders import NAMECoord, _build_lat_lon_for_NAME_timeseries from iris.tests._shared_utils import assert_array_equal diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py b/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py index f94b4b4857..9b40aa47ff 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__calc_integration_period.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.name_loaders.__calc_integration_period`.""" + import datetime from iris.fileformats.name_loaders import _calc_integration_period 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 f2fd376614..cd32f53843 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 @@ -6,6 +6,7 @@ function. """ + import numpy as np from iris.coords import AuxCoord diff --git a/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py b/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py index df0c1ce08d..7238b68d31 100644 --- a/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py +++ b/lib/iris/tests/unit/fileformats/name_loaders/test__generate_cubes.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.analysis.name_loaders._generate_cubes`.""" + from datetime import datetime, timedelta from unittest import mock diff --git a/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_units.py b/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_units.py index aeee7ab3ba..5c6c59c3a1 100644 --- a/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_units.py +++ b/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_units.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.fileformats.nimrod_load_rules.units` function.""" + import numpy as np import pytest diff --git a/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_vertical_coord.py b/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_vertical_coord.py index 9daeb18c05..2a3d06e56a 100644 --- a/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_vertical_coord.py +++ b/lib/iris/tests/unit/fileformats/nimrod_load_rules/test_vertical_coord.py @@ -6,6 +6,7 @@ function. """ + import pytest from iris.fileformats.nimrod import NimrodField diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__all_other_rules.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__all_other_rules.py index 2220929395..05f9c6f82b 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__all_other_rules.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__all_other_rules.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.fileformats.pp_load_rules._all_other_rules` function.""" + from unittest import mock from cf_units import CALENDAR_360_DAY, Unit diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__collapse_degenerate_points_and_bounds.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__collapse_degenerate_points_and_bounds.py index e666ae2d9a..523aef0e64 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__collapse_degenerate_points_and_bounds.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__collapse_degenerate_points_and_bounds.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._collapse_degenerate_points_and_bounds`. """ + import numpy as np from iris.fileformats.pp_load_rules import _collapse_degenerate_points_and_bounds diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_pseudo_level_coords.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_pseudo_level_coords.py index 978097e8ee..ad15d7a395 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_pseudo_level_coords.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_pseudo_level_coords.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._convert_pseudo_level_coords`. """ + from iris.coords import DimCoord from iris.fileformats.pp_load_rules import _convert_scalar_pseudo_level_coords diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_realization_coords.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_realization_coords.py index c00c4c1b5d..5d01eb5976 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_realization_coords.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_scalar_realization_coords.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._convert_scalar_realization_coords`. """ + from iris.coords import DimCoord from iris.fileformats.pp_load_rules import _convert_scalar_realization_coords diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_time_coords.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_time_coords.py index a7656a8ec6..690f869a34 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_time_coords.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_time_coords.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._convert_time_coords`. """ + from cf_units import CALENDAR_360_DAY, CALENDAR_STANDARD, Unit from cftime import datetime as nc_datetime import numpy as np diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_vertical_coords.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_vertical_coords.py index 0ba86a68b6..7f6270e9f3 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_vertical_coords.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__convert_vertical_coords.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._convert_vertical_coords`. """ + import numpy as np from iris.aux_factory import HybridHeightFactory, HybridPressureFactory diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__dim_or_aux.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__dim_or_aux.py index c532d4243a..496b82c6c8 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__dim_or_aux.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__dim_or_aux.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.pp_load_rules._dim_or_aux`.""" + import pytest from iris.coords import AuxCoord, DimCoord diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__epoch_date_hours.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__epoch_date_hours.py index 6db53bfcc8..826156dade 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__epoch_date_hours.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__epoch_date_hours.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._epoch_date_hours`. """ + import cf_units from cf_units import Unit from cftime import datetime as nc_datetime diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__model_level_number.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__model_level_number.py index cff13616d6..c721e82754 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__model_level_number.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__model_level_number.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.pp_load_rules._model_level_number`.""" + from iris.fileformats.pp_load_rules import _model_level_number diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__reduced_points_and_bounds.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__reduced_points_and_bounds.py index 9e94273d63..72e59963e7 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__reduced_points_and_bounds.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__reduced_points_and_bounds.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._reduce_points_and_bounds`. """ + import numpy as np from iris.fileformats.pp_load_rules import _reduce_points_and_bounds diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test__reshape_vector_args.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test__reshape_vector_args.py index 38cf0b9cb9..0bb8d55aae 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test__reshape_vector_args.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test__reshape_vector_args.py @@ -6,6 +6,7 @@ :func:`iris.fileformats.pp_load_rules._reshape_vector_args`. """ + import numpy as np import pytest diff --git a/lib/iris/tests/unit/fileformats/pp_load_rules/test_convert.py b/lib/iris/tests/unit/fileformats/pp_load_rules/test_convert.py index 08a6398f2d..d9e1e74e00 100644 --- a/lib/iris/tests/unit/fileformats/pp_load_rules/test_convert.py +++ b/lib/iris/tests/unit/fileformats/pp_load_rules/test_convert.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.pp_load_rules.convert`.""" + from types import MethodType from unittest import mock diff --git a/lib/iris/tests/unit/fileformats/rules/test_Loader.py b/lib/iris/tests/unit/fileformats/rules/test_Loader.py index a11d2f96b6..08e0764a45 100644 --- a/lib/iris/tests/unit/fileformats/rules/test_Loader.py +++ b/lib/iris/tests/unit/fileformats/rules/test_Loader.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :class:`iris.fileformats.rules.Loader`.""" + from iris.fileformats.rules import Loader from iris.tests._shared_utils import assert_no_warnings_regexp diff --git a/lib/iris/tests/unit/fileformats/rules/test__make_cube.py b/lib/iris/tests/unit/fileformats/rules/test__make_cube.py index c7cd01193a..c14a5df705 100644 --- a/lib/iris/tests/unit/fileformats/rules/test__make_cube.py +++ b/lib/iris/tests/unit/fileformats/rules/test__make_cube.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for :func:`iris.fileformats.rules._make_cube`.""" + from unittest import mock import numpy as np diff --git a/lib/iris/tests/unit/fileformats/rules/test_rules.py b/lib/iris/tests/unit/fileformats/rules/test_rules.py index 83dc202d71..df3c769a70 100644 --- a/lib/iris/tests/unit/fileformats/rules/test_rules.py +++ b/lib/iris/tests/unit/fileformats/rules/test_rules.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test iris.fileformats.rules.py - metadata translation rules.""" + import types from unittest import mock diff --git a/lib/iris/tests/unit/fileformats/structured_array_identification/test_ArrayStructure.py b/lib/iris/tests/unit/fileformats/structured_array_identification/test_ArrayStructure.py index d8530db5e1..bf23b39a5c 100644 --- a/lib/iris/tests/unit/fileformats/structured_array_identification/test_ArrayStructure.py +++ b/lib/iris/tests/unit/fileformats/structured_array_identification/test_ArrayStructure.py @@ -6,6 +6,7 @@ :mod:`iris.fileformats._structured_array_identification.ArrayStructure` class. """ + import numpy as np import pytest diff --git a/lib/iris/tests/unit/lazy_data/test_map_complete_blocks.py b/lib/iris/tests/unit/lazy_data/test_map_complete_blocks.py index c63f626fd9..be25ab6c09 100644 --- a/lib/iris/tests/unit/lazy_data/test_map_complete_blocks.py +++ b/lib/iris/tests/unit/lazy_data/test_map_complete_blocks.py @@ -47,7 +47,9 @@ def func(chunk): def test_non_lazy_input(self): # Check that a non-lazy input doesn't trip up the functionality. cube, cube_data = create_mock_cube(self.array) - result = map_complete_blocks(cube, self.func, dims=(1,), out_sizes=(4,), dtype=self.array.dtype) + result = map_complete_blocks( + cube, self.func, dims=(1,), out_sizes=(4,), dtype=self.array.dtype + ) assert not is_lazy_data(result) assert_array_equal(result, self.func_result) # check correct data was accessed @@ -57,7 +59,9 @@ def test_non_lazy_input(self): def test_lazy_input(self): lazy_array = da.asarray(self.array, chunks=((1, 1), (4,))) cube, cube_data = create_mock_cube(lazy_array) - result = map_complete_blocks(cube, self.func, dims=(1,), out_sizes=(4,), dtype=lazy_array.dtype) + result = map_complete_blocks( + cube, self.func, dims=(1,), out_sizes=(4,), dtype=lazy_array.dtype + ) assert is_lazy_data(result) assert_array_equal(result.compute(), self.func_result) # check correct data was accessed @@ -67,7 +71,8 @@ def test_lazy_input(self): def test_dask_array_input(self): lazy_array = da.asarray(self.array, chunks=((1, 1), (4,))) result = map_complete_blocks( - lazy_array, self.func, dims=(1,), out_sizes=(4,), dtype=lazy_array.dtype) + lazy_array, self.func, dims=(1,), out_sizes=(4,), dtype=lazy_array.dtype + ) assert is_lazy_data(result) assert_array_equal(result.compute(), self.func_result) @@ -100,7 +105,9 @@ def func(chunk): def test_rechunk(self): lazy_array = da.asarray(self.array, chunks=((1, 1), (2, 2))) cube, _ = create_mock_cube(lazy_array) - result = map_complete_blocks(cube, self.func, dims=(1,), out_sizes=(4,), dtype=lazy_array.dtype) + result = map_complete_blocks( + cube, self.func, dims=(1,), out_sizes=(4,), dtype=lazy_array.dtype + ) assert is_lazy_data(result) assert_array_equal(result.compute(), self.func_result) @@ -112,7 +119,9 @@ def func(_): return np.arange(2).reshape(1, 2) func_result = [[0, 1], [0, 1]] - result = map_complete_blocks(cube, func, dims=(1,), out_sizes=(2,), dtype=lazy_array.dtype) + result = map_complete_blocks( + cube, func, dims=(1,), out_sizes=(2,), dtype=lazy_array.dtype + ) assert is_lazy_data(result) assert_array_equal(result.compute(), func_result) @@ -120,6 +129,8 @@ def test_multidimensional_input(self): array = np.arange(2 * 3 * 4).reshape(2, 3, 4) lazy_array = da.asarray(array, chunks=((1, 1), (1, 2), (4,))) cube, _ = create_mock_cube(lazy_array) - result = map_complete_blocks(cube, self.func, dims=(1, 2), out_sizes=(3, 4), dtype=lazy_array.dtype) + result = map_complete_blocks( + cube, self.func, dims=(1, 2), out_sizes=(3, 4), dtype=lazy_array.dtype + ) assert is_lazy_data(result) assert_array_equal(result.compute(), array + 1) diff --git a/lib/iris/tests/unit/plot/test__get_plot_defn_custom_coords_picked.py b/lib/iris/tests/unit/plot/test__get_plot_defn_custom_coords_picked.py index 80f01be708..defae2ca86 100644 --- a/lib/iris/tests/unit/plot/test__get_plot_defn_custom_coords_picked.py +++ b/lib/iris/tests/unit/plot/test__get_plot_defn_custom_coords_picked.py @@ -5,6 +5,7 @@ """Unit tests for the `iris.plot._get_plot_defn_custom_coords_picked` function. """ + import pytest from iris.coords import BOUND_MODE, POINT_MODE diff --git a/lib/iris/tests/unit/plot/test__get_plot_objects.py b/lib/iris/tests/unit/plot/test__get_plot_objects.py index 20eea759af..a0ae48141a 100644 --- a/lib/iris/tests/unit/plot/test__get_plot_objects.py +++ b/lib/iris/tests/unit/plot/test__get_plot_objects.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.plot._get_plot_objects` function.""" + import pytest import iris.cube diff --git a/lib/iris/tests/unit/plot/test_outline.py b/lib/iris/tests/unit/plot/test_outline.py index 615febfed2..2c84a6c718 100644 --- a/lib/iris/tests/unit/plot/test_outline.py +++ b/lib/iris/tests/unit/plot/test_outline.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.plot.outline` function.""" + import numpy as np import pytest diff --git a/lib/iris/tests/unit/plot/test_points.py b/lib/iris/tests/unit/plot/test_points.py index 41babd53d6..e8778ed30e 100644 --- a/lib/iris/tests/unit/plot/test_points.py +++ b/lib/iris/tests/unit/plot/test_points.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Unit tests for the `iris.plot.points` function.""" + import numpy as np import pytest diff --git a/lib/iris/tests/unit/util/test__slice_data_with_keys.py b/lib/iris/tests/unit/util/test__slice_data_with_keys.py index e6b4067cb5..fd692e2076 100644 --- a/lib/iris/tests/unit/util/test__slice_data_with_keys.py +++ b/lib/iris/tests/unit/util/test__slice_data_with_keys.py @@ -11,6 +11,7 @@ in combination. """ + import numpy as np import pytest diff --git a/lib/iris/tests/unit/util/test_file_is_newer_than.py b/lib/iris/tests/unit/util/test_file_is_newer_than.py index 3e5e997835..bba3f1fe37 100644 --- a/lib/iris/tests/unit/util/test_file_is_newer_than.py +++ b/lib/iris/tests/unit/util/test_file_is_newer_than.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test function :func:`iris.util.test_file_is_newer`.""" + import os import os.path diff --git a/lib/iris/tests/unit/util/test_reverse.py b/lib/iris/tests/unit/util/test_reverse.py index 10d80c8a2e..77d6df0251 100644 --- a/lib/iris/tests/unit/util/test_reverse.py +++ b/lib/iris/tests/unit/util/test_reverse.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test function :func:`iris.util.reverse`.""" + import numpy as np import pytest diff --git a/lib/iris/tests/unit/util/test_rolling_window.py b/lib/iris/tests/unit/util/test_rolling_window.py index 90a6983cff..c2e5bdbb6c 100644 --- a/lib/iris/tests/unit/util/test_rolling_window.py +++ b/lib/iris/tests/unit/util/test_rolling_window.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test function :func:`iris.util.rolling_window`.""" + import dask.array as da import numpy as np import numpy.ma as ma diff --git a/lib/iris/tests/unit/util/test_squeeze.py b/lib/iris/tests/unit/util/test_squeeze.py index e4cc4dc9a7..c1a63a64b6 100644 --- a/lib/iris/tests/unit/util/test_squeeze.py +++ b/lib/iris/tests/unit/util/test_squeeze.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test function :func:`iris.util.squeeze`.""" + import pytest import iris diff --git a/lib/iris/tests/unit/util/test_unify_time_units.py b/lib/iris/tests/unit/util/test_unify_time_units.py index 9b2a6dd170..ceccc459ce 100644 --- a/lib/iris/tests/unit/util/test_unify_time_units.py +++ b/lib/iris/tests/unit/util/test_unify_time_units.py @@ -3,6 +3,7 @@ # This file is part of Iris and is released under the BSD license. # See LICENSE in the root of the repository for full licensing details. """Test function :func:`iris.util.array_equal`.""" + import copy import cf_units