Beispiel #1
0
def test_csa_one_to_one_connector():
    unittest_setup()
    connector = CSAConnector(csa.oneToOne)
    weight = 1.0
    delay = 2.0
    synapse_info = SynapseInformation(connector=None,
                                      pre_population=MockPopulation(10, "Pre"),
                                      post_population=MockPopulation(
                                          10, "Post"),
                                      prepop_is_view=False,
                                      postpop_is_view=False,
                                      rng=None,
                                      synapse_dynamics=None,
                                      synapse_type=None,
                                      receptor_type=None,
                                      is_virtual_machine=False,
                                      synapse_type_from_dynamics=False,
                                      weights=weight,
                                      delays=delay)
    connector.set_projection_information(synapse_info)
    pre_vertex_slice = Slice(0, 10)
    post_vertex_slice = Slice(0, 10)
    block = connector.create_synaptic_block([pre_vertex_slice],
                                            [post_vertex_slice],
                                            pre_vertex_slice,
                                            post_vertex_slice, 0, synapse_info)
    assert (len(block) > 0)
    assert (all(item["source"] == item["target"] for item in block))
    assert (all(item["weight"] == 1.0 for item in block))
    assert (all(item["delay"] == 2.0 for item in block))
Beispiel #2
0
def test_setting_state_variables():
    unittest_setup()

    @defaults
    class _AClass(object):
        @default_parameters({"param_1"})
        def __init__(self, param_1=1, param_2=2, param_3=3):
            pass

    @defaults
    class _AnotherClass(object):
        @default_initial_values({"param_1"})
        def __init__(self, param_1=1, param_2=2, param_3=3):
            pass

    with LogCapture() as lc:
        _AClass(param_1=1)
        _check_warnings(lc, [], ["param_1", "param_2", "param_3"])
    with LogCapture() as lc:
        _AClass(param_2=2)
        _check_warnings(lc, ["param_2"], ["param_1", "param_3"])
    with LogCapture() as lc:
        _AClass(param_3=3)
        _check_warnings(lc, ["param_3"], ["param_1", "param_2"])

    with LogCapture() as lc:
        _AnotherClass(param_1=1)
        _check_warnings(lc, ["param_1"], ["param_2", "param_3"])
    with LogCapture() as lc:
        _AnotherClass(param_2=2)
        _check_warnings(lc, [], ["param_1", "param_2", "param_3"])
    with LogCapture() as lc:
        _check_warnings(lc, [], ["param_1", "param_2", "param_3"])
        _AnotherClass(param_3=3)
Beispiel #3
0
def test_csa_random_connector():
    unittest_setup()
    connector = CSAConnector(csa.random(0.05))
    weight = 1.0
    delay = 2.0
    mock_synapse_info = SynapseInformation(
        connector=None,
        pre_population=MockPopulation(10, "Pre"),
        post_population=MockPopulation(10, "Post"),
        prepop_is_view=False,
        postpop_is_view=False,
        rng=None,
        synapse_dynamics=None,
        synapse_type=None,
        is_virtual_machine=False,
        weights=weight,
        delays=delay)
    connector.set_projection_information(mock_synapse_info)
    pre_vertex_slice = Slice(0, 10)
    post_vertex_slice = Slice(0, 10)
    block = connector.create_synaptic_block([pre_vertex_slice],
                                            [post_vertex_slice],
                                            pre_vertex_slice,
                                            post_vertex_slice, 0,
                                            mock_synapse_info)
    assert (len(block) >= 0)
    assert (all(item["weight"] == 1.0 for item in block))
    assert (all(item["delay"] == 2.0 for item in block))
def test_get_max_synapses():
    unittest_setup()
    spynnaker8.setup()
    d = SynapseDynamicsSTDP(timing_dependence=TimingDependenceSpikePair(),
                            weight_dependence=WeightDependenceAdditive(),
                            pad_to_length=258)
    assert d.get_max_synapses(256) <= 256
Beispiel #5
0
def test_init_bad():
    unittest_setup()
    neuron = MockNeuron()
    with pytest.raises(KeyError):
        neuron.get_initial_value("badvariable")
    with pytest.raises(KeyError):
        assert 1 == neuron.initialize("anotherbad", "junk")
Beispiel #6
0
def test_abstract():
    unittest_setup()

    class BaseClass(object, metaclass=AbstractBase):
        @abstractproperty
        @staticmethod
        def default_parameters():
            pass

        @abstractproperty
        @staticmethod
        def default_initial_values():
            pass

    @defaults
    class _AClass(BaseClass):

        default_parameters = None
        default_initial_values = None

        def __init__(self, param="test"):
            pass

    assert (_AClass.default_parameters == {"param": "test"})
    assert (_AClass.default_initial_values == {})
    _AClass()
Beispiel #7
0
def test_csa_from_list_connector():
    unittest_setup()
    conn_list = [(i, i + 1 % 10) for i in range(10)]
    connector = CSAConnector(conn_list)
    weight = 1.0
    delay = 2.0
    mock_synapse_info = SynapseInformation(
        connector=None,
        pre_population=MockPopulation(10, "Pre"),
        post_population=MockPopulation(10, "Post"),
        prepop_is_view=False,
        postpop_is_view=False,
        rng=None,
        synapse_dynamics=None,
        synapse_type=None,
        is_virtual_machine=False,
        weights=weight,
        delays=delay)
    connector.set_projection_information(mock_synapse_info)
    pre_vertex_slice = Slice(0, 10)
    post_vertex_slice = Slice(0, 10)
    block = connector.create_synaptic_block([pre_vertex_slice],
                                            [post_vertex_slice],
                                            pre_vertex_slice,
                                            post_vertex_slice, 0,
                                            mock_synapse_info)
    assert (len(block) > 0)
    assert (all(item["source"] == conn[0]
                for item, conn in zip(block, conn_list)))
    assert (all(item["target"] == conn[1]
                for item, conn in zip(block, conn_list)))
    assert (all(item["weight"] == 1.0 for item in block))
    assert (all(item["delay"] == 2.0 for item in block))
Beispiel #8
0
def test_initial_values():
    unittest_setup()
    neuron = MockNeuron()
    initial_values = neuron.initial_values
    assert "foo" in initial_values
    assert "bar" in initial_values
    initial_values = neuron.get_initial_values(selector=3)
    assert {"foo": [1], "bar": [11]} == initial_values
Beispiel #9
0
def test_initializable():
    unittest_setup()
    neuron = MockNeuron()
    assert [1, 1, 1, 1, 1] == neuron.get_initial_value("foo")
    neuron.initialize("foo", 2)
    assert [2, 2, 2, 2, 2] == neuron.get_initial_value("foo_init")
    assert [11, 11, 11, 11, 11] == neuron.get_initial_value("bar_init")
    assert [11, 11, 11, 11, 11] == neuron.get_initial_value("bar")
def test_max_atoms_per_core():
    unittest_setup()
    _MyPyNNModelImpl.set_model_max_atoms_per_core(100)
    _MyNeuronModelImpl.set_model_max_atoms_per_core(20)
    _MyOtherNeuronModel.set_model_max_atoms_per_core(50)
    assert (_MyPyNNModelImpl.get_max_atoms_per_core() == 100)
    assert (_MyNeuronModelImpl.get_max_atoms_per_core() == 20)
    assert (_MyOtherNeuronModel.get_max_atoms_per_core() == 50)
Beispiel #11
0
def test_connector_split():
    unittest_setup()
    n_sources = 1000
    n_targets = 1000
    n_connections = 10000
    pre_neurons_per_core = 57
    post_neurons_per_core = 59
    sources = numpy.random.randint(0, n_sources, n_connections)
    targets = numpy.random.randint(0, n_targets, n_connections)
    pre_slices = [
        Slice(i, i + pre_neurons_per_core - 1)
        for i in range(0, n_sources, pre_neurons_per_core)
    ]
    post_slices = [
        Slice(i, i + post_neurons_per_core - 1)
        for i in range(0, n_targets, post_neurons_per_core)
    ]

    connection_list = numpy.dstack((sources, targets))[0]
    connector = MockFromListConnector(connection_list)
    weight = 1.0
    delay = 1.0
    synapse_info = SynapseInformation(
        connector=None,
        pre_population=MockPopulation(n_sources, "Pre"),
        post_population=MockPopulation(n_targets, "Post"),
        prepop_is_view=False,
        postpop_is_view=False,
        rng=None,
        synapse_dynamics=None,
        synapse_type=None,
        is_virtual_machine=False,
        weights=weight,
        delays=delay)
    has_block = set()
    try:
        # Check each connection is in the right place
        for pre_slice in pre_slices:
            for post_slice in post_slices:
                block = connector.create_synaptic_block(
                    pre_slices, post_slices, pre_slice, post_slice, 1,
                    synapse_info)
                for source in block["source"]:
                    assert (pre_slice.lo_atom <= source <= pre_slice.hi_atom)
                for target in block["target"]:
                    assert (post_slice.lo_atom <= target <= post_slice.hi_atom)
                for item in block:
                    has_block.add((item["source"], item["target"]))

        # Check each connection has a place
        for source, target in zip(sources, targets):
            assert (source, target) in has_block

        # Check the split only happens once
        assert connector._split_count == 1
    except AssertionError as e:
        print(connection_list)
        raise e
def test_reset_max_atoms_per_core():
    unittest_setup()
    _MyNeuronModelImpl.set_model_max_atoms_per_core(20)
    _MyNeuronModelImpl.set_model_max_atoms_per_core()
    _MyPyNNModelImpl.set_model_max_atoms_per_core(100)
    _MyPyNNModelImpl.set_model_max_atoms_per_core()
    assert (_MyNeuronModelImpl.get_max_atoms_per_core() ==
            DEFAULT_MAX_ATOMS_PER_CORE)
    assert (_MyPyNNModelImpl.get_max_atoms_per_core() == sys.maxsize)
Beispiel #13
0
def test_connection_holder_matrix_multiple_items():
    unittest_setup()
    data_items = ["source", "target", "delay", "weight"]
    connection_holder = ConnectionHolder(data_items_to_return=data_items,
                                         as_list=False,
                                         n_pre_atoms=2,
                                         n_post_atoms=2)
    connections = numpy.array([(0, 0, 1, 10), (0, 0, 2, 20), (0, 1, 3, 30)],
                              AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE)
    connection_holder.add_connections(connections)
Beispiel #14
0
def test_init_by_in():
    unittest_setup()
    neuron = MockNeuron()
    assert [1, 1, 1, 1, 1] == neuron.get_initial_value("foo")
    neuron.initialize(variable="foo", value=11, selector=1)
    assert [1, 11, 1, 1, 1] == neuron.get_initial_value("foo")
    neuron.initialize(variable="foo", value=12, selector=2)
    assert [1, 11, 12, 1, 1] == neuron.get_initial_value("foo")
    assert [11] == neuron.get_initial_value("bar", selector=1)
    assert [12] == neuron.get_initial_value("foo", selector=2)
Beispiel #15
0
def test_state_variables():
    unittest_setup()

    @defaults
    class _AClass(object):
        @default_initial_values({"param_1"})
        def __init__(self, param_1=1, param_2=2, param_3=3):
            pass

    assert (_AClass.default_initial_values == {"param_1": 1})
    assert (_AClass.default_parameters == {"param_2": 2, "param_3": 3})
Beispiel #16
0
def test_nothing():
    unittest_setup()

    @defaults
    class _AClass(object):
        def __init__(self, param_1=1, param_2=2, param_3=3):
            pass

    assert (_AClass.default_parameters == {
        "param_1": 1,
        "param_2": 2,
        "param_3": 3
    })
    assert (_AClass.default_initial_values == {})
Beispiel #17
0
def test_recording_variables():
    unittest_setup()
    recordables = ["v", "gsyn_exc", "gsyn_inh"]

    data_types = {
        "v": DataType.S1615,
        "gsyn_exc": DataType.S1615,
        "gsyn_inh": DataType.S1615
    }

    nr = NeuronRecorder(recordables, data_types, [], 100, [], [], [], [])
    assert([] == nr.recording_variables)
    nr.set_recording("v", True)
    nr.set_recording("gsyn_inh", True)
    assert(["v", "gsyn_inh"] == nr.recording_variables)
    assert([0, 2] == nr.recorded_region_ids)
Beispiel #18
0
def test_simple_record():
    unittest_setup()
    recordables = ["v", "gsyn_exc", "gsyn_inh"]

    data_types = {
        "v": DataType.S1615,
        "gsyn_exc": DataType.S1615,
        "gsyn_inh": DataType.S1615
    }

    nr = NeuronRecorder(recordables, data_types, [], 100, [], [], [], [])
    assert(frozenset(["v", "gsyn_exc", "gsyn_inh"]) ==
           frozenset(nr.get_recordable_variables()))
    assert([] == nr.recording_variables)
    nr.set_recording("v", True)
    assert(["v"] == nr.recording_variables)
Beispiel #19
0
def test_could_connect():
    unittest_setup()
    connector = FromListConnector([[0, 0], [1, 2], [2, 0], [3, 3], [2, 6],
                                   [1, 8], [4, 1], [5, 0], [6, 2], [4, 8]])
    pre_slices = [Slice(0, 3), Slice(4, 6), Slice(7, 9)]
    post_slices = [Slice(0, 2), Slice(3, 5), Slice(6, 9)]
    for pre_slice in pre_slices:
        pre_vertex = MockMachineVertex(pre_slice, pre_slices)
        for post_slice in post_slices:
            post_vertex = MockMachineVertex(post_slice, post_slices)
            count = connector.get_n_connections(pre_slices, post_slices,
                                                pre_slice.hi_atom,
                                                post_slice.hi_atom)
            if count:
                assert (connector.could_connect(None, pre_vertex, post_vertex))
            else:
                assert (not connector.could_connect(None, pre_vertex,
                                                    post_vertex))
def test_slices():
    unittest_setup()
    app_edge = ProjectionApplicationEdge(None, None, None)
    mv0_2 = SimpleMachineVertex(None, None, None, None, Slice(0, 1))
    mv2_4 = SimpleMachineVertex(None, None, None, None, Slice(2, 3))
    mv4_6 = SimpleMachineVertex(None, None, None, None, Slice(4, 5))
    app_edge.remember_associated_machine_edge(MachineEdge(mv0_2, mv2_4))
    app_edge.remember_associated_machine_edge(MachineEdge(mv4_6, mv0_2))
    app_edge.remember_associated_machine_edge(MachineEdge(mv0_2, mv2_4))
    assert app_edge.pre_slices == [Slice(0, 1), Slice(4, 5)]
    post1 = app_edge.post_slices
    assert post1 == [Slice(0, 1), Slice(2, 3)]
    app_edge.remember_associated_machine_edge(MachineEdge(mv0_2, mv0_2))
    app_edge.remember_associated_machine_edge(MachineEdge(mv2_4, mv2_4))
    assert app_edge.pre_slices == [Slice(0, 1), Slice(2, 3), Slice(4, 5)]
    post2 = app_edge.post_slices
    assert post1 == post2
    assert id(post1) != id(post2)
Beispiel #21
0
def test_connector(clist, column_names, weights, delays, expected_clist,
                   expected_weights, expected_delays,
                   expected_extra_parameters, expected_extra_parameter_names):
    unittest_setup()
    connector = FromListConnector(clist, column_names=column_names)
    if expected_clist is not None:
        assert (numpy.array_equal(connector.conn_list, expected_clist))
    else:
        assert (numpy.array_equal(connector.conn_list, clist))

    # Check extra parameters are as expected
    extra_params = connector.get_extra_parameters()
    extra_param_names = connector.get_extra_parameter_names()
    assert (numpy.array_equal(extra_params, expected_extra_parameters))
    assert (numpy.array_equal(extra_param_names,
                              expected_extra_parameter_names))
    if extra_params is not None:
        assert (len(extra_params.shape) == 2)
        assert (extra_params.shape[1] == len(extra_param_names))
        for i in range(len(extra_param_names)):
            assert (extra_params[:, i].shape == (len(clist), ))

    # Check weights and delays are used or ignored as expected
    pre_slice = Slice(0, 10)
    post_slice = Slice(0, 10)
    synapse_info = SynapseInformation(connector=None,
                                      pre_population=MockPopulation(10, "Pre"),
                                      post_population=MockPopulation(
                                          10, "Post"),
                                      prepop_is_view=False,
                                      postpop_is_view=False,
                                      rng=None,
                                      synapse_dynamics=None,
                                      synapse_type=None,
                                      is_virtual_machine=False,
                                      weights=weights,
                                      delays=delays)
    block = connector.create_synaptic_block([pre_slice], [post_slice],
                                            pre_slice, post_slice, 1,
                                            synapse_info)
    assert (numpy.array_equal(block["weight"], numpy.array(expected_weights)))
    assert (numpy.array_equal(block["delay"], numpy.array(expected_delays)))
Beispiel #22
0
def test_csa_block_connector():
    unittest_setup()
    try:
        # This creates a block of size (2, 5) with a probability of 0.5; then
        # within the block an individual connection has a probability of 0.3
        connector = CSAConnector(
            csa.block(2, 5) * csa.random(0.5) * csa.random(0.3))
        weight = 1.0
        delay = 2.0
        mock_synapse_info = SynapseInformation(
            connector=None,
            pre_population=MockPopulation(10, "Pre"),
            post_population=MockPopulation(10, "Post"),
            prepop_is_view=False,
            postpop_is_view=False,
            rng=None,
            synapse_dynamics=None,
            synapse_type=None,
            receptor_type=None,
            is_virtual_machine=False,
            synapse_type_from_dynamics=False,
            weights=weight,
            delays=delay)

        connector.set_projection_information(mock_synapse_info)
        pre_vertex_slice = Slice(0, 10)
        post_vertex_slice = Slice(0, 10)
        block = connector.create_synaptic_block([pre_vertex_slice], 0,
                                                [post_vertex_slice], 0,
                                                pre_vertex_slice,
                                                post_vertex_slice, 0,
                                                mock_synapse_info)
        assert (len(block) >= 0)
        assert (all(item["weight"] == 1.0 for item in block))
        assert (all(item["delay"] == 2.0 for item in block))
    except TypeError as e:
        raise SkipTest("https://github.com/INCF/csa/issues/17") from e
    except RuntimeError as e:
        if sys.version_info >= (3, 7):
            raise SkipTest("https://github.com/INCF/csa/issues/16") from e
        raise e
Beispiel #23
0
def test_both():
    unittest_setup()

    @defaults
    class _AClass(object):
        @default_parameters({"param_1"})
        @default_initial_values({"param_2"})
        def __init__(self, param_1=1, param_2=2, param_3=3):
            pass

    @defaults
    class _AnotherClass(object):
        @default_initial_values({"param_1"})
        @default_parameters({"param_2"})
        def __init__(self, param_1=1, param_2=2, param_3=3):
            pass

    assert (_AClass.default_parameters == {"param_1": 1})
    assert (_AClass.default_initial_values == {"param_2": 2})
    assert (_AnotherClass.default_parameters == {"param_2": 2})
    assert (_AnotherClass.default_initial_values == {"param_1": 1})
def test_defaults():
    unittest_setup()
    assert (_MyPyNNModelImpl.default_initial_values == {"svar": 2.0})
    assert (_MyPyNNModelImpl.default_parameters == {"param": 1.0})
    assert (_MyPyNNModelImpl.default_initial_values == {"svar": 2.0})
    assert (_MyPyNNModelImpl.default_parameters == {"param": 1.0})
Beispiel #25
0
def test_connection_holder(data_items, fixed_values, as_list):
    unittest_setup()
    all_values = None
    n_items = 0
    if data_items is not None or fixed_values is not None:
        all_values = list()
    elif as_list:
        n_items = 4
    if data_items is not None:
        all_values.extend(data_items)
        n_items += len(data_items)
    if fixed_values is not None:
        all_values.extend([item[0] for item in fixed_values])
        n_items += len(fixed_values)
    test_data_items = data_items
    if test_data_items is None and fixed_values is None:
        test_data_items = ["source", "target", "weight", "delay"]

    connection_holder = ConnectionHolder(data_items_to_return=all_values,
                                         as_list=as_list,
                                         n_pre_atoms=2,
                                         n_post_atoms=2,
                                         fixed_values=fixed_values)
    connections = numpy.array([(0, 0, 1, 10), (0, 0, 2, 20), (0, 1, 3, 30)],
                              AbstractSynapseDynamics.NUMPY_CONNECTORS_DTYPE)
    connection_holder.add_connections(connections)

    if as_list:

        # Just a list so should be the same length as connections
        assert len(connection_holder) == len(connections)

        # Check that the selected item values are correct
        for i in range(len(connections)):

            # Go through each of the selected fields
            p = 0
            if test_data_items is not None:
                p = len(test_data_items)
                for j, item in enumerate(test_data_items):

                    item_index = connections.dtype.names.index(item)

                    # Check that the value matches with the correct field value
                    if n_items == 1:
                        assert connection_holder[i] == \
                            connections[i][item_index]
                    else:
                        assert connection_holder[i][j] == \
                            connections[i][item_index]

            if fixed_values is not None:
                for j, item in enumerate(fixed_values):
                    if n_items == 1:
                        assert connection_holder[i] == item[1]
                    else:
                        assert connection_holder[i][p + j] == item[1]

    else:

        if n_items == 0:
            assert len(connection_holder) == 0
        else:

            # Should have n_items matrices returned, each of which is a 2x2
            # matrix
            if n_items == 1:
                assert len(connection_holder) == 2
                assert len(connection_holder[0]) == 2
                assert len(connection_holder[1]) == 2
            else:
                assert len(connection_holder) == n_items
                for matrix in connection_holder:
                    assert len(matrix) == 2
                    assert len(matrix[0]) == 2
                    assert len(matrix[1]) == 2

            # Should have the values in the appropriate places
            # Go through each of the selected fields
            p = 0
            if test_data_items is not None:
                p = len(test_data_items)
                for j, item in enumerate(test_data_items):

                    # Check that the value matches with the correct field value
                    item_index = connections.dtype.names.index(item)
                    if n_items == 1:
                        matrix = connection_holder
                    else:
                        matrix = connection_holder[j]

                    assert matrix[0, 0] == connections[1][item_index]
                    assert matrix[0, 1] == connections[2][item_index]
                    assert math.isnan(matrix[1, 0])
                    assert math.isnan(matrix[1, 1])

            if fixed_values is not None:
                for j, item in enumerate(fixed_values):
                    if n_items == 1:
                        matrix = connection_holder
                    else:
                        matrix = connection_holder[j + p]
                    assert matrix[0, 0] == item[1]
                    assert matrix[0, 1] == item[1]
                    assert math.isnan(matrix[1, 0])
                    assert math.isnan(matrix[1, 1])
Beispiel #26
0
def test_single_value():
    unittest_setup()
    run_spec_check(single_value)
Beispiel #27
0
def test_real_list():
    unittest_setup()
    run_spec_check(real_list)
Beispiel #28
0
def test_range_list_as_list():
    unittest_setup()
    run_spec_check(range_list_as_list)
Beispiel #29
0
 def setUp(self):
     unittest_setup()
Beispiel #30
0
def test_connectors(n_pre, n_post, n_in_slice, create_connector, weight,
                    delay):
    unittest_setup()
    max_target = 0
    max_source = 0
    max_row_length = None
    max_col_length = None
    for seed in range(10):
        numpy.random.seed(random.randint(0, 1000))
        connector = create_connector()
        synapse_info = SynapseInformation(
            connector=None,
            pre_population=MockPopulation(n_pre, "Pre"),
            post_population=MockPopulation(n_post, "Post"),
            prepop_is_view=False,
            postpop_is_view=False,
            rng=None,
            synapse_dynamics=None,
            synapse_type=None,
            receptor_type=None,
            is_virtual_machine=False,
            synapse_type_from_dynamics=False,
            weights=weight,
            delays=delay)
        connector.set_projection_information(synapse_info=synapse_info)

        pre_slices = [
            Slice(i, i + n_in_slice - 1) for i in range(0, n_pre, n_in_slice)
        ]
        post_slices = [
            Slice(i, i + n_in_slice - 1) for i in range(0, n_post, n_in_slice)
        ]
        pre_slice_index = 0
        post_slice_index = 0
        pre_vertex_slice = pre_slices[pre_slice_index]
        post_vertex_slice = post_slices[post_slice_index]
        synapse_type = 0
        pre_slice = pre_slices[pre_slice_index]
        post_slice = post_slices[post_slice_index]
        pre_range = numpy.arange(pre_slice.lo_atom, pre_slice.hi_atom + 2)
        post_range = numpy.arange(post_slice.lo_atom, post_slice.hi_atom + 2)

        max_delay = connector.get_delay_maximum(synapse_info)
        max_weight = connector.get_weight_maximum(synapse_info)
        if max_row_length is None:
            max_row_length = connector.\
                get_n_connections_from_pre_vertex_maximum(
                    post_vertex_slice, synapse_info)
        else:
            assert (max_row_length ==
                    connector.get_n_connections_from_pre_vertex_maximum(
                        post_vertex_slice, synapse_info))
        if max_col_length is None:
            max_col_length = connector.\
                get_n_connections_to_post_vertex_maximum(synapse_info)
        else:
            assert (max_col_length == connector.
                    get_n_connections_to_post_vertex_maximum(synapse_info))
        synaptic_block = connector.create_synaptic_block(
            pre_slices, post_slices, pre_vertex_slice, post_vertex_slice,
            synapse_type, synapse_info)
        source_histogram = numpy.histogram(synaptic_block["source"],
                                           pre_range)[0]
        target_histogram = numpy.histogram(synaptic_block["target"],
                                           post_range)[0]
        matrix_max_weight = (max(synaptic_block["weight"])
                             if len(synaptic_block) > 0 else 0)
        matrix_max_delay = (max(synaptic_block["delay"])
                            if len(synaptic_block) > 0 else 0)

        max_source = max((max(source_histogram), max_source))
        max_target = max((max(target_histogram), max_target))

        if len(post_slices) > post_slice_index + 1:
            test_post_slice = post_slices[post_slice_index + 1]
            test_synaptic_block = connector.create_synaptic_block(
                pre_slices, post_slices, pre_vertex_slice, test_post_slice,
                synapse_type, synapse_info)
            if len(test_synaptic_block) > 0:
                assert not numpy.array_equal(test_synaptic_block,
                                             synaptic_block)
        if len(pre_slices) > pre_slice_index + 1:
            test_pre_slice = pre_slices[pre_slice_index + 1]
            test_synaptic_block = connector.create_synaptic_block(
                pre_slices, post_slices, test_pre_slice, post_vertex_slice,
                synapse_type, synapse_info)
            if len(test_synaptic_block) > 0:
                assert not numpy.array_equal(test_synaptic_block,
                                             synaptic_block)

        try:
            assert max(source_histogram) <= max_row_length
            assert max(target_histogram) <= max_col_length
            assert matrix_max_weight <= max_weight
            assert matrix_max_delay <= max_delay
        except Exception:
            print(connector, n_pre, n_post, n_in_slice)
            print(max_row_length, max(source_histogram), source_histogram)
            print(max_col_length, max(target_histogram), target_histogram)
            print(max_weight, matrix_max_weight, synaptic_block["weight"])
            print(max_delay, matrix_max_delay, synaptic_block["delay"])
    print(connector, n_pre, n_post, n_in_slice, max_row_length, max_source,
          max_col_length, max_target)