Code Duplication    Length = 13-14 lines in 5 locations

metpy/calc/tests/test_thermo.py 5 locations

@@ 437-450 (lines=14) @@
434
    assert_almost_equal(ret[2], 19.0 * units.degC, 6)
435
436
437
def test_isentropic_pressure():
438
    """Test calculation of isentropic pressure function."""
439
    lev = [100000., 95000., 90000., 85000.] * units.Pa
440
    tmp = np.ones((4, 5, 5))
441
    tmp[0, :] = 296.
442
    tmp[1, :] = 292.
443
    tmp[2, :] = 290
444
    tmp[3, :] = 288.
445
    tmpk = tmp * units.kelvin
446
    isentlev = [296.] * units.kelvin
447
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
448
    trueprs = 1000. * units.hPa
449
    assert_almost_equal(isentprs[0].shape, (1, 5, 5), 3)
450
    assert_almost_equal(isentprs[0], trueprs, 3)
451
452
453
def test_isentropic_pressure_p_increase():
@@ 561-573 (lines=13) @@
558
    assert_almost_equal(isentprs[1][1], truerh, 3)
559
560
561
def test_isentropic_pressure_tmp_out_interp():
562
    """Test calculation of isentropic pressure function, temperature output."""
563
    lev = [100000., 95000., 90000., 85000.] * units.Pa
564
    tmp = np.ones((4, 5, 5))
565
    tmp[0, :] = 296.
566
    tmp[1, :] = 292.
567
    tmp[2, :] = 290.
568
    tmp[3, :] = 288.
569
    tmpk = tmp * units.kelvin
570
    isentlev = [296., 297.] * units.kelvin
571
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, tmpk_out=True)
572
    truetmp = 291.4579 * units.kelvin
573
    assert_almost_equal(isentprs[1][1], truetmp, 3)
574
575
576
def test_isentropic_pressure_data_bounds_error():
@@ 525-537 (lines=13) @@
522
    assert_almost_equal(isentprs[1], truerh, 3)
523
524
525
def test_isentropic_pressure_interp():
526
    """Test calculation of isentropic pressure function."""
527
    lev = [100000., 95000., 90000., 85000.] * units.Pa
528
    tmp = np.ones((4, 5, 5))
529
    tmp[0, :] = 296.
530
    tmp[1, :] = 292.
531
    tmp[2, :] = 290
532
    tmp[3, :] = 288.
533
    tmpk = tmp * units.kelvin
534
    isentlev = [296., 297] * units.kelvin
535
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
536
    trueprs = 936.18057 * units.hPa
537
    assert_almost_equal(isentprs[0][1], trueprs, 3)
538
539
540
def test_isentropic_pressure_adition_args_interp():
@@ 489-501 (lines=13) @@
486
    assert_almost_equal(isentprs[1], truerh, 3)
487
488
489
def test_isentropic_pressure_tmp_out():
490
    """Test calculation of isentropic pressure function, temperature output."""
491
    lev = [100000., 95000., 90000., 85000.] * units.Pa
492
    tmp = np.ones((4, 5, 5))
493
    tmp[0, :] = 296.
494
    tmp[1, :] = 292.
495
    tmp[2, :] = 290.
496
    tmp[3, :] = 288.
497
    tmpk = tmp * units.kelvin
498
    isentlev = [296.] * units.kelvin
499
    isentprs = isentropic_interpolation(isentlev, lev, tmpk, tmpk_out=True)
500
    truetmp = 296. * units.kelvin
501
    assert_almost_equal(isentprs[1], truetmp, 3)
502
503
504
def test_isentropic_pressure_p_increase_rh_out():
@@ 453-465 (lines=13) @@
450
    assert_almost_equal(isentprs[0], trueprs, 3)
451
452
453
def test_isentropic_pressure_p_increase():
454
    """Test calculation of isentropic pressure function, p increasing order."""
455
    lev = [85000, 90000., 95000., 100000.] * units.Pa
456
    tmp = np.ones((4, 5, 5))
457
    tmp[0, :] = 288.
458
    tmp[1, :] = 290.
459
    tmp[2, :] = 292.
460
    tmp[3, :] = 296.
461
    tmpk = tmp * units.kelvin
462
    isentlev = [296.] * units.kelvin
463
    isentprs = isentropic_interpolation(isentlev, lev, tmpk)
464
    trueprs = 1000. * units.hPa
465
    assert_almost_equal(isentprs[0], trueprs, 3)
466
467
468
def test_isentropic_pressure_adition_args():