Example #1
0
def select():

    spec = Collate(*Collate.from_log(path))

    sel = Select(spec, float_keys=['cortex_density', 'retina_density'])

    data = np.random.rand(9)
    selection = (sel.retina_density > 3.0) & (sel.cortex_density > 5)

    assert set(sel[selection].tid) == set([5, 8])
    assert repr(sel.select(selection, data)) == repr(data[selection])

    list_data = [None, 3, False, object, 3.4, '32', np.int64, unicode, lambda x: x]
    list_selection = [True, True, False, True] + [False]*5
    assert repr(sel.select(list_selection, list_data)) == repr([None, 3,object])
    new_sel = Select(sel.tolist(selection), float_keys=['cortex_density', 'retina_density'])
    return new_sel