Code Duplication    Length = 8-9 lines in 4 locations

metpy/calc/tests/test_thermo.py 4 locations

@@ 410-418 (lines=9) @@
407
def test_mixing_ratio_from_specific_humidity():
408
    """Tests mixing ratio from specific humidity."""
409
    q = 0.012
410
    w = mixing_ratio_from_specific_humidity(q)
411
    assert_almost_equal(w, 0.01215, 3)
412
413
414
def test_rh_specific_humidity():
415
    """Tests relative humidity from specific humidity."""
416
    p = 1013.25 * units.mbar
417
    temperature = 20. * units.degC
418
    q = 0.012
419
    rh = relative_humidity_from_specific_humidity(q, temperature, p)
420
    assert_almost_equal(rh, 82.7145 * units.percent, 3)
421
@@ 386-394 (lines=9) @@
383
    assert_almost_equal(psychrometric_rh, 82.8747 * units.percent, 3)
384
385
386
def test_wet_psychrometric_rh_kwargs():
387
    """Test calculation of relative humidity from wet and dry bulb temperatures."""
388
    p = 1013.25 * units.mbar
389
    dry_bulb_temperature = 20. * units.degC
390
    wet_bulb_temperature = 18. * units.degC
391
    coeff = 6.1e-4 / units.kelvin
392
    psychrometric_rh = relative_humidity_wet_psychrometric(dry_bulb_temperature,
393
                                                           wet_bulb_temperature, p,
394
                                                           psychrometer_coefficient=coeff)
395
    assert_almost_equal(psychrometric_rh, 82.9701 * units.percent, 3)
396
397
@@ 179-186 (lines=8) @@
176
def test_vapor_pressure():
177
    """Test vapor pressure calculation."""
178
    assert_almost_equal(vapor_pressure(998. * units.mbar, 0.04963),
179
                        73.74925 * units.mbar, 5)
180
181
182
def test_lcl():
183
    """Test LCL calculation."""
184
    lcl_pressure, lcl_temperature = lcl(1000. * units.mbar, 30. * units.degC, 20. * units.degC)
185
    assert_almost_equal(lcl_pressure, 864.761 * units.mbar, 2)
186
    assert_almost_equal(lcl_temperature, 17.676 * units.degC, 2)
187
188
189
def test_lcl_convergence():
@@ 364-372 (lines=9) @@
361
    el_pressure, el_temperature = el(levels, temperatures, dewpoints)
362
    assert assert_nan(el_pressure, levels.units)
363
    assert assert_nan(el_temperature, temperatures.units)
364
365
366
def test_wet_psychrometric_vapor_pressure():
367
    """Test calculation of vapor pressure from wet and dry bulb temperatures."""
368
    p = 1013.25 * units.mbar
369
    dry_bulb_temperature = 20. * units.degC
370
    wet_bulb_temperature = 18. * units.degC
371
    psychrometric_vapor_pressure = psychrometric_vapor_pressure_wet(dry_bulb_temperature,
372
                                                                    wet_bulb_temperature, p)
373
    assert_almost_equal(psychrometric_vapor_pressure, 19.3673 * units.mbar, 3)
374
375