• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

victoriyaforsythe / PyIRI / 15282160672

27 May 2025 05:45PM UTC coverage: 47.272%. First build
15282160672

push

github

web-flow
Merge pull request #49 from victoriyaforsythe/victoriya_tests

New F1 model, new EDP construction, tests.

361 of 479 new or added lines in 8 files covered. (75.37%)

953 of 2016 relevant lines covered (47.27%)

3.31 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.61
/PyIRI/tests/test_edp_update.py
1
"""
2
Unit tests for PyIRI's edp_update module.
3
"""
4

5
import numpy as np
7✔
6
import pytest
7✔
7

8
import PyIRI
7✔
9
from PyIRI import edp_update
7✔
10
from PyIRI import edp_update as ml
7✔
11

12

13
def test_IRI_density_1day_runs():
7✔
14
    """Test that IRI_density_1day runs and returns expected shape."""
15
    year = 2024
7✔
16
    mth = 6
7✔
17
    day = 21
7✔
18
    aUT = np.array([12.0])
7✔
19
    alon = np.array([0.0])
7✔
20
    alat = np.array([0.0])
7✔
21
    aalt = np.linspace(100, 600, 20)
7✔
22
    F107 = 100.0
7✔
23
    coeff_dir = PyIRI.coeff_dir
7✔
24

25
    try:
7✔
26
        F2, F1, E, Es, sun, mag, EDP = edp_update.IRI_density_1day(
7✔
27
            year, mth, day, aUT, alon, alat, aalt, F107, coeff_dir)
28
        assert EDP.shape[1] == len(aalt)
7✔
NEW
29
    except Exception as e:
×
NEW
30
        pytest.fail(f"Function raised an exception: {e}")
×
31

32

33
def test_Probability_F1_output():
7✔
34
    """Test output of Probability_F1 against expected values."""
35
    year = 2020
7✔
36
    month = 4
7✔
37
    aUT = np.arange(0, 24, 24)
7✔
38
    alon = np.array([10.])
7✔
39
    alat = np.array([20.])
7✔
40
    expected = np.array([[[0.00210238, 0.00210238]]])
7✔
41

42
    result = ml.Probability_F1(year, month, aUT, alon, alat)
7✔
43
    assert result.shape == expected.shape, (
7✔
44
        "Shape mismatch in Probability_F1 output")
45
    assert np.allclose(result, expected, atol=1e-8), (
7✔
46
        "Value mismatch in Probability_F1 output")
47

48

49
def test_drop_up_output():
7✔
50
    """Test drop_up returns expected value."""
51
    z_E = 230.0
7✔
52
    z_F = 110.0
7✔
53
    z_top = 250.0
7✔
54
    expected = 0.2245381938521092
7✔
55

56
    result = ml.drop_up(z_E, z_F, z_top, drop_fraction=0.2)
7✔
57
    assert abs(result - expected) < 1e-8, "drop_up output mismatch"
7✔
58

59

60
def test_logistic_curve_output():
7✔
61
    """Test logistic_curve returns expected value."""
62
    z = 240.0
7✔
63
    z0 = 200.0
7✔
64
    scale = 50.0
7✔
65
    expected = 0.6899744811276125
7✔
66

67
    result = ml.logistic_curve(z, z0, scale)
7✔
68
    assert abs(result - expected) < 1e-8, "logistic_curve output mismatch"
7✔
69

70

71
def test_derive_dependent_F1_parameters_output():
7✔
72
    """Test derive_dependent_F1_parameters output accuracy."""
73
    p_F1 = np.array([0.5])
7✔
74
    NmF2 = np.array([1.0e11])
7✔
75
    hmF2 = np.array([350.])
7✔
76
    B_F2_bot = np.array([60.])
7✔
77
    z_E = np.array([110.])
7✔
78
    expected_NmF1 = np.array([5.54030525e+10])
7✔
79
    expected_B_F1_bot = np.array([2.1137616])
7✔
80
    expected_hmF1 = np.array([254.])
7✔
81
    expected_thickness = np.array([72.])
7✔
82

83
    NmF1, B_F1_bot, hmF1, thickness = ml.derive_dependent_F1_parameters(
7✔
84
        p_F1, NmF2, hmF2, B_F2_bot, z_E)
85

86
    assert np.allclose(NmF1, expected_NmF1, atol=1e-6), "NmF1 mismatch"
7✔
87
    assert np.allclose(B_F1_bot, expected_B_F1_bot,
7✔
88
                       atol=1e-6), "B_F1_bot mismatch"
89
    assert np.allclose(hmF1, expected_hmF1, atol=1e-6), "hmF1 mismatch"
7✔
90
    assert np.allclose(thickness, expected_thickness,
7✔
91
                       atol=1e-6), "thickness mismatch"
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc