Skip to content

Port regression test 665 to Pytests #3459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jessica-mitchell
Copy link
Contributor

Conversion uses Mistral AI

@jessica-mitchell jessica-mitchell added S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation. I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Apr 2, 2025
@github-project-automation github-project-automation bot moved this to In progress in PyNEST-NG Apr 2, 2025
@jessica-mitchell
Copy link
Contributor Author

jessica-mitchell commented Apr 11, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Normal Handle this with default priority T: Maintenance Work to keep up the quality of the code and documentation.
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.

1 participant