Code Duplication    Length = 8-9 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

@@ 410-418 (lines=9) @@
407
    assert_array_almost_equal(x2, x_truth, 6)
408
    assert_almost_equal(y2, y_truth, 6)
409
410
411
def test_most_unstable_parcel():
412
    """Tests calculating the most unstable parcel."""
413
    levels = np.array([1000., 959., 867.9]) * units.mbar
414
    temperatures = np.array([18.2, 22.2, 17.4]) * units.celsius
415
    dewpoints = np.array([19., 19., 14.3]) * units.celsius
416
    ret = most_unstable_parcel(levels, temperatures, dewpoints, depth=100 * units.hPa)
417
    assert_almost_equal(ret[0], 959.0 * units.hPa, 6)
418
    assert_almost_equal(ret[1], 22.2 * units.degC, 6)
419
    assert_almost_equal(ret[2], 19.0 * units.degC, 6)
420
421
@@ 386-394 (lines=9) @@
383
    assert_almost_equal(cape, 0.08750805 * units('joule / kilogram'), 6)
384
    assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6)
385
386
387
def test_cape_cin_no_lfc():
388
    """Tests that CAPE is zero with no LFC."""
389
    p = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
390
    temperature = np.array([22.2, 24.6, 22., 20.4, 18., -10.]) * units.celsius
391
    dewpoint = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
392
    parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC')
393
    cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof)
394
    assert_almost_equal(cape, 0.0 * units('joule / kilogram'), 6)
395
    assert_almost_equal(cin, 0.0 * units('joule / kilogram'), 6)
396
397
@@ 179-186 (lines=8) @@
176
    with pytest.raises(RuntimeError):
177
        lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC, max_iters=2)
178
179
180
def test_lfc_basic():
181
    """Test LFC calculation."""
182
    levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
183
    temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius
184
    dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
185
    l = lfc(levels, temperatures, dewpoints)
186
    assert_almost_equal(l[0], 727.468 * units.mbar, 2)
187
    assert_almost_equal(l[1], 9.705 * units.celsius, 2)
188
189