Skip to content

Commit

Permalink
All remaining changes
Browse files Browse the repository at this point in the history
  • Loading branch information
HGWright committed Mar 27, 2024
1 parent cdfe56f commit 37c4bb5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion lib/iris/experimental/geovista.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ def extract_unstructured_region(cube, polydata, region, **kwargs):
indices_key = VTK_POINT_IDS
else:
raise NotImplementedError(
f"Must be on face or node. Found: {cube.location}."
f"cube.location must be `face` or `node`. Found: {cube.location}."
)

if cube.shape[mesh_dim] != polydata_length:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ def test_integration_2d():
"votemper.nc",
]
)
with PARSE_UGRID_ON_LOAD:
global_cube = load_cube(file_path, "votemper")

polydata = cube_to_polydata(global_cube[0, 1, :])
cube = load_cube(file_path, "votemper")

polydata = cube_to_polydata(cube[0, 1, :])
# This is a known good output, we have plotted the result and checked it.
assert polydata.GetNumberOfCells() == 26640
assert polydata.GetNumberOfPoints() == 26969
np.testing.assert_array_equal(cube[0, 1, :].data.flatten(), polydata.active_scalars)


def test_integration_1d():
Expand All @@ -38,13 +39,13 @@ def test_integration_1d():
"SMALL_hires_wind_u_for_ipcc4.nc",
]
)
with PARSE_UGRID_ON_LOAD:
global_cube = load_cube(file_path)
cube = load_cube(file_path)

polydata = cube_to_polydata(global_cube[0, :])
polydata = cube_to_polydata(cube[0, :])
# This is a known good output, we have plotted the result and checked it.
assert polydata.GetNumberOfCells() == 51200
assert polydata.GetNumberOfPoints() == 51681
np.testing.assert_array_equal(cube[0, :].data.flatten(), polydata.active_scalars)


def test_integration_mesh():
Expand All @@ -57,10 +58,10 @@ def test_integration_mesh():
)

with PARSE_UGRID_ON_LOAD.context():
global_cube = load_cube(file_path, "conv_rain")
cube = load_cube(file_path, "conv_rain")

polydata = cube_to_polydata(global_cube[0, :])
polydata = cube_to_polydata(cube[0, :])
# This is a known good output, we have plotted the result and checked it.
assert polydata.GetNumberOfCells() == 864
assert polydata.GetNumberOfPoints() == 866
np.testing.assert_array_equal(polydata.active_scalars, global_cube[0, :].data)
np.testing.assert_array_equal(polydata.active_scalars, cube[0, :].data)
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ def test_face_region_extraction():

assert extracted_cube.ndim == 2
assert extracted_cube.shape == (72, 101)
assert global_cube.shape == (72, 864)
assert global_cube.ndim == 2
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def expected(self, cube_2d):
"xs": cube_2d.coord(axis="X").contiguous_bounds(),
"ys": cube_2d.coord(axis="Y").contiguous_bounds(),
"data": cube_2d.data,
"name": cube_2d.name() + " / " + "(" + str(cube_2d.units) + ")",
"name": f"{cube_2d.name()} / ({cube_2d.units})",
}

@pytest.fixture()
Expand All @@ -120,7 +120,7 @@ def expected(self, cube_1d):
"xs": cube_1d.coord(axis="X").contiguous_bounds(),
"ys": cube_1d.coord(axis="Y").contiguous_bounds(),
"data": cube_1d.data,
"name": cube_1d.name() + " / " + "(" + str(cube_1d.units) + ")",
"name": f"{cube_1d.name()} / ({cube_1d.units})",
}

@pytest.fixture()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ def test_no_mesh(self, cube_2d):
def test_edge_location(self, cube_mesh_edge):
with pytest.raises(
NotImplementedError,
match=f"Must be on face or node." f" Found: {cube_mesh_edge.location}.",
match=f"cube.location must be `face` or `node`."
f" Found: {cube_mesh_edge.location}.",
):
extract_unstructured_region(
cube_mesh_edge, self.mocked_polydata, self.mocked_region
Expand Down

0 comments on commit 37c4bb5

Please sign in to comment.