Code Duplication    Length = 8-10 lines in 3 locations

metpy/calc/tests/test_tools.py 3 locations

@@ 333-340 (lines=8) @@
330
    y = np.arange(9) * units.degC
331
    with pytest.raises(ValueError):
332
        get_layer(p, y)
333
334
335
def test_get_layer_invalid_depth_units():
336
    """Tests that error is raised when depth has invalid units."""
337
    p = np.arange(10) * units.hPa
338
    y = np.arange(9) * units.degC
339
    with pytest.raises(ValueError):
340
        get_layer(p, y, depth=400 * units.degC)
341
342
343
@pytest.fixture
@@ 323-330 (lines=8) @@
320
321
    p_layer, hgt_layer = get_layer(p[::-1], hgt[::-1], heights=hgt[::-1],
322
                                   depth=1000. * units.meter)
323
    assert_array_almost_equal(p_layer, true_p_layer, 4)
324
    assert_array_almost_equal(hgt_layer, true_hgt_layer, 4)
325
326
327
def test_get_layer_ragged_data():
328
    """Tests that error is raised for unequal length pressure and data arrays."""
329
    p = np.arange(10) * units.hPa
330
    y = np.arange(9) * units.degC
331
    with pytest.raises(ValueError):
332
        get_layer(p, y)
333
@@ 343-352 (lines=10) @@
340
        get_layer(p, y, depth=400 * units.degC)
341
342
343
@pytest.fixture
344
def layer_test_data():
345
    """Provide test data for testing of layer bounds."""
346
    pressure = np.arange(1000, 10, -100) * units.hPa
347
    temperature = np.linspace(25, -50, len(pressure)) * units.degC
348
    return pressure, temperature
349
350
351
@pytest.mark.parametrize('pressure, variable, heights, bottom, depth, interp, expected', [
352
    (layer_test_data()[0], layer_test_data()[1], None, None, 150 * units.hPa, True,
353
     (np.array([1000, 900, 850]) * units.hPa,
354
      np.array([25.0, 16.666666, 12.62262]) * units.degC)),
355
    (layer_test_data()[0], layer_test_data()[1], None, None, 150 * units.hPa, False,