Skip to content

Commit

Permalink
actioned review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ESadek-MO committed Nov 30, 2023
1 parent 18524aa commit f1f1039
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion esmf_regrid/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion esmf_regrid/experimental/unstructured_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
):
Expand Down
6 changes: 3 additions & 3 deletions esmf_regrid/schemes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit f1f1039

Please sign in to comment.