from region import Region


def test_bind_input_2d_skips_self_edge_connections():
    region = Region("two-d-self-edge")
    region.bind_input_2d("image", 2, 2, 1.0, 0.01, [])
    edge_layer_index = region.input_edges["image"]

    region.bind_input_2d("image", 2, 2, 1.0, 0.01, [edge_layer_index])

    edge_layer = region.get_layers()[edge_layer_index]
    total_synapses = sum(len(neuron.get_outgoing()) for neuron in edge_layer.get_neurons())
    assert total_synapses == 0


def test_bind_input_nd_skips_self_edge_connections():
    region = Region("nd-self-edge")
    region.bind_input_nd("tensor", [2, 2], 1.0, 0.01, [])
    edge_layer_index = region.input_edges["tensor"]

    region.bind_input_nd("tensor", [2, 2], 1.0, 0.01, [edge_layer_index])

    edge_layer = region.get_layers()[edge_layer_index]
    total_synapses = sum(len(neuron.get_outgoing()) for neuron in edge_layer.get_neurons())
    assert total_synapses == 0
