Code Duplication    Length = 9-10 lines in 4 locations

metpy/calc/tests/test_tools.py 4 locations

@@ 515-524 (lines=10) @@
512
    assert_array_almost_equal(data_true, data, 6)
513
514
515
def test_get_layer_heights_agl_bottom_no_interp():
516
    """Test get_layer_heights with no interpolation and a bottom."""
517
    heights = np.arange(300, 1200, 100) * units.m
518
    data = heights.m * 0.1 * units.degC
519
    heights, data = get_layer_heights(heights, 500 * units.m, data, with_agl=True,
520
                                      interpolation=False, bottom=200 * units.m)
521
    heights_true = np.array([0.2, 0.3, 0.4, 0.5, 0.6, 0.7]) * units.km
522
    data_true = np.array([50, 60, 70, 80, 90, 100]) * units.degC
523
    assert_array_almost_equal(heights_true, heights, 6)
524
    assert_array_almost_equal(data_true, data, 6)
525
@@ 492-501 (lines=10) @@
489
    assert_array_almost_equal(data_true, data, 6)
490
491
492
def test_get_layer_heights_no_interpolation():
493
    """Test get_layer_heights without interpolation."""
494
    heights = np.arange(10) * units.km
495
    data = heights.m * 2 * units.degC
496
    heights, data = get_layer_heights(heights, 5000 * units.m, data,
497
                                      bottom=1500 * units.m, interpolate=False)
498
    heights_true = np.array([2, 3, 4, 5, 6]) * units.km
499
    data_true = heights_true.m * 2 * units.degC
500
    assert_array_almost_equal(heights_true, heights, 6)
501
    assert_array_almost_equal(data_true, data, 6)
502
503
504
def test_get_layer_heights_agl():
@@ 504-512 (lines=9) @@
501
    assert_array_almost_equal(data_true, data, 6)
502
503
504
def test_get_layer_heights_agl():
505
    """Test get_layer_heights with interpolation."""
506
    heights = np.arange(300, 1200, 100) * units.m
507
    data = heights.m * 0.1 * units.degC
508
    heights, data = get_layer_heights(heights, 500 * units.m, data, with_agl=True)
509
    heights_true = np.array([0, 0.1, 0.2, 0.3, 0.4, 0.5]) * units.km
510
    data_true = np.array([30, 40, 50, 60, 70, 80]) * units.degC
511
    assert_array_almost_equal(heights_true, heights, 6)
512
    assert_array_almost_equal(data_true, data, 6)
513
514
515
def test_get_layer_heights_agl_bottom_no_interp():
@@ 481-489 (lines=9) @@
478
    assert_array_equal(res, truth)
479
480
481
def test_get_layer_heights_interpolation():
482
    """Test get_layer_heights with interpolation."""
483
    heights = np.arange(10) * units.km
484
    data = heights.m * 2 * units.degC
485
    heights, data = get_layer_heights(heights, 5000 * units.m, data, bottom=1500 * units.m)
486
    heights_true = np.array([1.5, 2, 3, 4, 5, 6, 6.5]) * units.km
487
    data_true = heights_true.m * 2 * units.degC
488
    assert_array_almost_equal(heights_true, heights, 6)
489
    assert_array_almost_equal(data_true, data, 6)
490
491
492
def test_get_layer_heights_no_interpolation():