Skip to content

Commit

Permalink
Merge pull request #2719 from janskaar/test_mip_corrdet_topy
Browse files Browse the repository at this point in the history
Port test_mip_corrdet to py
  • Loading branch information
heplesser authored Apr 27, 2023
2 parents 8d13d34 + 27fe265 commit 5c94bfc
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 138 deletions.
62 changes: 62 additions & 0 deletions testsuite/pytests/test_mip_corrdet.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# -*- coding: utf-8 -*-
#
# test_mip_corrdet.py
#
# This file is part of NEST.
#
# Copyright (C) 2004 The NEST Initiative
#
# NEST is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# NEST is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with NEST. If not, see <http://www.gnu.org/licenses/>.
"""
Tests correlation_detector connected to two parrot_neurons
receiving input from a mip_generator. Compares resulting correlation
to known value.
"""


import nest
import pytest
import numpy.testing as nptest


def test_correlation_detector_mip():
# Cross check generated with cross_check_test_mip_corrdet.py
expected_hist = [2335, 2317, 2364, 2370, 2376, 2336, 2308, 2325, 2292, 2393,
4806, 2378, 2373, 2356, 2357, 2400, 2420, 2325, 2367, 2338, 2293]

nest.ResetKernel()

nest.set(rng_seed=12345)

mg = nest.Create("mip_generator")
mg.set(rate=100, p_copy=0.5)
cd = nest.Create("correlation_detector")
cd.set(tau_max=100, delta_tau=10)

pn1 = nest.Create("parrot_neuron")
pn2 = nest.Create("parrot_neuron")

nest.Connect(mg, pn1)
nest.Connect(mg, pn2)

syn_spec = {"weight": 1., "receptor_type": 0}
nest.Connect(pn1, cd, syn_spec=syn_spec)

syn_spec = {"weight": 1., "receptor_type": 1}
nest.Connect(pn2, cd, syn_spec=syn_spec)

nest.Simulate(100000.)

hist = cd.get("histogram")
nptest.assert_array_equal(hist, expected_hist)
138 changes: 0 additions & 138 deletions testsuite/unittests/test_mip_corrdet.sli

This file was deleted.

0 comments on commit 5c94bfc

Please sign in to comment.