Port regression test 665 to Pytests
Conversion uses Mistral AI
@heplesser I looked at the failing test and saw that it uses some NEST 2 syntax so I tried to re-evaluate it with AI, providing documentation for NEST 3. But I am unsure if the changes maintain the intent of the original SLI test. (It seems to make sense based on the documentation I found in spatially-structured networks, but obviously some expertise is required)
A suggestion (that passes) for the first set of tests is the following
def reset_kernel():
nest.ResetKernel()
def create_and_connect_layers(source_model, target_model, conn_spec):
nest.ResetKernel()
nest.SetKernelStatus({"local_num_threads": 4})
source_layer = nest.Create(source_model, positions=nest.spatial.grid([1, 1]))
target_layer = nest.Create(target_model, positions=nest.spatial.grid([2, 2]))
nest.Connect(source_layer, target_layer, conn_spec)
return source_layer, target_layer
def test_gen_to_layer_pairwise_bernoulli_on_source():
source_layer, target_layer = create_and_connect_layers(
'poisson_generator', 'iaf_psc_alpha',
{'rule': 'pairwise_bernoulli', 'p': 1.0}
)
conns = nest.GetConnections(source=source_layer)
target_ids = nest.GetStatus(conns, 'target')
assert sorted(target_layer.tolist()) == sorted(target_ids)
def test_gen_to_layer_pairwise_bernoulli_on_target():
source_layer, target_layer = create_and_connect_layers(
'poisson_generator', 'iaf_psc_alpha',
{'rule': 'pairwise_bernoulli', 'p': 1.0}
)
conns = nest.GetConnections(source=source_layer)
target_ids = nest.GetStatus(conns, 'target')
assert sorted(target_layer.tolist()) == sorted(target_ids)
def test_gen_to_layer_fixed_indegree():
source_layer, target_layer = create_and_connect_layers(
'poisson_generator', 'iaf_psc_alpha',
{'rule': 'fixed_indegree', 'indegree': 1}
)
conns = nest.GetConnections(target=target_layer)
source_ids = nest.GetStatus(conns, 'source')
assert len(source_ids) == len(target_layer)
def test_gen_to_layer_fixed_outdegree():
source_layer, target_layer = create_and_connect_layers(
'poisson_generator', 'iaf_psc_alpha',
{'rule': 'fixed_outdegree', 'outdegree': 4, 'allow_multapses': False}
)
conns = nest.GetConnections(source=source_layer)
target_ids = nest.GetStatus(conns, 'target')
assert len(target_ids) == 4
However, I struggled to find a solution to the second set of tests. When trying to use a rule like pairwise_bernoulli with the neuron and spike_recorder, I kept running into the error that
Cannot use this rule to connect to nodes without proxies (usually devices).
And any solution that was suggested was incorrect. I tried both Mistral AI and perplexity, and ended up with the same issue.
Pull request automatically marked stale!
Pull request automatically marked stale!
@jessica-mitchell I sent you a PR adding two missing corner cases from the original test.