File: test_numpy_codegen.py

package info (click to toggle)
brian 2.9.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,872 kB
  • sloc: python: 51,820; cpp: 2,033; makefile: 108; sh: 72
file content (24 lines) | stat: -rw-r--r-- 561 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import pytest

from brian2 import *


def test_error_message():
    if prefs.codegen.target != "numpy":
        pytest.skip("numpy-only test")

    @check_units(x=1, result=1)
    def foo(x):
        raise ValueError()

    G = NeuronGroup(1, "v : 1")
    G.run_regularly("v = foo(3)")
    with pytest.raises(BrianObjectException) as exc:
        run(defaultclock.dt)
        # The actual code line should be mentioned in the error message
        exc.match("v = foo(3)")


if __name__ == "__main__":
    prefs.codegen.target = "numpy"
    test_error_message()