Пример #1
0
def test_fset_vector_eval():
    str3 = odl.Strings(3)
    ints = odl.Integers()
    fset = FunctionSet(str3, ints)
    strings = np.array(['aa', 'b', 'cab', 'aba'])
    out_vec = np.empty((4, ), dtype=int)

    # Vectorized for arrays only
    f_vec = fset.element(lambda s: np.array([str(si).count('a') for si in s]))
    true_vec = [2, 0, 1, 2]

    assert f_vec('abc') == 1
    assert all_equal(f_vec(strings), true_vec)
    f_vec(strings, out=out_vec)
    assert all_equal(out_vec, true_vec)
Пример #2
0
def test_fset_init():
    str3 = odl.Strings(3)
    ints = odl.Integers()
    FunctionSet(str3, ints)