def test_as_labeled():

    from mahotas.labeled import _as_labeled
    arr = np.zeros((64, 64))
    labeled = np.zeros((64, 64), dtype=np.intc)
    funcname = 'testing'

    assert _as_labeled(arr, labeled, funcname, inplace=True) is labeled
    assert _as_labeled(arr, labeled, funcname) is labeled

    lab2 = _as_labeled(arr, labeled, funcname, inplace=False)
    assert lab2 is not labeled
    assert np.all(labeled == lab2)

    assert _as_labeled(arr[::2], labeled[::2], funcname,
                       inplace=False) is not labeled
    assert _as_labeled(arr[::2], labeled[::2], funcname,
                       inplace=None) is not labeled
    assert _as_labeled(arr[::2], labeled[::2], funcname) is not labeled

    with raises(ValueError):
        _as_labeled(arr[::2], labeled[::2], funcname, inplace=True)

    with raises(ValueError):
        _as_labeled(arr[::2], labeled, funcname)
Exemplo n.º 2
0
def test_as_labeled():

    from mahotas.labeled import _as_labeled
    arr = np.zeros((64,64))
    labeled = np.zeros((64,64), dtype=np.intc)
    funcname = 'testing'

    assert _as_labeled(arr, labeled, funcname, inplace=True) is labeled
    assert _as_labeled(arr, labeled, funcname) is labeled

    lab2 = _as_labeled(arr, labeled, funcname, inplace=False)
    assert lab2 is not labeled
    assert np.all(labeled == lab2)

    assert _as_labeled(arr[::2], labeled[::2], funcname, inplace=False) is not labeled
    assert _as_labeled(arr[::2], labeled[::2], funcname, inplace=None) is not labeled
    assert _as_labeled(arr[::2], labeled[::2], funcname) is not labeled

    @raises(ValueError)
    def t():
        _as_labeled(arr[::2], labeled[::2], funcname, inplace=True)
    t()

    @raises(ValueError)
    def t():
        _as_labeled(arr[::2], labeled, funcname)
    t()
Exemplo n.º 3
0
 def t():
     _as_labeled(arr[::2], labeled, funcname)
Exemplo n.º 4
0
 def t():
     _as_labeled(arr[::2], labeled[::2], funcname, inplace=True)
Exemplo n.º 5
0
 def t():
     _as_labeled(arr[::2], labeled, funcname)
Exemplo n.º 6
0
 def t():
     _as_labeled(arr[::2], labeled[::2], funcname, inplace=True)