-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils_tests.py
More file actions
75 lines (65 loc) · 2.5 KB
/
utils_tests.py
File metadata and controls
75 lines (65 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import pytest
import numpy as np
@pytest.mark.parametrize("t, instrument, band, measurement_type", [
(5, 0, 3, 1),
(0, 0, 0, 0),
(29, 0, 5, 2),
])
def test_valid_indices(t, instrument, band, measurement_type):
"""Test with valid indices."""
try:
all_x_and_y(t, instrument, band, measurement_type)
except IndexError:
pytest.fail(f"all_x_and_y raised IndexError unexpectedly for t={t}, instrument={instrument}, band={band}, measurement_type={measurement_type}!")
@pytest.mark.parametrize("t, instrument, band, measurement_type", [
(30, 0, 3, 1),
(5, 1, 3, 1),
(5, 0, 6, 1),
(5, 0, 3, 3),
])
def test_invalid_indices(t, instrument, band, measurement_type):
"""Test with invalid indices."""
with pytest.raises(IndexError):
all_x_and_y(t, instrument, band, measurement_type)
@pytest.mark.parametrize("t, instrument, band, measurement_type", [
(0, 0, 0, 0),
(29, 0, 5, 2),
])
def test_boundary_indices(t, instrument, band, measurement_type):
"""Test with boundary indices."""
try:
all_x_and_y(t, instrument, band, measurement_type)
except IndexError:
pytest.fail(f"all_x_and_y raised IndexError unexpectedly for t={t}, instrument={instrument}, band={band}, measurement_type={measurement_type}!")
@pytest.mark.parametrize("sza, vza, raa, expected", [
(0, 0, 0, 180),
(90, 90, 0, 180),
(45, 45, 180, 90),
(60, 30, 90, 115.658906),
])
def test_scattering_angle_valid(sza, vza, raa, expected):
"""Test with valid angles."""
result = scattering_angle(sza, vza, raa)
np.testing.assert_almost_equal(result, expected, decimal=6) # Tolérance de 6 décimales
@pytest.mark.parametrize("sza, vza, raa, expected", [
(-10, 30, 90, 148.525051),
(60, -20, 90, 118.024320),
(60, 30, -50, 135.344690),
(95, 30, 90, 85.671249),
(60, 100, 90, 85.019074),
(60, 30, 370, 149.254545),
])
def test_scattering_angle_valid_negatif(sza, vza, raa, expected):
"""Test with valid angles."""
result = scattering_angle(sza, vza, raa)
np.testing.assert_almost_equal(result, expected, decimal=6)
@pytest.mark.parametrize("sza, vza, raa", [
(0, 0, 0),
(90, 90, 360),
])
def test_scattering_angle_boundaries(sza, vza, raa):
"""Test with boundary values for angles."""
try:
scattering_angle(sza, vza, raa)
except ValueError:
pytest.fail(f"scattering_angle raised ValueError unexpectedly for sza={sza}, vza={vza}, raa={raa}")