Ejemplo n.º 1
0
def test_array_to_scalar():
    a = array_to_scalar(np.array(1))
    assert isinstance(a, int)
    assert a == 1
    b = array_to_scalar(np.array(1.5))
    assert isinstance(b, float)
    assert b == 1.5
Ejemplo n.º 2
0
def test_transpose2(x, y, axis1, axis2):
    perm = (scalar_cast(axis1, u64), scalar_cast(axis2, u64))
    xt = transpose(x, perm)
    yt = transpose(y, perm)
    d = dot(xt, yt)
    sm = array_reduce(scalar_add, d, ())
    return array_to_scalar(sm)
Ejemplo n.º 3
0
def test_transpose(x, y):
    xt = transpose(x, (1, 0))
    yt = transpose(y, (1, 0))
    d = dot(xt, yt)
    sm = array_reduce(scalar_add, d, ())
    return array_to_scalar(sm)
Ejemplo n.º 4
0
def test_dot(x, y):
    d = dot(x, y)
    sm = array_reduce(scalar_add, d, ())
    return array_to_scalar(sm)
Ejemplo n.º 5
0
def test_array_operations_std(xs, ys):
    div = xs / ys
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)
Ejemplo n.º 6
0
def test_array_operations_reshape(xs, ys):
    xs = reshape(xs, (6, ))
    ys = reshape(ys, (6, ))
    div = array_map(scalar_div, xs, ys)
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)
Ejemplo n.º 7
0
def test_array_operations_distribute(x, y):
    xs = distribute(scalar_to_array(x, AA), (4, 3))
    ys = distribute(scalar_to_array(y, AA), (4, 3))
    div = array_map(scalar_div, xs, ys)
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)
Ejemplo n.º 8
0
def test_array_operations(xs, ys):
    div = array_map(scalar_div, xs, ys)
    sm = array_reduce(scalar_add, div, ())
    return array_to_scalar(sm)
Ejemplo n.º 9
0
def test_array_to_scalar(x):
    return array_to_scalar(reshape(x, ()))