Exemplo n.º 1
0
def test_standard_deviation07():
    labels = cp.asarray([1])
    olderr = np.seterr(all="ignore")
    try:
        for type in types:
            input = cp.asarray([-0.00619519], type)
            output = ndimage.standard_deviation(input, labels, cp.asarray([1]))
            assert_array_almost_equal(output, [0])
    finally:
        np.seterr(**olderr)
Exemplo n.º 2
0
def test_standard_deviation01():
    olderr = np.seterr(all="ignore")
    try:
        for type in types:
            input = cp.asarray([], type)
            with suppress_warnings() as sup:
                sup.filter(RuntimeWarning, "Mean of empty slice")
                output = ndimage.standard_deviation(input)
            assert_(cp.isnan(output))
    finally:
        np.seterr(**olderr)
Exemplo n.º 3
0
def test_standard_deviation06():
    labels = cp.asarray([2, 2, 3, 3, 4])
    olderr = np.seterr(all="ignore")
    try:
        for type in types:
            input = cp.asarray([1, 3, 8, 10, 8], type)
            output = ndimage.standard_deviation(input, labels,
                                                cp.asarray([2, 3, 4]))
            assert_array_almost_equal(output, [1.0, 1.0, 0.0])
    finally:
        np.seterr(**olderr)
Exemplo n.º 4
0
def test_stat_funcs_2d():
    a = cp.asarray([[5, 6, 0, 0, 0], [8, 9, 0, 0, 0], [0, 0, 0, 3, 5]])
    lbl = cp.asarray([[1, 1, 0, 0, 0], [1, 1, 0, 0, 0], [0, 0, 0, 2, 2]])

    index = cp.asarray([1, 2])
    mean = ndimage.mean(a, labels=lbl, index=index)
    assert_array_equal(mean, [7.0, 4.0])

    var = ndimage.variance(a, labels=lbl, index=index)
    assert_array_equal(var, [2.5, 1.0])

    std = ndimage.standard_deviation(a, labels=lbl, index=index)
    assert_array_almost_equal(std, cp.sqrt(cp.asarray([2.5, 1.0])))

    med = ndimage.median(a, labels=lbl, index=index)
    assert_array_equal(med, [7.0, 4.0])

    min = ndimage.minimum(a, labels=lbl, index=index)
    assert_array_equal(min, [5, 3])

    max = ndimage.maximum(a, labels=lbl, index=index)
    assert_array_equal(max, [9, 5])
Exemplo n.º 5
0
def test_standard_deviation05():
    labels = cp.asarray([2, 2, 3])
    for type in types:
        input = cp.asarray([1, 3, 8], type)
        output = ndimage.standard_deviation(input, labels, 2)
        assert_almost_equal(output, 1.0)
Exemplo n.º 6
0
def test_standard_deviation04():
    input = cp.asarray([1, 0], bool)
    output = ndimage.standard_deviation(input)
    assert_almost_equal(output, 0.5)
Exemplo n.º 7
0
def test_standard_deviation03():
    for type in types:
        input = cp.asarray([1, 3], type)
        output = ndimage.standard_deviation(input)
        assert_almost_equal(output, np.sqrt(1.0))
Exemplo n.º 8
0
def test_standard_deviation02():
    for type in types:
        input = cp.asarray([1], type)
        output = ndimage.standard_deviation(input)
        assert_almost_equal(output, 0.0)