Skip to content

Commit

Permalink
don't conglomerate tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wx4stg committed Nov 14, 2023
1 parent 5823f9f commit 48b8e59
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions tests/calc/test_indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,10 @@ def test_corfidi_motion():
38.32734963, -11.90040377] * units('kt')
assert_almost_equal(motion_full.flatten(), truth_full, 8)


def test_corfidi_motion_override_llj():
"""Test corfidi MCS motion with overridden LLJ"""

Check failure on line 190 in tests/calc/test_indices.py

View workflow job for this annotation

GitHub Actions / Flake8

[ruff] reported by reviewdog 🐶 D400 First line should end with a period Raw Output: tests/calc/test_indices.py:190:5: D400 First line should end with a period
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC')
motion_override = concatenate(corfidi_storm_motion(data['pressure'],
data['u_wind'], data['v_wind'],
u_llj=0 * units('kt'),
Expand All @@ -193,15 +197,35 @@ def test_corfidi_motion():
35.45121012, 20.97402126] * units('kt')
assert_almost_equal(motion_override.flatten(), truth_override, 8)

with pytest.raises(ValueError):
corfidi_storm_motion(data['pressure'], data['u_wind'],
data['v_wind'], u_llj=10 * units('kt'))

with pytest.raises(ValueError):
corfidi_storm_motion(data['pressure'], data['u_wind'],
data['v_wind'], v_llj=10 * units('kt'))


def test_corfidi_corfidi_llj_unaivalable():
"""Test corfidi MCS motion where the LLJ is unailable."""
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC')
with pytest.raises(ValueError):
corfidi_storm_motion(data['pressure'][6:], data['u_wind'][6:], data['v_wind'][6:])


def test_corfidi_corfidi_cloudlayer_trimmed():
"""Test corfidi MCS motion where sounding does not include the entire cloud layer."""
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC')
motion_no_top = concatenate(corfidi_storm_motion(data['pressure'][:37],
data['u_wind'][:37], data['v_wind'][:37]))
truth_no_top = [20.40419260, -21.43467629,
37.93224569, -9.99492754] * units('kt')
assert_almost_equal(motion_no_top.flatten(), truth_no_top, 8)


def test_corfidi_motion_with_nans():
"""Test corfidi MCS motion with observed sounding with nans."""
data = get_upper_air_data(datetime(2016, 5, 22, 0), 'DDC')
u_with_nans = data['u_wind']
u_with_nans[6:10] = np.nan
v_with_nans = data['v_wind']
Expand All @@ -212,14 +236,6 @@ def test_corfidi_motion():
37.14543575, -12.42974709] * units('kt')
assert_almost_equal(motion_with_nans.flatten(), truth_with_nans, 8)

with pytest.raises(ValueError):
corfidi_storm_motion(data['pressure'], data['u_wind'],
data['v_wind'], u_llj=10 * units('kt'))

with pytest.raises(ValueError):
corfidi_storm_motion(data['pressure'], data['u_wind'],
data['v_wind'], v_llj=10 * units('kt'))


def test_bunkers_motion_with_nans():
"""Test Bunkers storm motion with observed sounding."""
Expand Down

0 comments on commit 48b8e59

Please sign in to comment.