Code Duplication    Length = 8-9 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

@@ 410-418 (lines=9) @@
407
408
def test_find_append_zero_crossings():
409
    """Tests finding and appending zero crossings of an x, y series."""
410
    x = np.arange(11) * units.hPa
411
    y = np.array([3, 2, 1, -1, 2, 2, 0, 1, 0, -1, 2]) * units.degC
412
    x2, y2 = _find_append_zero_crossings(x, y)
413
414
    x_truth = np.array([0., 1., 2., 2.5, 3., 3.33333333, 4., 5.,
415
                        6., 7., 8., 9., 9.33333333, 10.]) * units.hPa
416
    y_truth = np.array([3, 2, 1, 0, -1, 0, 2, 2, 0, 1, 0, -1, 0, 2]) * units.degC
417
    assert_array_almost_equal(x2, x_truth, 6)
418
    assert_almost_equal(y2, y_truth, 6)
419
420
421
def test_most_unstable_parcel():
@@ 386-394 (lines=9) @@
383
    assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6)
384
385
386
def test_cape_cin_no_el():
387
    """Tests that CAPE works with no EL."""
388
    p = np.array([959., 779.2, 751.3, 724.3]) * units.mbar
389
    temperature = np.array([22.2, 14.6, 12., 9.4]) * units.celsius
390
    dewpoint = np.array([19., -11.2, -10.8, -10.4]) * units.celsius
391
    parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC')
392
    cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof)
393
    assert_almost_equal(cape, 0.08750805 * units('joule / kilogram'), 6)
394
    assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6)
395
396
397
def test_cape_cin_no_lfc():
@@ 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