Code Duplication    Length = 8-9 lines in 3 locations

metpy/calc/tests/test_thermo.py 3 locations

@@ 410-418 (lines=9) @@
407
    assert_almost_equal(cape, 0.0 * units('joule / kilogram'), 6)
408
    assert_almost_equal(cin, 0.0 * units('joule / kilogram'), 6)
409
410
411
def test_find_append_zero_crossings():
412
    """Tests finding and appending zero crossings of an x, y series."""
413
    x = np.arange(11) * units.hPa
414
    y = np.array([3, 2, 1, -1, 2, 2, 0, 1, 0, -1, 2]) * units.degC
415
    x2, y2 = _find_append_zero_crossings(x, y)
416
417
    x_truth = np.array([0., 1., 2., 2.5, 3., 3.33333333, 4., 5.,
418
                        6., 7., 8., 9., 9.33333333, 10.]) * units.hPa
419
    y_truth = np.array([3, 2, 1, 0, -1, 0, 2, 2, 0, 1, 0, -1, 0, 2]) * units.degC
420
    assert_array_almost_equal(x2, x_truth, 6)
421
    assert_almost_equal(y2, y_truth, 6)
@@ 386-394 (lines=9) @@
383
    parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC')
384
    cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof)
385
    assert_almost_equal(cape, 58.0368212 * units('joule / kilogram'), 6)
386
    assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6)
387
388
389
def test_cape_cin_no_el():
390
    """Tests that CAPE works with no EL."""
391
    p = np.array([959., 779.2, 751.3, 724.3]) * units.mbar
392
    temperature = np.array([22.2, 14.6, 12., 9.4]) * units.celsius
393
    dewpoint = np.array([19., -11.2, -10.8, -10.4]) * units.celsius
394
    parcel_prof = parcel_profile(p, temperature[0], dewpoint[0]).to('degC')
395
    cape, cin = cape_cin(p, temperature, dewpoint, parcel_prof)
396
    assert_almost_equal(cape, 0.08750805 * units('joule / kilogram'), 6)
397
    assert_almost_equal(cin, -89.8073512 * units('joule / kilogram'), 6)
@@ 179-186 (lines=8) @@
176
        lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC, max_iters=2)
177
178
179
def test_lfc_basic():
180
    """Test LFC calculation."""
181
    levels = np.array([959., 779.2, 751.3, 724.3, 700., 269.]) * units.mbar
182
    temperatures = np.array([22.2, 14.6, 12., 9.4, 7., -49.]) * units.celsius
183
    dewpoints = np.array([19., -11.2, -10.8, -10.4, -10., -53.2]) * units.celsius
184
    l = lfc(levels, temperatures, dewpoints)
185
    assert_almost_equal(l[0], 727.468 * units.mbar, 2)
186
    assert_almost_equal(l[1], 9.705 * units.celsius, 2)
187
188
189
def test_no_lfc():