-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add test for string handling * make test NEST2 compatible --------- Co-authored-by: C.A.P. Linssen <charl@turingbirds.com>
- Loading branch information
Showing
3 changed files
with
118 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
""" | ||
StringHandlingTest.nestml | ||
######################### | ||
|
||
|
||
Copyright statement | ||
+++++++++++++++++++ | ||
|
||
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/>. | ||
""" | ||
neuron string_handling_test: | ||
state: | ||
s1 string = "abc" | ||
s2 string = "def" | ||
b1 boolean = false | ||
b2 boolean = false | ||
|
||
parameters: | ||
s3 string = "ghi" | ||
s4 string = "klm" | ||
|
||
internals: | ||
s5 string = "ghi" | ||
|
||
update: | ||
s7 string = s1 + s2 | ||
if s7 == "abcdef": | ||
b1 = true | ||
|
||
if s3 + s4 == s5 + "klm": | ||
b2 = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# test_string_handling.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/>. | ||
|
||
import nest | ||
import numpy as np | ||
import scipy as sp | ||
import os | ||
|
||
from pynestml.frontend.pynestml_frontend import generate_nest_target | ||
from pynestml.codegeneration.nest_tools import NESTTools | ||
|
||
|
||
class TestStringHandling: | ||
"""Test string handling""" | ||
|
||
def test_string_handling(self): | ||
input_path = os.path.join(os.path.realpath(os.path.join(os.path.dirname(__file__), "resources", "StringHandlingTest.nestml"))) | ||
target_path = "target" | ||
logging_level = "INFO" | ||
module_name = "nestmlmodule" | ||
suffix = "_nestml" | ||
|
||
nest_version = NESTTools.detect_nest_version() | ||
|
||
nest.set_verbosity("M_ALL") | ||
generate_nest_target(input_path, | ||
target_path=target_path, | ||
logging_level=logging_level, | ||
module_name=module_name, | ||
suffix=suffix) | ||
nest.ResetKernel() | ||
nest.Install("nestmlmodule") | ||
|
||
nrn = nest.Create("string_handling_test_nestml") | ||
|
||
nest.Simulate(100.) | ||
|
||
assert nest.GetStatus(nrn, "b1") | ||
assert nest.GetStatus(nrn, "b2") |