diff --git a/esmf_regrid/tests/integration/esmf_regridder/test_Regridder.py b/esmf_regrid/tests/integration/esmf_regridder/test_Regridder.py index 911e49fa..42210489 100644 --- a/esmf_regrid/tests/integration/esmf_regridder/test_Regridder.py +++ b/esmf_regrid/tests/integration/esmf_regridder/test_Regridder.py @@ -4,7 +4,7 @@ from numpy import ma from esmf_regrid import esmpy -from .... import Constants +from esmf_regrid import Constants from esmf_regrid.esmf_regridder import GridInfo, Regridder from esmf_regrid.tests import make_grid_args diff --git a/esmf_regrid/tests/unit/esmf_regridder/test_Regridder.py b/esmf_regrid/tests/unit/esmf_regridder/test_Regridder.py index 84eac0c8..c29d6df8 100644 --- a/esmf_regrid/tests/unit/esmf_regridder/test_Regridder.py +++ b/esmf_regrid/tests/unit/esmf_regridder/test_Regridder.py @@ -5,7 +5,7 @@ import pytest import scipy.sparse -from .... import Constants +from esmf_regrid import Constants from esmf_regrid.esmf_regridder import GridInfo, Regridder from esmf_regrid.tests import make_grid_args diff --git a/esmf_regrid/tests/unit/experimental/io/test_round_tripping.py b/esmf_regrid/tests/unit/experimental/io/test_round_tripping.py index 5f8d8a2d..fa213b2c 100644 --- a/esmf_regrid/tests/unit/experimental/io/test_round_tripping.py +++ b/esmf_regrid/tests/unit/experimental/io/test_round_tripping.py @@ -3,7 +3,6 @@ import numpy as np from numpy import ma import pytest -from ..... import Constants from esmf_regrid.experimental.io import load_regridder, save_regridder from esmf_regrid.experimental.unstructured_scheme import ( @@ -17,6 +16,7 @@ from esmf_regrid.tests.unit.schemes.test__mesh_to_MeshInfo import ( _gridlike_mesh_cube, ) +from esmf_regrid import Constants def _make_grid_to_mesh_regridder( diff --git a/esmf_regrid/tests/unit/experimental/unstructured_regrid/test_MeshInfo.py b/esmf_regrid/tests/unit/experimental/unstructured_regrid/test_MeshInfo.py index 96b17016..655e7ea1 100644 --- a/esmf_regrid/tests/unit/experimental/unstructured_regrid/test_MeshInfo.py +++ b/esmf_regrid/tests/unit/experimental/unstructured_regrid/test_MeshInfo.py @@ -3,11 +3,11 @@ import numpy as np from numpy import ma -from ..... import Constants from esmf_regrid.esmf_regridder import GridInfo, Regridder from esmf_regrid.experimental.unstructured_regrid import MeshInfo from esmf_regrid.tests import get_result_path, make_grid_args +from esmf_regrid import Constants def _make_small_mesh_args(): ugrid_node_coords = np.array( @@ -112,9 +112,7 @@ def test_regrid_bilinear_with_mesh(): grid_args = [ar * 2 for ar in make_grid_args(2, 3)] grid = GridInfo(*grid_args, center=True) - mesh_to_grid_regridder = Regridder( - node_mesh, grid, method=Constants.Method.BILINEAR - ) + mesh_to_grid_regridder = Regridder(node_mesh, grid, method=Constants.Method.BILINEAR) mesh_input = np.arange(5) grid_output = mesh_to_grid_regridder.regrid(mesh_input) # For a flat surface, we would expect the fractional part of these values @@ -135,17 +133,13 @@ def test_regrid_bilinear_with_mesh(): expected_grid_output = ma.array(expected_grid_output, mask=expected_grid_mask) assert ma.allclose(expected_grid_output, grid_output) - grid_to_mesh_regridder = Regridder( - grid, node_mesh, method=Constants.Method.BILINEAR - ) + grid_to_mesh_regridder = Regridder(grid, node_mesh, method=Constants.Method.BILINEAR) grid_input = np.array([[0, 0], [1, 0], [2, 1]]) mesh_output = grid_to_mesh_regridder.regrid(grid_input) expected_mesh_output = ma.array([0.0, 1.5, 0.0, 0.5, -1], mask=[0, 0, 0, 0, 1]) assert ma.allclose(expected_mesh_output, mesh_output) - grid_to_face_mesh_regridder = Regridder( - grid, face_mesh, method=Constants.Method.BILINEAR - ) + grid_to_face_mesh_regridder = Regridder(grid, face_mesh, method=Constants.Method.BILINEAR) grid_input_2 = np.array([[0, 0], [1, 0], [4, 1]]) face_mesh_output = grid_to_face_mesh_regridder.regrid(grid_input_2) expected_face_mesh_output = np.array([0.0, 1.4888258584989558]) diff --git a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_GridToMeshESMFRegridder.py b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_GridToMeshESMFRegridder.py index d710ace4..74e9b2b0 100644 --- a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_GridToMeshESMFRegridder.py +++ b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_GridToMeshESMFRegridder.py @@ -7,7 +7,6 @@ from numpy import ma import pytest -from ..... import Constants from esmf_regrid.experimental.unstructured_scheme import ( GridToMeshESMFRegridder, ) @@ -22,7 +21,7 @@ from esmf_regrid.tests.unit.schemes.test__regrid_unstructured_to_rectilinear__prepare import ( _flat_mesh_cube, ) - +from esmf_regrid import Constants def _add_metadata(cube): result = cube.copy() diff --git a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_MeshToGridESMFRegridder.py b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_MeshToGridESMFRegridder.py index b78fc267..9a76bf56 100644 --- a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_MeshToGridESMFRegridder.py +++ b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_MeshToGridESMFRegridder.py @@ -6,7 +6,6 @@ import numpy as np import pytest -from ..... import Constants from esmf_regrid.experimental.unstructured_scheme import ( MeshToGridESMFRegridder, ) @@ -22,6 +21,7 @@ _flat_mesh_cube, _full_mesh, ) +from esmf_regrid import Constants def _add_metadata(cube): diff --git a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_rectilinear_to_unstructured.py b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_rectilinear_to_unstructured.py index 27f901a1..93698b5f 100644 --- a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_rectilinear_to_unstructured.py +++ b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_rectilinear_to_unstructured.py @@ -6,7 +6,6 @@ from numpy import ma import pytest -from ..... import Constants from esmf_regrid.experimental.unstructured_scheme import ( regrid_rectilinear_to_unstructured, ) @@ -19,7 +18,7 @@ from esmf_regrid.tests.unit.schemes.test__regrid_unstructured_to_rectilinear__prepare import ( _flat_mesh_cube, ) - +from esmf_regrid import Constants def _add_metadata(cube): result = cube.copy() diff --git a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_unstructured_to_rectilinear.py b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_unstructured_to_rectilinear.py index 08d90cf6..cf503b2c 100644 --- a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_unstructured_to_rectilinear.py +++ b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_regrid_unstructured_to_rectilinear.py @@ -5,7 +5,6 @@ import numpy as np import pytest -from ..... import Constants from esmf_regrid.experimental.unstructured_scheme import ( regrid_unstructured_to_rectilinear, ) @@ -19,7 +18,7 @@ _flat_mesh_cube, _full_mesh, ) - +from esmf_regrid import Constants def _add_metadata(cube): result = cube.copy() @@ -65,9 +64,7 @@ def test_flat_cubes(): assert expected_cube == result -@pytest.mark.parametrize( - "method", (Constants.Method.BILINEAR, Constants.Method.NEAREST) -) +@pytest.mark.parametrize("method", (Constants.Method.BILINEAR, Constants.Method.NEAREST)) def test_node_friendly_methods(method): """ Basic test for :func:`esmf_regrid.experimental.unstructured_scheme.regrid_unstructured_to_rectilinear`. @@ -115,35 +112,25 @@ def test_invalid_args(): tgt = _grid_cube(n_lons, n_lats, lon_bounds, lat_bounds, circular=True) with pytest.raises(ValueError): - _ = regrid_unstructured_to_rectilinear( - tgt, tgt, method=Constants.Method.BILINEAR - ) + _ = regrid_unstructured_to_rectilinear(tgt, tgt, method=Constants.Method.BILINEAR) with pytest.raises(NotImplementedError): - _ = regrid_unstructured_to_rectilinear( - face_src, tgt, method=Constants.Method.NEAREST - ) + _ = regrid_unstructured_to_rectilinear(face_src, tgt, method=Constants.Method.NEAREST) with pytest.raises(ValueError) as excinfo: - _ = regrid_unstructured_to_rectilinear( - node_src, tgt, method=Constants.Method.CONSERVATIVE - ) + _ = regrid_unstructured_to_rectilinear(node_src, tgt, method=Constants.Method.CONSERVATIVE) expected_message = ( "Conservative regridding requires a source cube located on " "the face of a cube, target cube had the node location." ) assert expected_message in str(excinfo.value) with pytest.raises(ValueError) as excinfo: - _ = regrid_unstructured_to_rectilinear( - edge_src, tgt, method=Constants.Method.BILINEAR - ) + _ = regrid_unstructured_to_rectilinear(edge_src, tgt, method=Constants.Method.BILINEAR) expected_message = ( "bilinear regridding requires a source cube with a node " "or face location, target cube had the edge location." ) assert expected_message in str(excinfo.value) with pytest.raises(ValueError) as excinfo: - _ = regrid_unstructured_to_rectilinear( - edge_src, tgt, method=Constants.Method.NEAREST - ) + _ = regrid_unstructured_to_rectilinear(edge_src, tgt, method=Constants.Method.NEAREST) expected_message = ( "nearest regridding requires a source cube with a node " "or face location, target cube had the edge location." diff --git a/esmf_regrid/tests/unit/schemes/test__regrid_unstructured_to_rectilinear__prepare.py b/esmf_regrid/tests/unit/schemes/test__regrid_unstructured_to_rectilinear__prepare.py index 3a1ab718..056c174e 100644 --- a/esmf_regrid/tests/unit/schemes/test__regrid_unstructured_to_rectilinear__prepare.py +++ b/esmf_regrid/tests/unit/schemes/test__regrid_unstructured_to_rectilinear__prepare.py @@ -4,7 +4,6 @@ from iris.cube import Cube import numpy as np -from .... import Constants from esmf_regrid.esmf_regridder import GridInfo from esmf_regrid.experimental.unstructured_regrid import MeshInfo from esmf_regrid.schemes import ( @@ -16,7 +15,7 @@ from esmf_regrid.tests.unit.schemes.test__mesh_to_MeshInfo import ( _example_mesh, ) - +from esmf_regrid import Constants def _full_mesh(): mesh = _example_mesh()