Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Αdd test for quad area function #61

Merged
merged 7 commits into from
Sep 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.