def test_invalid_edge_node_ids():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            h5f['edges/default/source_node_id'][0] = 99999
            h5f['edges/default/target_node_id'][0] = 99999
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(
                Error.FATAL,
                '/edges/default/source_node_id misses node ids in its node population: [99999]'
            ),
            Error(
                Error.FATAL,
                '/edges/default/target_node_id misses node ids in its node population: [99999]'
            ),
            Error(
                Error.FATAL,
                'Population {} edges [99999] have node ids [0 1] instead of '
                'single id 2'.format(edges_file)),
            Error(
                Error.FATAL,
                'Population {} edges [99999] have node ids [0 1] instead of '
                'single id 0'.format(edges_file)),
        }
Exemple #2
0
def test_invalid_edge_node_ids():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / "edges.h5"
        with h5py.File(edges_file, "r+") as h5f:
            h5f["edges/default/source_node_id"][0] = 99999
            h5f["edges/default/target_node_id"][0] = 99999
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(
                Error.FATAL,
                "/edges/default/source_node_id misses node ids in its node population: [99999]",
            ),
            Error(
                Error.FATAL,
                "/edges/default/target_node_id misses node ids in its node population: [99999]",
            ),
            Error(
                Error.FATAL,
                "Population {} edges [99999] have node ids [0 1] instead of "
                "single id 2".format(edges_file),
            ),
            Error(
                Error.FATAL,
                "Population {} edges [99999] have node ids [0 1] instead of "
                "single id 0".format(edges_file),
            ),
        }
Exemple #3
0
def test_no_morph_files():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / "nodes.h5"
        with h5py.File(nodes_file, "r+") as h5f:
            h5f["nodes/default/0/morphology"][0] = "noname"
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(
                Error.WARNING,
                "missing 1 files in group morphology: default/0[{}]:\n\tnoname.swc\n".format(
                    nodes_file
                ),
            )
        }

        with h5py.File(nodes_file, "r+") as h5f:
            morph = h5f["nodes/default/0/morphology"]
            morph[:] = ["noname" + str(i) for i in range(len(morph))]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(
                Error.WARNING,
                "missing 3 files in group morphology: default/0[{}]:\n\tnoname0.swc\n\t...\n".format(
                    nodes_file
                ),
            )
        }
Exemple #4
0
def test_no_edge_source_to_target():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            del h5f['edges/default/indices/source_to_target']
            del h5f['edges/default/indices/target_to_source']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'No "source_to_target" in {}'.format(edges_file)),
                          Error(Error.FATAL, 'No "target_to_source" in {}'.format(edges_file))}
Exemple #5
0
def test_no_nodes_h5():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            del h5f['nodes']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(Error.FATAL, 'No "nodes" in {}.'.format(nodes_file)),
            Error(Error.FATAL, 'No node population for "/edges/default/source_node_id"'),
            Error(Error.FATAL, 'No node population for "/edges/default/target_node_id"'),
        }
Exemple #6
0
def test_no_edge_all_node_ids():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            del h5f['nodes/default/0']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(Error.FATAL,
                  '/edges/default/source_node_id does not have node ids in its node population'),
            Error(Error.FATAL,
                  '/edges/default/target_node_id does not have node ids in its node population')}
Exemple #7
0
def test_invalid_config_nodes_file():
    with copy_circuit() as (_, config_copy_path):
        with edit_config(config_copy_path) as config:
            del config["networks"]["nodes"][0]["nodes_file"]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Invalid "nodes_file": None')}

        with edit_config(config_copy_path) as config:
            config["networks"]["nodes"][0]["nodes_file"] = "/"
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Invalid "nodes_file": /')}
Exemple #8
0
def test_invalid_config_edges_file():
    with copy_circuit() as (_, config_copy_path):
        with edit_config(config_copy_path) as config:
            del config['networks']['edges'][0]['edges_file']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Invalid "edges_file": None')}

        with edit_config(config_copy_path) as config:
            config['networks']['edges'][0]['edges_file'] = '/'
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Invalid "edges_file": /')}
Exemple #9
0
def test_no_edges_h5():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            del h5f['edges']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'No "edges" in {}.'.format(edges_file))}
Exemple #10
0
def test_invalid_edge_population_type():
    with copy_circuit() as (_, config_copy_path):
        fake_type = "fake_type"
        with edit_config(config_copy_path) as config:
            config["networks"]["edges"][0]["populations"]["default"]["type"] = fake_type
        errors = test_module.validate(str(config_copy_path), bbp_check=True)
        assert errors == {Error(Error.WARNING, "Invalid edge type: {}".format(fake_type))}
def test_no_config_edges():
    with copy_circuit() as (_, config_copy_path):
        with edit_config(config_copy_path) as config:
            del config['networks']['edges']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(Error.FATAL, 'No "edges" in config "networks"')
        }
Exemple #12
0
def test_edge_population_missing_edge_group_index_one_group():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            del h5f['edges/default/edge_group_index']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Population default of {} misses dataset {}'.
                                format(edges_file, {"edge_group_index"}))}
Exemple #13
0
def test_nodes_multi_group_wrong_group_id():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            h5f.copy('nodes/default/0', 'nodes/default/1')
            h5f['nodes/default/node_group_id'][-1] = 2
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Population /nodes/default of {} misses group(s): {}'.
                                format(nodes_file, {2}))}
Exemple #14
0
def test_edge_population_wrong_group_id():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            del h5f['edges/default/edge_group_id']
            h5f.create_dataset('edges/default/edge_group_id', data=[0, 1, 0, 0])
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Population /edges/default of {} misses group(s): {}'.
                                format(edges_file, {1}))}
Exemple #15
0
def test_explicit_edges_no_node_population_attr():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            del h5f['edges/default/source_node_id'].attrs['node_population']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(Error.FATAL,
                  'Missing "node_population" attribute for "/edges/default/source_node_id"')}
Exemple #16
0
def test_edge_population_wrong_group_index():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            del h5f['edges/default/edge_group_index']
            h5f.create_dataset('edges/default/edge_group_index', data=[0, 1, 2, 12])
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Group default/0 in file {} should have ids up to {}'.
                                format(edges_file, 12))}
Exemple #17
0
def test_edge_population_edge_group_different_length():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            del h5f['edges/default/edge_group_index']
            h5f.create_dataset('edges/default/edge_group_index', data=[0, 1, 2, 3, 4])
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL,
                                'Population {} of {} has different sizes of "group_id" and "group_index"'.
                                format('/edges/default', edges_file))}
Exemple #18
0
def test_no_template_files():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            h5f['nodes/default/0/model_template'][0] = 'hoc:noname'
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(Error.WARNING,
                  'missing 1 files in group model_template: default/0[{}]:\n\tnoname.hoc\n'
                  .format(nodes_file))}
Exemple #19
0
def test_no_morph_files():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            h5f['nodes/default/0/morphology'][0] = 'noname'
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(
            Error.WARNING,
            'missing 1 files in group morphology: default/0[{}]:\n\tnoname.swc\n'.format(
                nodes_file))}

        with h5py.File(nodes_file, 'r+') as h5f:
            morph = h5f['nodes/default/0/morphology']
            morph[:] = ['noname' + str(i) for i in range(len(morph))]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(
            Error.WARNING,
            'missing 3 files in group morphology: default/0[{}]:\n\tnoname0.swc\n\t...\n'.format(
                nodes_file))}
Exemple #20
0
def test_no_rotation_bio_node_group_datasets():
    angle_datasets = ['rotation_angle_xaxis', 'rotation_angle_yaxis', 'rotation_angle_zaxis']
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            for ds in angle_datasets:
                del h5f['nodes/default/0/' + ds]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.WARNING,
                                'Group default/0 of {} has no rotation fields'.format(nodes_file))}
Exemple #21
0
def test_no_rotation_bio_node_group_datasets():
    angle_datasets = ["rotation_angle_xaxis", "rotation_angle_yaxis", "rotation_angle_zaxis"]
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / "nodes.h5"
        with h5py.File(nodes_file, "r+") as h5f:
            for ds in angle_datasets:
                del h5f["nodes/default/0/" + ds]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(Error.WARNING, "Group default/0 of {} has no rotation fields".format(nodes_file))
        }
Exemple #22
0
def test_no_required_edge_population_datasets_one_group():
    required_datasets = sorted([
        'edge_type_id', 'source_node_id', 'target_node_id'])
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / 'edges.h5'
        with h5py.File(edges_file, 'r+') as h5f:
            for ds in required_datasets:
                del h5f['edges/default/' + ds]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Population default of {} misses datasets {}'.
                                format(edges_file, required_datasets))}
Exemple #23
0
def test_no_required_node_multi_group_datasets():
    required_datasets = ['node_group_id', 'node_group_index']
    for ds in required_datasets:
        with copy_circuit() as (circuit_copy_path, config_copy_path):
            nodes_file = circuit_copy_path / 'nodes.h5'
            with h5py.File(nodes_file, 'r+') as h5f:
                del h5f['nodes/default/' + ds]
                h5f.copy('nodes/default/0', 'nodes/default/1')
            errors = test_module.validate(str(config_copy_path))
            assert errors == {Error(Error.FATAL, 'Population default of {} misses datasets {}'.
                                    format(nodes_file, [ds]))}
Exemple #24
0
def test_no_required_bio_node_group_datasets():
    required_datasets = sorted(['morphology', 'x', 'y', 'z'])
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            for ds in required_datasets:
                del h5f['nodes/default/0/' + ds]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL,
                                'Group default/0 of {} misses biophysical fields: {}'
                                .format(nodes_file, required_datasets))}
Exemple #25
0
def test_no_required_node_group_datasets():
    required_datasets = ['model_template', 'model_type']
    for ds in required_datasets:
        with copy_circuit() as (circuit_copy_path, config_copy_path):
            nodes_file = circuit_copy_path / 'nodes.h5'
            with h5py.File(nodes_file, 'r+') as h5f:
                del h5f['nodes/default/0/' + ds]
            errors = test_module.validate(str(config_copy_path))
            assert errors == {Error(Error.FATAL,
                                    'Group default/0 of {} misses "{}" field'
                                    .format(nodes_file, ds))}
Exemple #26
0
def test_edges_population_not_found_in_h5():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / "edges.h5"
        with edit_config(config_copy_path) as config:
            config["networks"]["edges"][0]["populations"]["fake_population"] = {}
        errors = test_module.validate(str(config_copy_path), bbp_check=True)
        assert errors == {
            Error(
                Error.FATAL,
                "populations not found in {}:\n{}".format(edges_file, "\tfake_population\n"),
            )
        }
Exemple #27
0
def test_no_config_edges_population():
    with copy_circuit() as (_, config_copy_path):
        expected = {Error(Error.FATAL, 'No "populations" defined in config "edges"')}
        with edit_config(config_copy_path) as config:
            del config["networks"]["edges"][0]["populations"]["default"]
        errors = test_module.validate(str(config_copy_path), bbp_check=True)
        assert errors == expected

        with edit_config(config_copy_path) as config:
            del config["networks"]["edges"][0]["populations"]
        errors = test_module.validate(str(config_copy_path), bbp_check=True)
        assert errors == expected
Exemple #28
0
def test_edge_population_missing_edge_group_id_one_group():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        edges_file = circuit_copy_path / "edges.h5"
        with h5py.File(edges_file, "r+") as h5f:
            del h5f["edges/default/edge_group_id"]
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(
                Error.FATAL,
                "Population default of {} misses dataset {}".format(edges_file, {"edge_group_id"}),
            )
        }
Exemple #29
0
def test_nodes_multi_group_wrong_group_id():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / "nodes.h5"
        with h5py.File(nodes_file, "r+") as h5f:
            h5f.copy("nodes/default/0", "nodes/default/1")
            h5f["nodes/default/node_group_id"][-1] = 2
        errors = test_module.validate(str(config_copy_path))
        assert errors == {
            Error(
                Error.FATAL,
                "Population /nodes/default of {} misses group(s): {}".format(nodes_file, {2}),
            )
        }
Exemple #30
0
def test_no_required_node_single_population_datasets():
    with copy_circuit() as (circuit_copy_path, config_copy_path):
        nodes_file = circuit_copy_path / 'nodes.h5'
        with h5py.File(nodes_file, 'r+') as h5f:
            del h5f['nodes/default2/']
            del h5f['nodes/default/node_group_id']
            del h5f['nodes/default/node_group_index']
        errors = test_module.validate(str(config_copy_path))
        assert errors == set()
        with h5py.File(nodes_file, 'r+') as h5f:
            del h5f['nodes/default/node_type_id']
        errors = test_module.validate(str(config_copy_path))
        assert errors == {Error(Error.FATAL, 'Population default of {} misses datasets {}'.
                                format(nodes_file, ['node_type_id']))}