Beispiel #1
0
def test_constant_norm(fn, exponent):
    xarr, x = _vectors(fn)

    constant = 1.5
    if exponent == float('inf'):
        factor = constant
    else:
        factor = constant ** (1 / exponent)
    true_norm = factor * np.linalg.norm(xarr, ord=exponent)

    w_const = FnConstWeighting(constant, exponent=exponent)
    assert almost_equal(w_const.norm(x), true_norm)

    # With free function
    w_const_norm = weighted_norm(constant, exponent=exponent)
    assert almost_equal(w_const_norm(x), true_norm)
Beispiel #2
0
def test_constant_norm(fn, exponent):
    xarr, x = example_vectors(fn)

    constant = 1.5
    if exponent == float('inf'):
        factor = constant
    else:
        factor = constant**(1 / exponent)
    true_norm = factor * np.linalg.norm(xarr, ord=exponent)

    w_const = FnConstWeighting(constant, exponent=exponent)
    assert almost_equal(w_const.norm(x), true_norm)

    # With free function
    w_const_norm = weighted_norm(constant, exponent=exponent)
    assert almost_equal(w_const_norm(x), true_norm)