Skip to content

Commit

Permalink
test the exception error by quadilateral_area
Browse files Browse the repository at this point in the history
  • Loading branch information
navidcy committed Sep 6, 2023
1 parent 139ac70 commit aa5ed7a
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/test_grid_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ def test_quadilateral_area(v1, v2, v3, v4, true_area):
assert np.isclose(quadilateral_area(v1, v2, v3, v4), true_area)


v1 = latlon_to_cartesian(0, 0, R=2)
v2 = latlon_to_cartesian(90, 0, R=2)
v3 = latlon_to_cartesian(0, 90, R=2)
v4 = latlon_to_cartesian(-90, 0, R=2.1)


def test_quadilateral_area_exception():
with pytest.raises(Exception) as excinfo:
quadilateral_area(v1, v2, v3, v4)

assert str(excinfo.value) == "vectors provided must have the same length"


# create a lat-lon mesh that covers 1/4 of the North Hemisphere
lon1, lat1 = np.meshgrid(np.linspace(0, 90, 5), np.linspace(0, 90, 5))
area1 = 1 / 8 * (4 * np.pi)
Expand Down

0 comments on commit aa5ed7a

Please sign in to comment.