nest-simulator icon indicating copy to clipboard operation
nest-simulator copied to clipboard

Port regression test 665 to Pytests

Open jessica-mitchell opened this issue 9 months ago • 2 comments

Conversion uses Mistral AI

jessica-mitchell avatar Apr 02 '25 19:04 jessica-mitchell

@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.

jessica-mitchell avatar Apr 11 '25 09:04 jessica-mitchell

Pull request automatically marked stale!

github-actions[bot] avatar Jun 11 '25 08:06 github-actions[bot]

Pull request automatically marked stale!

github-actions[bot] avatar Aug 26 '25 08:08 github-actions[bot]

@jessica-mitchell I sent you a PR adding two missing corner cases from the original test.

heplesser avatar Dec 01 '25 19:12 heplesser