Exemple #1
0
def test_iter():
    imgiter = iter(gimg)
    for data in imgiter:
        yield assert_equal, data.shape, (3,2)
    tmp = Image(np.zeros(gimg.shape), gimg.coordmap)
    write_data(tmp, data_generator(gimg, range(gimg.shape[0])))
    yield assert_true, np.allclose(np.asarray(tmp), np.asarray(gimg))
    tmp = Image(np.zeros(gimg.shape), gimg.coordmap)
    g = data_generator(gimg)
    write_data(tmp, g)
    yield assert_true, np.allclose(np.asarray(tmp), np.asarray(gimg))
Exemple #2
0
def test_parcels1():
    rho = gimg
    parcelmap = np.asarray(rho).astype(np.int32)
    test = np.zeros(parcelmap.shape)
    v = 0
    for i, d in data_generator(test, parcels(parcelmap)):
        v += d.shape[0]
    yield assert_equal, v, np.product(test.shape)
Exemple #3
0
def test_parcels3():
    rho = gimg[0]
    parcelmap = np.asarray(rho).astype(np.int32)
    labels = np.unique(parcelmap)
    test = np.zeros(rho.shape)
    v = 0
    for i, d in data_generator(test, parcels(parcelmap, labels=labels)):
        v += d.shape[0]
    yield assert_equal, v, np.product(test.shape)
Exemple #4
0
def test_generator():
    gen = data_generator(gimg)
    for ind, data in gen:
        yield assert_equal, data.shape, (3,2)