From f1f103927a8bd489aedef70edab691f5544dd7d9 Mon Sep 17 00:00:00 2001 From: Elias Sadek Date: Thu, 30 Nov 2023 14:29:08 +0000 Subject: [PATCH] actioned review comments --- esmf_regrid/constants.py | 2 +- esmf_regrid/experimental/unstructured_scheme.py | 2 +- esmf_regrid/schemes.py | 6 +++--- .../unstructured_scheme/test_GridToMeshESMFRegridder.py | 6 +++--- .../unstructured_scheme/test_MeshToGridESMFRegridder.py | 6 +++--- .../test_regrid_rectilinear_to_unstructured.py | 6 +++--- .../test_regrid_unstructured_to_rectilinear.py | 6 +++--- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/esmf_regrid/constants.py b/esmf_regrid/constants.py index 2335d60e..f750eb6d 100644 --- a/esmf_regrid/constants.py +++ b/esmf_regrid/constants.py @@ -42,7 +42,7 @@ def check_method(method): result = method else: raise ValueError( - f"Method must be a member of `Constants.Method` enum, instead got {method}" + f"Method must be a member of `Constants.Method` enum, instead got method.name.lower()" ) return result diff --git a/esmf_regrid/experimental/unstructured_scheme.py b/esmf_regrid/experimental/unstructured_scheme.py index bc68de57..23b3913c 100644 --- a/esmf_regrid/experimental/unstructured_scheme.py +++ b/esmf_regrid/experimental/unstructured_scheme.py @@ -352,7 +352,7 @@ def regrid_unstructured_to_unstructured( src_mesh_cube, tgt_mesh_cube, mdtol=0, - method="conservative", + method=Constants.Method.CONSERVATIVE, use_src_mask=False, use_tgt_mask=False, ): diff --git a/esmf_regrid/schemes.py b/esmf_regrid/schemes.py index 871c9487..0192021e 100644 --- a/esmf_regrid/schemes.py +++ b/esmf_regrid/schemes.py @@ -483,18 +483,18 @@ def _make_meshinfo(cube_or_mesh, method, mask, src_or_tgt, location=None): if method == Constants.Method.CONSERVATIVE: if location != "face": raise ValueError( - f"Conservative regridding requires a {src_or_tgt} cube located on " + f"{method.name.lower()} regridding requires a {src_or_tgt} cube located on " f"the face of a cube, target cube had the {location} location." ) elif method in (Constants.Method.NEAREST, Constants.Method.BILINEAR): if location not in ["face", "node"]: raise ValueError( - f"{method} regridding requires a {src_or_tgt} cube with a node " + f"{method.name.lower()} regridding requires a {src_or_tgt} cube with a node " f"or face location, target cube had the {location} location." ) if location == "face" and None in mesh.face_coords: raise ValueError( - f"{method} regridding requires a {src_or_tgt} cube on a face" + f"{method.name.lower()} regridding requires a {src_or_tgt} cube on a face" f"location to have a face center." ) 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 c178c8e4..c3b11581 100644 --- a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_GridToMeshESMFRegridder.py +++ b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_GridToMeshESMFRegridder.py @@ -208,21 +208,21 @@ def test_invalid_method(): with pytest.raises(ValueError) as excinfo: _ = GridToMeshESMFRegridder(src, node_tgt, method=Constants.Method.CONSERVATIVE) expected_message = ( - "Conservative regridding requires a target cube located on " + "conservative regridding requires a target 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: _ = GridToMeshESMFRegridder(src, edge_tgt, method=Constants.Method.BILINEAR) expected_message = ( - "Method.BILINEAR regridding requires a target cube with a node " + "bilinear regridding requires a target 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: _ = GridToMeshESMFRegridder(src, edge_tgt, method=Constants.Method.NEAREST) expected_message = ( - "Method.NEAREST regridding requires a target cube with a node " + "nearest regridding requires a target cube with a node " "or face location, target cube had the edge location." ) assert expected_message in str(excinfo.value) 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 d66c94cb..563759bf 100644 --- a/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_MeshToGridESMFRegridder.py +++ b/esmf_regrid/tests/unit/experimental/unstructured_scheme/test_MeshToGridESMFRegridder.py @@ -204,21 +204,21 @@ def test_invalid_method(): with pytest.raises(ValueError) as excinfo: _ = MeshToGridESMFRegridder(node_src, tgt, method=Constants.Method.CONSERVATIVE) expected_message = ( - "Conservative regridding requires a source cube located on " + "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: _ = MeshToGridESMFRegridder(edge_src, tgt, method=Constants.Method.BILINEAR) expected_message = ( - "Method.BILINEAR regridding requires a source cube with a node " + "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: _ = MeshToGridESMFRegridder(edge_src, tgt, method=Constants.Method.NEAREST) expected_message = ( - "Method.NEAREST regridding requires a source cube with a node " + "nearest regridding requires a source cube with a node " "or face location, target cube had the edge location." ) assert expected_message in str(excinfo.value) 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 699ba583..e408a39a 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 @@ -131,7 +131,7 @@ def test_invalid_args(): src, node_tgt, method=Constants.Method.CONSERVATIVE ) expected_message = ( - "Conservative regridding requires a target cube located on " + "conservative regridding requires a target cube located on " "the face of a cube, target cube had the node location." ) assert expected_message in str(excinfo.value) @@ -140,7 +140,7 @@ def test_invalid_args(): src, edge_tgt, method=Constants.Method.BILINEAR ) expected_message = ( - "Method.BILINEAR regridding requires a target cube with a node " + "bilinear regridding requires a target cube with a node " "or face location, target cube had the edge location." ) assert expected_message in str(excinfo.value) @@ -149,7 +149,7 @@ def test_invalid_args(): src, edge_tgt, method=Constants.Method.NEAREST ) expected_message = ( - "Method.NEAREST regridding requires a target cube with a node " + "nearest regridding requires a target cube with a node " "or face location, target cube had the edge location." ) assert expected_message in str(excinfo.value) 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 72e48c2e..36f94d44 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 @@ -125,7 +125,7 @@ def test_invalid_args(): node_src, tgt, method=Constants.Method.CONSERVATIVE ) expected_message = ( - "Conservative regridding requires a source cube located on " + "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) @@ -134,7 +134,7 @@ def test_invalid_args(): edge_src, tgt, method=Constants.Method.BILINEAR ) expected_message = ( - "Method.BILINEAR regridding requires a source cube with a node " + "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) @@ -143,7 +143,7 @@ def test_invalid_args(): edge_src, tgt, method=Constants.Method.NEAREST ) expected_message = ( - "Method.NEAREST regridding requires a source cube with a node " + "nearest regridding requires a source cube with a node " "or face location, target cube had the edge location." ) assert expected_message in str(excinfo.value)