Skip to content

Commit

Permalink
Αdd test for quad area function (#61)
Browse files Browse the repository at this point in the history
* added test for test quad area

* remove placeholder tests trivial

* reformat with black

* Update tests/test_grid_generation.py

Co-authored-by: Navid C. Constantinou <[email protected]>

* Update tests/test_grid_generation.py

Co-authored-by: Navid C. Constantinou <[email protected]>

* Update tests/test_grid_generation.py

Co-authored-by: Navid C. Constantinou <[email protected]>

* Update tests/test_grid_generation.py

Co-authored-by: Navid C. Constantinou <[email protected]>

---------

Co-authored-by: Navid C. Constantinou <[email protected]>
  • Loading branch information
ashjbarnes and navidcy authored Sep 4, 2023
1 parent 7a557bb commit f876f88
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ _build
regional_mom6/_version.py
regional_mom6.egg-info
.pytest_cache
env
.env
32 changes: 32 additions & 0 deletions tests/test_grid_generation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import numpy as np
import pytest
from regional_mom6 import angle_between
from regional_mom6 import quad_area


@pytest.mark.parametrize(
("v1", "v2", "v3", "true_angle"),
[
([1, 0, 0], [0, 1, 0], [0, 0, 1], np.pi / 2),
([1, 0, 0], [1, 1, 0], [0, 1, 1], np.pi / 4),
],
)
def test_angle_between(v1, v2, v3, true_angle):
assert np.isclose(angle_between(v1, v2, v3), true_angle)


# create a lat-lon mesh that covers 1/4 of the North Hemisphere
lon, lat = np.meshgrid(np.linspace(0, 90, 5), np.linspace(0, 90, 5))


@pytest.mark.parametrize(
("lat", "lon", "true_area"),
[
(lat, lon, 0.5 * np.pi),
],
)
def test_quad_area(lat, lon, true_area):
assert np.isclose(np.sum(quad_area(lat, lon)), true_area)


# what to return when pytest passes
15 changes: 0 additions & 15 deletions tests/test_trivial.py

This file was deleted.

0 comments on commit f876f88

Please sign in to comment.