Code Duplication    Length = 13-13 lines in 4 locations

metpy/calc/tests/test_turbulence.py 4 locations

@@ 406-418 (lines=13) @@
403
                        axis=0), u_star_true['uwvw'])
404
405
406
def test_u_star_2d_axis_first_nonzero_mean(uvw_and_known_u_star_nonzero_mean):
407
    """Test friction velocity in 2D with a non-zero-mean time series along the first axis."""
408
    u, v, w, u_star_true = uvw_and_known_u_star_nonzero_mean
409
    u = np.array([u, u, u]).transpose()
410
    v = np.array([v, v, v]).transpose()
411
    w = np.array([w, w, w]).transpose()
412
    for key in u_star_true.keys():
413
        tmp = u_star_true[key]
414
        u_star_true[key] = np.array([tmp, tmp, tmp]).transpose()
415
    assert_almost_equal(friction_velocity(u, w, perturbation=False,
416
                        axis=0), u_star_true['uw'])
417
    assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False,
418
                        axis=0), u_star_true['uwvw'])
419
@@ 391-403 (lines=13) @@
388
                        axis=-1), u_star_true['uwvw'])
389
390
391
def test_u_star_2d_axis_first_zero_mean(uvw_and_known_u_star_zero_mean):
392
    """Test friction velocity in 2D with a zero-mean time series along the first axis."""
393
    u, v, w, u_star_true = uvw_and_known_u_star_zero_mean
394
    u = np.array([u, u, u]).transpose()
395
    v = np.array([v, v, v]).transpose()
396
    w = np.array([w, w, w]).transpose()
397
    for key in u_star_true.keys():
398
        tmp = u_star_true[key]
399
        u_star_true[key] = np.array([tmp, tmp, tmp]).transpose()
400
    assert_almost_equal(friction_velocity(u, w, perturbation=False,
401
                        axis=0), u_star_true['uw'])
402
    assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False,
403
                        axis=0), u_star_true['uwvw'])
404
405
406
def test_u_star_2d_axis_first_nonzero_mean(uvw_and_known_u_star_nonzero_mean):
@@ 376-388 (lines=13) @@
373
                        axis=-1), u_star_true['uwvw'])
374
375
376
def test_u_star_2d_axis_last_nonzero_mean(uvw_and_known_u_star_nonzero_mean):
377
    """Test friction velocity in 2D with a non-zero-mean time series along the last axis."""
378
    u, v, w, u_star_true = uvw_and_known_u_star_nonzero_mean
379
    u = np.array([u, u, u])
380
    v = np.array([v, v, v])
381
    w = np.array([w, w, w])
382
    for key in u_star_true.keys():
383
        tmp = u_star_true[key]
384
        u_star_true[key] = np.array([tmp, tmp, tmp])
385
    assert_almost_equal(friction_velocity(u, w, perturbation=False,
386
                        axis=-1), u_star_true['uw'])
387
    assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False,
388
                        axis=-1), u_star_true['uwvw'])
389
390
391
def test_u_star_2d_axis_first_zero_mean(uvw_and_known_u_star_zero_mean):
@@ 361-373 (lines=13) @@
358
                        u_star_true['uwvw'])
359
360
361
def test_u_star_2d_axis_last_zero_mean(uvw_and_known_u_star_zero_mean):
362
    """Test friction velocity in 2D with a zero-mean time series along the last axis."""
363
    u, v, w, u_star_true = uvw_and_known_u_star_zero_mean
364
    u = np.array([u, u, u])
365
    v = np.array([v, v, v])
366
    w = np.array([w, w, w])
367
    for key in u_star_true.keys():
368
        tmp = u_star_true[key]
369
        u_star_true[key] = np.array([tmp, tmp, tmp])
370
    assert_almost_equal(friction_velocity(u, w, perturbation=False,
371
                        axis=-1), u_star_true['uw'])
372
    assert_almost_equal(friction_velocity(u, w, v=v, perturbation=False,
373
                        axis=-1), u_star_true['uwvw'])
374
375
376
def test_u_star_2d_axis_last_nonzero_mean(uvw_and_known_u_star_nonzero_mean):