-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Αdd test for quad area function (#61)
* 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
1 parent
7a557bb
commit f876f88
Showing
3 changed files
with
33 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ _build | |
regional_mom6/_version.py | ||
regional_mom6.egg-info | ||
.pytest_cache | ||
env | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file was deleted.
Oops, something went wrong.