Skip to content

Commit

Permalink
added test for test quad area
Browse files Browse the repository at this point in the history
  • Loading branch information
ashjbarnes committed Sep 4, 2023
1 parent 7a557bb commit 907f071
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
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
30 changes: 30 additions & 0 deletions tests/test_grid_generation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import numpy as np
import pytest
from regional_mom6 import angle_between
from regional_mom6 import quad_area


# placeholder trivial test test
@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)

X, Y = np.meshgrid(np.linspace(0,90,100), np.linspace(0,90,100))
X, Y = np.meshgrid(np.linspace(0,90, 5), np.linspace(0, 90, 5))
@pytest.mark.parametrize(
("lat", "lon", "true_area"),
[
(Y,X, 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

0 comments on commit 907f071

Please sign in to comment.