def test_store_load_complete_region_mapping(tmph5factory, connectivity_factory, surface_factory, region_mapping_factory):
    connectivity = connectivity_factory(2)
    surface = surface_factory(5)
    region_mapping = region_mapping_factory(surface, connectivity)

    with ConnectivityH5(tmph5factory('Connectivity_{}.h5'.format(connectivity.gid))) as conn_h5:
        conn_h5.store(connectivity)
        conn_stored = Connectivity()
        conn_h5.load_into(conn_stored)

    with SurfaceH5(tmph5factory('Surface_{}.h5'.format(surface.gid))) as surf_h5:
        surf_h5.store(surface)
        surf_stored = Surface()
        surf_h5.load_into(surf_stored)

    with RegionMappingH5(tmph5factory('RegionMapping_{}.h5'.format(region_mapping.gid))) as rm_h5:
        rm_h5.store(region_mapping)
        rm_stored = RegionMapping()
        rm_h5.load_into(rm_stored)

    # load_into will not load dependent datatypes. connectivity and surface are undefined
    with pytest.raises(TraitAttributeError):
        rm_stored.connectivity
    with pytest.raises(TraitAttributeError):
        rm_stored.surface

    rm_stored.connectivity = conn_stored
    rm_stored.surface = surf_stored
    assert rm_stored.connectivity is not None
    assert rm_stored.surface is not None
Example #2
0
def test_store_load_connectivity(tmph5factory, connectivity_factory):
    connectivity = connectivity_factory(2)
    conn_h5 = ConnectivityH5(tmph5factory())
    conn_h5.store(connectivity)
    conn_h5.close()

    conn_stored = Connectivity()
    with pytest.raises(TraitAttributeError):
        conn_stored.region_labels
    conn_h5.load_into(conn_stored)
    assert conn_stored.region_labels.shape[0] == 2
Example #3
0
def test_store_partial_connectivity(tmph5factory):
    partial_conn = Connectivity(
        region_labels=numpy.array(["a", "b"]),
        weights=numpy.zeros((2, 2)),
        tract_lengths=numpy.zeros((2, 2)),
        centres=numpy.zeros((2, 2)),
        number_of_regions=int(2),
        number_of_connections=int(4),
    )
    conn_h5 = ConnectivityH5(tmph5factory())
    conn_h5.store(partial_conn)
    conn_h5.close()
Example #4
0
def test_store_connectivity(tmph5factory, connectivity_factory):
    connectivity = connectivity_factory(2)
    conn_h5 = ConnectivityH5(tmph5factory())
    conn_h5.store(connectivity)
    conn_h5.close()