Exemplo n.º 1
0
def test_mean():
    assert_export(sc.mean, sc.Variable(), 'x')
Exemplo n.º 2
0
def test_atan2():
    var = sc.Variable()
    assert_export(sc.atan2, y=var, x=var)
    assert_export(sc.atan2, y=var, x=var, out=var)
Exemplo n.º 3
0
def test_isfinite():
    assert_export(sc.isfinite, sc.Variable())
Exemplo n.º 4
0
def test_acos():
    assert_export(sc.acos, sc.Variable())
Exemplo n.º 5
0
def test_atan():
    assert_export(sc.atan, sc.Variable())
Exemplo n.º 6
0
def test_log10():
    var = sc.Variable()
    assert_export(sc.log10, x=var)
Exemplo n.º 7
0
def test_sin_out():
    var = sc.Variable()
    assert_export(sc.sin, var, out=var)
Exemplo n.º 8
0
def test_variance_acess():
    v = sc.Variable()
    assert v.variance is None
    assert v.variances is None
Exemplo n.º 9
0
def test_create_from_numpy_1d_bool():
    var = sc.Variable(dims=['x'], values=np.array([True, False, True]))
    assert var.dtype == sc.dtype.bool
    np.testing.assert_array_equal(var.values, np.array([True, False, True]))
Exemplo n.º 10
0
def test_sqrt_out():
    var = sc.Variable()
    assert_export(sc.sqrt, var, var)
Exemplo n.º 11
0
def test_values_variances():
    assert_export(sc.values, sc.Variable())
    assert_export(sc.variances, sc.Variable())
Exemplo n.º 12
0
def test_sqrt():
    assert_export(sc.sqrt, sc.Variable())
Exemplo n.º 13
0
def test_norm():
    assert_export(sc.norm, sc.Variable())
Exemplo n.º 14
0
def test_mean_in_place():
    var = sc.Variable()
    assert_export(sc.mean, sc.Variable(), 'x', var)
Exemplo n.º 15
0
def test_reciprocal_out():
    var = sc.Variable()
    assert_export(sc.reciprocal, var, var)
Exemplo n.º 16
0
def test_sum_mean():
    var = sc.Variable(dims=['x'], values=np.arange(5, dtype=np.int64))
    assert sc.is_equal(sc.sum(var, 'x'), sc.Variable(10))
    var = sc.Variable(dims=['x'], values=np.arange(6, dtype=np.int64))
    assert sc.is_equal(sc.mean(var, 'x'), sc.Variable(2.5))
Exemplo n.º 17
0
def test_exp():
    var = sc.Variable()
    assert_export(sc.exp, x=var)
Exemplo n.º 18
0
def test_construct_0d_native_python_types():
    assert sc.Variable(2).dtype == sc.dtype.int64
    assert sc.Variable(2.0).dtype == sc.dtype.float64
    assert sc.Variable(True).dtype == sc.dtype.bool
Exemplo n.º 19
0
def test_create_scalar():
    var = sc.Variable(1.2)
    assert var.value == 1.2
    assert var.dims == []
    assert var.dtype == sc.dtype.float64
    assert var.unit == sc.units.dimensionless
Exemplo n.º 20
0
def test_construct_0d_dtype():
    assert sc.Variable(2, dtype=np.int32).dtype == sc.dtype.int32
    assert sc.Variable(np.float64(2),
                       dtype=np.float32).dtype == sc.dtype.float32
    assert sc.Variable(1, dtype=np.bool).dtype == sc.dtype.bool
Exemplo n.º 21
0
def test_asin():
    assert_export(sc.asin, sc.Variable())
Exemplo n.º 22
0
def test_rename_dims():
    values = np.arange(6).reshape(2, 3)
    xy = sc.Variable(dims=['x', 'y'], values=values)
    zy = sc.Variable(dims=['z', 'y'], values=values)
    xy.rename_dims({'x': 'z'})
    assert sc.is_equal(xy, zy)
Exemplo n.º 23
0
def test_acos_out():
    var = sc.Variable()
    assert_export(sc.acos, var, out=var)
Exemplo n.º 24
0
def test_create_1d_with_strings():
    v = sc.Variable(dims=['x'], values=["aaa", "ff", "bb"])
    assert np.all(v.values == np.array(["aaa", "ff", "bb"]))
Exemplo n.º 25
0
def test_atan_out():
    var = sc.Variable()
    assert_export(sc.atan, var, out=var)
Exemplo n.º 26
0
def test_bool_variable_repr():
    a = sc.Variable(dims=['x'],
                    values=np.array([False, True, True, False, True]))
    assert [expected in repr(a) for expected in ["True", "False", "..."]]
Exemplo n.º 27
0
def test_isnan():
    assert_export(sc.isnan, sc.Variable())
Exemplo n.º 28
0
def test_reciprocal():
    assert_export(sc.reciprocal, sc.Variable())
Exemplo n.º 29
0
def test_isneginf():
    assert_export(sc.isneginf, sc.Variable())
Exemplo n.º 30
0
def test_create_from_numpy_1d():
    var = sc.Variable(dims=['x'], values=np.arange(4.0))
    assert var.dtype == sc.dtype.float64
    np.testing.assert_array_equal(var.values, np.arange(4))