Code Duplication    Length = 9-10 lines in 4 locations

metpy/calc/tests/test_tools.py 4 locations

@@ 515-524 (lines=10) @@
512
513
def test_get_layer_heights_no_interpolation():
514
    """Test get_layer_heights without interpolation."""
515
    heights = np.arange(10) * units.km
516
    data = heights.m * 2 * units.degC
517
    heights, data = get_layer_heights(heights, 5000 * units.m, data,
518
                                      bottom=1500 * units.m, interpolate=False)
519
    heights_true = np.array([2, 3, 4, 5, 6]) * units.km
520
    data_true = heights_true.m * 2 * units.degC
521
    assert_array_almost_equal(heights_true, heights, 6)
522
    assert_array_almost_equal(data_true, data, 6)
523
524
525
def test_get_layer_heights_agl():
526
    """Test get_layer_heights with interpolation."""
527
    heights = np.arange(300, 1200, 100) * units.m
@@ 492-501 (lines=10) @@
489
    res = _greater_or_close(x, comparison_value)
490
    assert_array_equal(res, truth)
491
492
493
def test_less_or_close():
494
    """Test floating point less or close to."""
495
    x = np.array([0.0, 1.0, 1.49999, 1.5, 1.5000, 1.7])
496
    comparison_value = 1.5
497
    truth = np.array([True, True, True, True, True, False])
498
    res = _less_or_close(x, comparison_value)
499
    assert_array_equal(res, truth)
500
501
502
def test_get_layer_heights_interpolation():
503
    """Test get_layer_heights with interpolation."""
504
    heights = np.arange(10) * units.km
@@ 504-512 (lines=9) @@
501
502
def test_get_layer_heights_interpolation():
503
    """Test get_layer_heights with interpolation."""
504
    heights = np.arange(10) * units.km
505
    data = heights.m * 2 * units.degC
506
    heights, data = get_layer_heights(heights, 5000 * units.m, data, bottom=1500 * units.m)
507
    heights_true = np.array([1.5, 2, 3, 4, 5, 6, 6.5]) * units.km
508
    data_true = heights_true.m * 2 * units.degC
509
    assert_array_almost_equal(heights_true, heights, 6)
510
    assert_array_almost_equal(data_true, data, 6)
511
512
513
def test_get_layer_heights_no_interpolation():
514
    """Test get_layer_heights without interpolation."""
515
    heights = np.arange(10) * units.km
@@ 481-489 (lines=9) @@
478
    x_interp = np.array([1.0, 4.0])
479
    y_interp_truth = np.array([1.0, 4.0])
480
    y_interp = interp(x_interp, x, y)
481
    assert_array_almost_equal(y_interp, y_interp_truth, 7)
482
483
484
def test_greater_or_close():
485
    """Test floating point greater or close to."""
486
    x = np.array([0.0, 1.0, 1.49999, 1.5, 1.5000, 1.7])
487
    comparison_value = 1.5
488
    truth = np.array([False, False, True, True, True, True])
489
    res = _greater_or_close(x, comparison_value)
490
    assert_array_equal(res, truth)
491
492