diff --git a/testsuite/CMakeLists.txt b/testsuite/CMakeLists.txt index 8553593ca8..ab13fe9be3 100644 --- a/testsuite/CMakeLists.txt +++ b/testsuite/CMakeLists.txt @@ -23,7 +23,7 @@ set( TESTSUBDIRS regressiontests mpitests mpi_selftests - musictests + sli2py_music cpptests pytests ) @@ -36,11 +36,12 @@ add_subdirectory( regressiontests/sli2py_ignore ) add_subdirectory( mpi_selftests/fail ) add_subdirectory( mpi_selftests/pass ) add_subdirectory( mpitests ) -add_subdirectory( musictests ) +add_subdirectory( sli2py_music ) add_subdirectory( cpptests ) install( DIRECTORY ${TESTSUBDIRS} DESTINATION ${CMAKE_INSTALL_DATADIR}/testsuite + USE_SOURCE_PERMISSIONS ) install( PROGRAMS diff --git a/testsuite/SLI2PY_TODO.md b/testsuite/SLI2PY_TODO.md index 88f14ba034..b6005666d4 100644 --- a/testsuite/SLI2PY_TODO.md +++ b/testsuite/SLI2PY_TODO.md @@ -2,7 +2,6 @@ To port - unittests - regressiontests - mpitests -- musictests Ignore - selftests diff --git a/testsuite/do_tests.sh b/testsuite/do_tests.sh index 977742a917..eeef3744ce 100755 --- a/testsuite/do_tests.sh +++ b/testsuite/do_tests.sh @@ -422,16 +422,21 @@ if test "${MUSIC}"; then BASEDIR="$PWD" TMPDIR_MUSIC="$(mktemp -d)" - TESTDIR="${TEST_BASEDIR}/musictests/" + TESTDIR="${TEST_BASEDIR}/sli2py_music/" # shellcheck disable=SC2044 for test_name in $(find "${TESTDIR}" -maxdepth 1 -name '*.music' -printf '%f\n'); do music_file="${TESTDIR}/${test_name}" - # Collect the list of SLI files from the '.music' file. - sli_files="$(grep '\.sli' "${music_file}" | sed -e "s#args=#${TESTDIR}#g")" - sli_files="$(for f in ${sli_files}; do if test -f "${f}"; then echo "${f}"; fi; done)" - sli_files="${sli_files//$'\n'/ }" + # Collect the list of Python files from the '.music' file. + if py_file_matches="$(grep '\.py' "${music_file}")"; then + py_files="${py_file_matches//binary=/${TESTDIR}}" + py_files="$(for f in ${py_files}; do if test -f "${f}"; then echo "${f}"; fi; done)" + py_files="${py_files//$'\n'/ }" + else + py_files="" + echo "No python files found in music file ${music_file}" + fi # Check if there is an accompanying shell script for the test. sh_file="${TESTDIR}/$(basename "${music_file}" ".music").sh" @@ -443,7 +448,7 @@ if test "${MUSIC}"; then # Calculate the total number of processes from the '.music' file. np="$(($(sed -n 's/np=//p' "${music_file}" | paste -sd'+' -)))" - test_command="$(sli -c "${np} (${MUSIC}) (${test_name}) mpirun =only")" + test_command="${MPI_LAUNCHER} ${SLI_MPIEXEC_PREFLAGS} -np ${np} ${MUSIC} ${test_name}" proc_txt="processes" if test $np -eq 1; then proc_txt="process"; fi @@ -451,16 +456,16 @@ if test "${MUSIC}"; then printf '%s' " Running test '${test_name}' with $np $proc_txt... " # Copy everything to TMPDIR_MUSIC. - # Note that variables might also be empty, so test for file existance first. - # Note that ${sli_files} must not be quoted because it expands into multiple, space-separate file names. - for filename in "${music_file}" "${sh_file}" "${input_file}" ${sli_files}; do + # Note that variables might also be empty, so test for file existence first. + # Note that ${py_files} must not be quoted because it expands into multiple, space-separate file names. + for filename in "${music_file}" "${sh_file}" "${input_file}" ${py_files}; do test -e "${filename}" && cp "${filename}" "${TMPDIR_MUSIC}" done # Create the runner script in TMPDIR_MUSIC. cd "${TMPDIR_MUSIC}" { - echo "#!/bin/sh" + echo "#!/usr/bin/env sh" echo "set +e" echo "NEST_DATA_PATH=\"${TMPDIR_MUSIC}\"" echo "${test_command} > ${TEST_OUTFILE} 2>&1" diff --git a/testsuite/musictests/test_cont_proxy_receiver.sli b/testsuite/musictests/test_cont_proxy_receiver.sli deleted file mode 100644 index c8b9361d4b..0000000000 --- a/testsuite/musictests/test_cont_proxy_receiver.sli +++ /dev/null @@ -1,75 +0,0 @@ -/* - * test_cont_proxy_receiver.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -skip_if_without_music - -M_ERROR setverbosity - -/music_cont_in_proxy Create /mciproxy Set -mciproxy << /port_name (voltage_in) >> SetStatus - -/ReceiveDataPacket -{ - 1 Simulate mciproxy [/data] get cva -} def - -% reference data: V_m -% n1 channel A | n2 channel B -% ----------------------------- -[ -57.0719 -60.0000 ] -[ -57.4215 -55.8623 ] -[ -57.7953 -57.3695 ] -[ -58.1948 -58.9805 ] -[ -58.6218 -60.0000 ] -[ -59.0783 -60.0000 ] -[ -59.5663 -55.4294 ] -[ -60.0879 -56.9067 ] -[ -60.6455 -58.4859 ] -[ -61.2415 -60.0000 ] -[ -61.8786 -60.0000 ] -[ -62.5596 -55.1193 ] -[ -63.2876 -56.5752 ] -[ -64.0658 -58.1315 ] -[ -64.8976 -59.7951 ] -[ -65.7867 -61.5734 ] -[ -66.7371 -63.4743 ] -[ -67.7531 -65.5062 ] -[ -68.8391 -67.6783 ] -[ 0.00000 0.00000 ] - -20 { - arrayload pop - 7 ToUnitTestPrecision cvs /RefValueChannelB Set - 7 ToUnitTestPrecision cvs /RefValueChannelA Set - - ReceiveDataPacket - - arrayload pop - 7 ToUnitTestPrecision cvs /RecValueChannelB Set - 7 ToUnitTestPrecision cvs /RecValueChannelA Set - - { RefValueChannelA RecValueChannelA eq } assert_or_die - { RefValueChannelB RecValueChannelB eq } assert_or_die -} repeat diff --git a/testsuite/musictests/test_cont_proxy_sender.sli b/testsuite/musictests/test_cont_proxy_sender.sli deleted file mode 100644 index 89efd09dc5..0000000000 --- a/testsuite/musictests/test_cont_proxy_sender.sli +++ /dev/null @@ -1,42 +0,0 @@ -/* - * test_cont_proxy_sender.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -skip_if_without_music - -M_ERROR setverbosity - -/music_cont_out_proxy Create /mcoproxy Set - -/iaf_cond_exp Create /n1 Set -n1 << /I_e 300. >> SetStatus - -/iaf_cond_exp Create /n2 Set -n2 << /I_e 600. >> SetStatus - -mcoproxy << /port_name (voltage_out) >> SetStatus -mcoproxy << /record_from [/V_m] >> SetStatus -mcoproxy << /targets n1 n2 join >> SetStatus - -20 Simulate diff --git a/testsuite/musictests/test_event_proxies.music b/testsuite/musictests/test_event_proxies.music deleted file mode 100644 index 03062c9b56..0000000000 --- a/testsuite/musictests/test_event_proxies.music +++ /dev/null @@ -1,13 +0,0 @@ - -stoptime=0.01 - -[from] - binary=nest - np=1 - args=test_event_proxies_sender.sli - -[to] - binary=nest - np=1 - args=test_event_proxies_receiver.sli - from.spikes_out -> to.spikes_in [1] diff --git a/testsuite/musictests/test_event_proxies.sh b/testsuite/musictests/test_event_proxies.sh deleted file mode 100644 index 50ad300547..0000000000 --- a/testsuite/musictests/test_event_proxies.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -# Prevent any output, result will be interpreted based on exit code. -# Output would confuse parser. -diff sender-1-0.dat receiver-1-0.dat >/dev/null 2>&1 diff --git a/testsuite/musictests/test_event_proxies_issue-696_receiver.sli b/testsuite/musictests/test_event_proxies_issue-696_receiver.sli deleted file mode 100644 index faa5132c00..0000000000 --- a/testsuite/musictests/test_event_proxies_issue-696_receiver.sli +++ /dev/null @@ -1,44 +0,0 @@ -/* - * test_event_proxies_issue-696_receiver.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -statusdict/have_music :: not { exit_test_gracefully } if - -M_ERROR setverbosity - -11 /N_NEURONS Set - -/iaf_psc_alpha N_NEURONS Create /neurons Set -/music_event_in_proxy N_NEURONS Create /inputs Set - -[N_NEURONS] Range -{ - /channel Set - inputs [channel] Take /meip Set - meip << /port_name (in) /music_channel channel 1 sub >> SetStatus - meip neurons [channel] Take << >> << /weight 750.0 >> Connect -} -forall - -1 Simulate diff --git a/testsuite/musictests/test_event_proxies_issue-696_sender.sli b/testsuite/musictests/test_event_proxies_issue-696_sender.sli deleted file mode 100644 index a08b41c76b..0000000000 --- a/testsuite/musictests/test_event_proxies_issue-696_sender.sli +++ /dev/null @@ -1,57 +0,0 @@ -/* - * test_event_proxies_issue-696_sender.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -statusdict/have_music :: not { exit_test_gracefully } if - -M_ERROR setverbosity - -10 /N_THREADS Set -11 /N_NEURONS Set - -<< /local_num_threads N_THREADS /resolution 0.1 >> SetKernelStatus - -/spike_generator N_NEURONS Create /generators Set -/parrot_neuron N_NEURONS Create /neurons Set - -[N_NEURONS] Range -{ - /i Set - generators [i] Take /sg Set - sg << /spike_times [0.1 0.2 0.3] >> SetStatus - sg neurons [i] Take << >> << /delay 0.1 >> Connect -} -forall - -/music_event_out_proxy << /port_name (out) >> Create /meop Set - -[N_NEURONS] Range -{ - /channel Set - neurons [channel] Take /n Set - n meop << >> << /music_channel channel 1 sub >> Connect -} -forall - -1 Simulate diff --git a/testsuite/musictests/test_event_proxies_receiver.sli b/testsuite/musictests/test_event_proxies_receiver.sli deleted file mode 100644 index 864840bae5..0000000000 --- a/testsuite/musictests/test_event_proxies_receiver.sli +++ /dev/null @@ -1,43 +0,0 @@ -/* - * test_event_proxies_receiver.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -skip_if_without_music - -M_ERROR setverbosity - -% create voltmeter first to ensure same GID in sender and receiver -/voltmeter Create /vm Set -vm << /label (receiver) /record_to /ascii >> SetStatus - -/music_event_in_proxy Create /meip Set -meip << /port_name (spikes_in) /music_channel 0 >> SetStatus - -/iaf_psc_alpha Create /n Set - -meip n /one_to_one << /weight 750.0 >> Connect - -vm n Connect - -10 Simulate diff --git a/testsuite/musictests/test_event_proxies_sender.sli b/testsuite/musictests/test_event_proxies_sender.sli deleted file mode 100644 index 81763b9184..0000000000 --- a/testsuite/musictests/test_event_proxies_sender.sli +++ /dev/null @@ -1,52 +0,0 @@ -/* - * test_event_proxies_sender.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -skip_if_without_music - -M_ERROR setverbosity - -% create voltmeter first to ensure same GID in sender and receiver -/voltmeter Create /vm Set -vm << /label (sender) /record_to /ascii >> SetStatus - -/spike_generator Create /sg Set -sg << /spike_times [1.0 1.5 2.0 ]>> SetStatus - -/iaf_psc_alpha Create /n Set - -% create last to ensure same GID for neuron as in receiver -/parrot_neuron Create /pn Set - -sg pn Connect -pn n /one_to_one << /weight 750.0 >> Connect - -vm n Connect - -/music_event_out_proxy Create /meop Set -meop << /port_name (spikes_out) >> SetStatus - -pn meop /one_to_one << /music_channel 0 >> Connect - -10 Simulate diff --git a/testsuite/musictests/test_message_receiver.sli b/testsuite/musictests/test_message_receiver.sli deleted file mode 100644 index 1ea2c95df7..0000000000 --- a/testsuite/musictests/test_message_receiver.sli +++ /dev/null @@ -1,47 +0,0 @@ -/* - * test_message_receiver.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -skip_if_without_music - -M_ERROR setverbosity - -{ - /simtime 100 def - - /ref_times [ 30.0 70.0 90.0 ] def - /ref_messages [ (First) (Second) (Third) ] def - - /music_message_in_proxy Create /mmip Set - mmip << /port_name (msgdata) >> SetStatus - - simtime Simulate - - mmip GetStatus 0 get - /data get /data Set - - data /messages_times get cva ref_times eq - data /messages get ref_messages eq and -} -assert_or_die diff --git a/testsuite/musictests/test_rate_proxy_receiver.sli b/testsuite/musictests/test_rate_proxy_receiver.sli deleted file mode 100644 index 327beae99b..0000000000 --- a/testsuite/musictests/test_rate_proxy_receiver.sli +++ /dev/null @@ -1,52 +0,0 @@ -/* - * test_rate_proxy_receiver.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -skip_if_without_music - -M_ERROR setverbosity - -{ - /simtime 500 def - /mm_starttime 400. def % To let receiving neuron reach equilibrium - - /music_rate_in_proxy Create /mrip Set - /lin_rate_ipn Create /neuron Set - /multimeter Create /mm Set - - mrip << /port_name (rate_in) /music_channel 0 >> SetStatus - neuron << /sigma 0.0 >> SetStatus - mm << /interval 0.1 /record_from [ /rate ] /start mm_starttime >> SetStatus - - mrip neuron /one_to_one << /synapse_model /rate_connection_instantaneous >> Connect - mm neuron Connect - - simtime Simulate - - mm GetStatus 0 get /events get /rate get /rates Set - - % Test that all rates are equal to the drive rate, 1.5, in the sender - rates Max rates Min eq - rates Max 1.5 eq and -} assert_or_die diff --git a/testsuite/musictests/test_rate_proxy_sender.sli b/testsuite/musictests/test_rate_proxy_sender.sli deleted file mode 100644 index fb7bcf4590..0000000000 --- a/testsuite/musictests/test_rate_proxy_sender.sli +++ /dev/null @@ -1,44 +0,0 @@ -/* - * test_rate_proxy_sender.sli - * - * 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 . - * - */ - -(unittest) run -/unittest using - -skip_if_without_music - -M_ERROR setverbosity - -<< /overwrite_files true >> SetKernelStatus - -/drive 1.5 def -/simtime 500 def - -/lin_rate_ipn Create /rate_neuron Set -/music_rate_out_proxy Create /mrop Set - -rate_neuron << /rate drive /mu drive /sigma 0. >> SetStatus -mrop << /port_name (rate_out) >> SetStatus - -rate_neuron mrop /one_to_one << /synapse_model /rate_connection_instantaneous - /music_channel 0 - >> Connect -simtime Simulate diff --git a/testsuite/musictests/CMakeLists.txt b/testsuite/sli2py_music/CMakeLists.txt similarity index 100% rename from testsuite/musictests/CMakeLists.txt rename to testsuite/sli2py_music/CMakeLists.txt diff --git a/testsuite/musictests/README.md b/testsuite/sli2py_music/README.md similarity index 93% rename from testsuite/musictests/README.md rename to testsuite/sli2py_music/README.md index e47d31f988..4846a679b7 100644 --- a/testsuite/musictests/README.md +++ b/testsuite/sli2py_music/README.md @@ -1,11 +1,11 @@ -# `musictests` folder +# `sli2py_music` folder This directory contains tests for the MUSIC interface of NEST [1]. Each test consists of the following parts: * a MUSIC configuration file with the extension `.music` -* one or more `.sli` scripts specifying the simulation +* one or more `.py` scripts specifying the simulation * optionally a shell script with the extension `.sh`, which is run after the actual test simulation. This script can be used to test resulting data files for consistency diff --git a/testsuite/musictests/empty.sli b/testsuite/sli2py_music/empty.sli similarity index 100% rename from testsuite/musictests/empty.sli rename to testsuite/sli2py_music/empty.sli diff --git a/testsuite/musictests/test_cont_proxy.music b/testsuite/sli2py_music/test_cont_proxy.music similarity index 86% rename from testsuite/musictests/test_cont_proxy.music rename to testsuite/sli2py_music/test_cont_proxy.music index 2d6a21667b..0b04240d30 100644 --- a/testsuite/musictests/test_cont_proxy.music +++ b/testsuite/sli2py_music/test_cont_proxy.music @@ -1,5 +1,5 @@ /* - * test_cont_proxies.music + * test_rate_proxy.music * * This file is part of NEST. * @@ -24,13 +24,11 @@ stoptime=0.2 timestep=0.01 [from] - binary=nest np=2 - args=test_cont_proxy_sender.sli + binary=./test_cont_proxy_sender.py [to] - binary=nest np=1 - args=test_cont_proxy_receiver.sli + binary=./test_cont_proxy_receiver.py from.voltage_out -> to.voltage_in [2] diff --git a/testsuite/sli2py_music/test_cont_proxy_receiver.py b/testsuite/sli2py_music/test_cont_proxy_receiver.py new file mode 100755 index 0000000000..d6172eb3ed --- /dev/null +++ b/testsuite/sli2py_music/test_cont_proxy_receiver.py @@ -0,0 +1,61 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_cont_proxy_receiver.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 . + + +import nest +import numpy as np + +mciproxy = nest.Create("music_cont_in_proxy", params={"port_name": "voltage_in"}) + +results = np.empty(shape=(20, 2), dtype=float) +with nest.RunManager(): + for i in range(20): + nest.Run(1) + results[i, :] = mciproxy.data + +reference_results = np.array( + [ + [-57.0719, -60.0000], + [-57.4215, -55.8623], + [-57.7953, -57.3695], + [-58.1948, -58.9805], + [-58.6218, -60.0000], + [-59.0783, -60.0000], + [-59.5663, -55.4294], + [-60.0879, -56.9067], + [-60.6455, -58.4859], + [-61.2415, -60.0000], + [-61.8786, -60.0000], + [-62.5596, -55.1193], + [-63.2876, -56.5752], + [-64.0658, -58.1315], + [-64.8976, -59.7951], + [-65.7867, -61.5734], + [-66.7371, -63.4743], + [-67.7531, -65.5062], + [-68.8391, -67.6783], + [0.00000, 0.00000], + ] +) + +# reference results are in reverse order (copied from SLI) +np.testing.assert_allclose(reference_results[-1::-1, :], results, atol=1e-4) diff --git a/testsuite/sli2py_music/test_cont_proxy_sender.py b/testsuite/sli2py_music/test_cont_proxy_sender.py new file mode 100755 index 0000000000..45389282df --- /dev/null +++ b/testsuite/sli2py_music/test_cont_proxy_sender.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_cont_proxy_sender.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 . + + +import nest + +mcoproxy = nest.Create("music_cont_out_proxy") +mcoproxy.port_name = "voltage_out" +mcoproxy.record_from = ["V_m"] + +n1 = nest.Create("iaf_cond_exp", params={"I_e": 300.0}) +n2 = nest.Create("iaf_cond_exp", params={"I_e": 600.0}) +n = n1 + n2 + +mcoproxy.targets = n + +nest.Simulate(20) diff --git a/testsuite/sli2py_music/test_event_proxies.music b/testsuite/sli2py_music/test_event_proxies.music new file mode 100644 index 0000000000..7249d093d6 --- /dev/null +++ b/testsuite/sli2py_music/test_event_proxies.music @@ -0,0 +1,12 @@ + +stoptime=0.01 + +[from] + binary=./test_event_proxies_sender.py + np=1 + +[to] + binary=./test_event_proxies_receiver.py + np=1 + + from.spikes_out -> to.spikes_in [1] diff --git a/testsuite/musictests/test_event_proxies_issue-696.music b/testsuite/sli2py_music/test_event_proxies_issue-696.music similarity index 87% rename from testsuite/musictests/test_event_proxies_issue-696.music rename to testsuite/sli2py_music/test_event_proxies_issue-696.music index 4a25a521a9..a65c4bf41c 100644 --- a/testsuite/musictests/test_event_proxies_issue-696.music +++ b/testsuite/sli2py_music/test_event_proxies_issue-696.music @@ -21,13 +21,11 @@ */ [sender] - binary=nest np=1 - args=test_event_proxies_issue-696_sender.sli + binary=./test_event_proxies_issue-696_sender.py [receiver] - binary=nest np=1 - args=test_event_proxies_issue-696_receiver.sli + binary=./test_event_proxies_issue-696_receiver.py sender.out -> receiver.in [11] diff --git a/testsuite/sli2py_music/test_event_proxies_issue-696_receiver.py b/testsuite/sli2py_music/test_event_proxies_issue-696_receiver.py new file mode 100755 index 0000000000..7bea43ac0a --- /dev/null +++ b/testsuite/sli2py_music/test_event_proxies_issue-696_receiver.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_event_proxies_issue-696_receiver.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 . +import nest + +n_neurons = 11 + +neurons = nest.Create("iaf_psc_alpha", n_neurons) +inputs = nest.Create( + "music_event_in_proxy", n_neurons, params={"port_name": ["in"] * n_neurons, "music_channel": list(range(n_neurons))} +) + +nest.Connect(inputs, neurons, "one_to_one", {"weight": 750.0}) + +nest.Simulate(1) diff --git a/testsuite/sli2py_music/test_event_proxies_issue-696_sender.py b/testsuite/sli2py_music/test_event_proxies_issue-696_sender.py new file mode 100755 index 0000000000..12c5b87424 --- /dev/null +++ b/testsuite/sli2py_music/test_event_proxies_issue-696_sender.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_event_proxies_issue-696_sender.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 . + +import nest + +nest.local_num_threads = 10 +nest.resolution = 0.1 + +n_neurons = 11 +generators = nest.Create("spike_generator", n_neurons, params={"spike_times": [0.1, 0.2, 0.3]}) +neurons = nest.Create("parrot_neuron", n_neurons) + +nest.Connect(generators, neurons, "one_to_one", {"delay": 0.1}) + +meop = nest.Create("music_event_out_proxy", params={"port_name": "out"}) + + +nest.Connect(neurons, meop, "all_to_all", {"music_channel": [list(range(n_neurons))]}) + +nest.Simulate(1) diff --git a/testsuite/sli2py_music/test_event_proxies_receiver.py b/testsuite/sli2py_music/test_event_proxies_receiver.py new file mode 100755 index 0000000000..0c6b1598b1 --- /dev/null +++ b/testsuite/sli2py_music/test_event_proxies_receiver.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_event_proxies_receiver.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 . + +import nest +import numpy as np + +# create voltmeter first to ensure same GID in sender and receiver +vm = nest.Create("voltmeter", params={"label": "receiver", "record_to": "memory"}) + +meip = nest.Create("music_event_in_proxy", params={"port_name": "spikes_in", "music_channel": 0}) + +n = nest.Create("iaf_psc_alpha") + +nest.Connect(meip, n, "one_to_one", syn_spec={"weight": 750.0}) + +nest.Connect(vm, n) + +nest.Simulate(10) + +reference_vms = [-70.000, -70.000, -70.000, -68.156, -61.917, -70.000, -70.000, -70.000, -65.205] + +np.testing.assert_allclose(reference_vms, vm.events["V_m"], atol=1e-3) diff --git a/testsuite/sli2py_music/test_event_proxies_sender.py b/testsuite/sli2py_music/test_event_proxies_sender.py new file mode 100755 index 0000000000..beeaab9e00 --- /dev/null +++ b/testsuite/sli2py_music/test_event_proxies_sender.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_event_proxies_sender.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 . + +import nest +import numpy as np + +# create voltmeter first to ensure same GID in sender and receiver +vm = nest.Create("voltmeter", params={"label": "sender", "record_to": "memory"}) + +sg = nest.Create("spike_generator", params={"spike_times": [1.0, 1.5, 2.0]}) + +n = nest.Create("iaf_psc_alpha") + +# create last to ensure same GID for neuron as in receiver +pn = nest.Create("parrot_neuron") + +nest.Connect(sg, pn) +nest.Connect(pn, n, "one_to_one", syn_spec={"weight": 750.0}) + +nest.Connect(vm, n) + +meop = nest.Create("music_event_out_proxy", params={"port_name": "spikes_out"}) + +nest.Connect(pn, meop, "one_to_one", syn_spec={"music_channel": 0}) + +nest.Simulate(10) + +reference_vms = [-70.000, -70.000, -70.000, -68.156, -61.917, -70.000, -70.000, -70.000, -65.205] + +np.testing.assert_allclose(reference_vms, vm.events["V_m"], atol=1e-3) diff --git a/testsuite/musictests/test_message.music b/testsuite/sli2py_music/test_message.music similarity index 95% rename from testsuite/musictests/test_message.music rename to testsuite/sli2py_music/test_message.music index c83e41b915..9869189e85 100644 --- a/testsuite/musictests/test_message.music +++ b/testsuite/sli2py_music/test_message.music @@ -31,8 +31,7 @@ stoptime=0.1 args=test_message [to] - binary=nest np=1 - args=test_message_receiver.sli + binary=./test_message_receiver.py from.out -> to.msgdata [0] diff --git a/testsuite/musictests/test_message0.dat b/testsuite/sli2py_music/test_message0.dat similarity index 100% rename from testsuite/musictests/test_message0.dat rename to testsuite/sli2py_music/test_message0.dat diff --git a/testsuite/sli2py_music/test_message_receiver.py b/testsuite/sli2py_music/test_message_receiver.py new file mode 100755 index 0000000000..cd58369d10 --- /dev/null +++ b/testsuite/sli2py_music/test_message_receiver.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_message_receiver.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 . + +import nest +import numpy as np + +ref_times = [30.0, 70.0, 90.0] +ref_messages = ["First", "Second", "Third"] + +mmip = nest.Create("music_message_in_proxy", params={"port_name": "msgdata"}) + +nest.Simulate(100) + +np.testing.assert_allclose(mmip.data["messages_times"], ref_times) +np.testing.assert_equal(mmip.data["messages"], ref_messages) diff --git a/testsuite/musictests/test_music_failure1.music b/testsuite/sli2py_music/test_music_failure1.music similarity index 100% rename from testsuite/musictests/test_music_failure1.music rename to testsuite/sli2py_music/test_music_failure1.music diff --git a/testsuite/musictests/test_music_failure2.music b/testsuite/sli2py_music/test_music_failure2.music similarity index 100% rename from testsuite/musictests/test_music_failure2.music rename to testsuite/sli2py_music/test_music_failure2.music diff --git a/testsuite/musictests/test_rate_proxy.music b/testsuite/sli2py_music/test_rate_proxy.music similarity index 88% rename from testsuite/musictests/test_rate_proxy.music rename to testsuite/sli2py_music/test_rate_proxy.music index e456d01d05..58769ea568 100644 --- a/testsuite/musictests/test_rate_proxy.music +++ b/testsuite/sli2py_music/test_rate_proxy.music @@ -23,13 +23,11 @@ stoptime=5.0 [from] - binary=nest + binary=./test_rate_proxy_sender.py np=1 - args=test_rate_proxy_sender.sli [to] - binary=nest + binary=./test_rate_proxy_receiver.py np=1 - args=test_rate_proxy_receiver.sli from.rate_out -> to.rate_in [1] diff --git a/testsuite/sli2py_music/test_rate_proxy_receiver.py b/testsuite/sli2py_music/test_rate_proxy_receiver.py new file mode 100755 index 0000000000..0ca3c1587f --- /dev/null +++ b/testsuite/sli2py_music/test_rate_proxy_receiver.py @@ -0,0 +1,39 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_rate_proxy_receiver.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 . + +import nest + +mrip = nest.Create("music_rate_in_proxy", params={"port_name": "rate_in", "music_channel": 0}) +neuron = nest.Create("lin_rate_ipn", params={"sigma": 0.0}) +# To let receiving neuron reach equilibrium +mm = nest.Create("multimeter", params={"interval": 0.1, "record_from": ["rate"], "start": 400.0}) + +nest.Connect(mrip, neuron, "one_to_one", syn_spec={"synapse_model": "rate_connection_instantaneous"}) +nest.Connect(mm, neuron) + +nest.Simulate(500) + +rates = mm.events["rate"] + +# Test that all rates are equal to the drive rate, 1.5, in the sender +assert min(rates) == max(rates) +assert max(rates) == 1.5 diff --git a/testsuite/sli2py_music/test_rate_proxy_sender.py b/testsuite/sli2py_music/test_rate_proxy_sender.py new file mode 100755 index 0000000000..b3acd40f8c --- /dev/null +++ b/testsuite/sli2py_music/test_rate_proxy_sender.py @@ -0,0 +1,33 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# test_rate_proxy_sender.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 . + +import nest + +rate_neuron = nest.Create("lin_rate_ipn", params={"rate": 1.5, "mu": 1.5, "sigma": 0.0}) + +mrop = nest.Create("music_rate_out_proxy", params={"port_name": "rate_out"}) + +nest.Connect( + rate_neuron, mrop, "one_to_one", syn_spec={"synapse_model": "rate_connection_instantaneous", "music_channel": 0} +) + +nest.Simulate(500)