From 55e5ad3b5a72a2f2196cab3bb5d5cdb427e6846b Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 10 Oct 2023 16:18:10 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- esmf_regrid/experimental/unstructured_scheme.py | 4 +++- esmf_regrid/schemes.py | 13 ++++++++----- .../tests/unit/schemes/test_ESMFAreaWeighted.py | 8 +++++++- esmf_regrid/tests/unit/schemes/test_ESMFBilinear.py | 8 +++++++- esmf_regrid/tests/unit/schemes/test_ESMFNearest.py | 8 +++++++- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/esmf_regrid/experimental/unstructured_scheme.py b/esmf_regrid/experimental/unstructured_scheme.py index 2eda00e6..b1d1efd2 100644 --- a/esmf_regrid/experimental/unstructured_scheme.py +++ b/esmf_regrid/experimental/unstructured_scheme.py @@ -442,5 +442,7 @@ def regrid_unstructured_to_unstructured( src_mask=src_mask, tgt_mask=tgt_mask, ) - result = _regrid_rectilinear_to_unstructured__perform(src_mesh_cube, regrid_info, mdtol) + result = _regrid_rectilinear_to_unstructured__perform( + src_mesh_cube, regrid_info, mdtol + ) return result diff --git a/esmf_regrid/schemes.py b/esmf_regrid/schemes.py index a9faab9a..026fca0a 100644 --- a/esmf_regrid/schemes.py +++ b/esmf_regrid/schemes.py @@ -774,7 +774,6 @@ def _regrid_unstructured_to_unstructured__prepare( tgt_mask=None, tgt_location=None, ): - if isinstance(tgt_cube_or_mesh, Mesh): mesh = tgt_cube_or_mesh location = tgt_location @@ -785,10 +784,15 @@ def _regrid_unstructured_to_unstructured__prepare( mesh_dim = src_mesh_cube.mesh_dim() src_meshinfo = _make_meshinfo(src_mesh_cube, method, src_mask, "source") - tgt_meshinfo = _make_meshinfo(tgt_cube_or_mesh, method, tgt_mask, "target", location=tgt_location) + tgt_meshinfo = _make_meshinfo( + tgt_cube_or_mesh, method, tgt_mask, "target", location=tgt_location + ) regridder = Regridder( - src_meshinfo, tgt_meshinfo, method=method, precomputed_weights=precomputed_weights + src_meshinfo, + tgt_meshinfo, + method=method, + precomputed_weights=precomputed_weights, ) regrid_info = RegridInfo( @@ -801,7 +805,6 @@ def _regrid_unstructured_to_unstructured__prepare( def _regrid_unstructured_to_unstructured__perform(src_cube, regrid_info, mdtol): - (mesh_dim,) = regrid_info.dims mesh, location = regrid_info.target regridder = regrid_info.regridder @@ -813,7 +816,7 @@ def _regrid_unstructured_to_unstructured__perform(src_cube, regrid_info, mdtol): num_out_dims=1, mdtol=mdtol, ) - if location =="face": + if location == "face": face_node = mesh.face_node_connectivity chunk_shape = (face_node.shape[face_node.location_axis],) elif location == "node": diff --git a/esmf_regrid/tests/unit/schemes/test_ESMFAreaWeighted.py b/esmf_regrid/tests/unit/schemes/test_ESMFAreaWeighted.py index 71d5f39e..9fd54dd8 100644 --- a/esmf_regrid/tests/unit/schemes/test_ESMFAreaWeighted.py +++ b/esmf_regrid/tests/unit/schemes/test_ESMFAreaWeighted.py @@ -13,7 +13,13 @@ @pytest.mark.parametrize( "src_type,tgt_type", - [("grid", "grid"), ("grid", "mesh"), ("grid", "just_mesh"), ("mesh", "grid"), ("mesh", "mesh")], + [ + ("grid", "grid"), + ("grid", "mesh"), + ("grid", "just_mesh"), + ("mesh", "grid"), + ("mesh", "mesh"), + ], ) def test_cube_regrid(src_type, tgt_type): """ diff --git a/esmf_regrid/tests/unit/schemes/test_ESMFBilinear.py b/esmf_regrid/tests/unit/schemes/test_ESMFBilinear.py index ea504755..9448dcc3 100644 --- a/esmf_regrid/tests/unit/schemes/test_ESMFBilinear.py +++ b/esmf_regrid/tests/unit/schemes/test_ESMFBilinear.py @@ -13,7 +13,13 @@ @pytest.mark.parametrize( "src_type,tgt_type", - [("grid", "grid"), ("grid", "mesh"), ("grid", "just_mesh"), ("mesh", "grid"), ("mesh", "mesh")], + [ + ("grid", "grid"), + ("grid", "mesh"), + ("grid", "just_mesh"), + ("mesh", "grid"), + ("mesh", "mesh"), + ], ) def test_cube_regrid(src_type, tgt_type): """ diff --git a/esmf_regrid/tests/unit/schemes/test_ESMFNearest.py b/esmf_regrid/tests/unit/schemes/test_ESMFNearest.py index ed8f62f0..3f7e95eb 100644 --- a/esmf_regrid/tests/unit/schemes/test_ESMFNearest.py +++ b/esmf_regrid/tests/unit/schemes/test_ESMFNearest.py @@ -18,7 +18,13 @@ @pytest.mark.parametrize( "src_type,tgt_type", - [("grid", "grid"), ("grid", "mesh"), ("grid", "just_mesh"), ("mesh", "grid"), ("mesh", "mesh")], + [ + ("grid", "grid"), + ("grid", "mesh"), + ("grid", "just_mesh"), + ("mesh", "grid"), + ("mesh", "mesh"), + ], ) def test_cube_regrid(src_type, tgt_type): """