Skip to content

Commit

Permalink
Merge pull request #1502 from brian-team/cpow_cython
Browse files Browse the repository at this point in the history
Use `cpow=True` in Python
  • Loading branch information
mstimberg committed Feb 6, 2024
2 parents 2a54971 + 59a4cb0 commit 2cca2a4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#cython: boundscheck=False
#cython: wraparound=False
#cython: cdivision=False
#cython: cpow=True
#cython: infer_types=True
{% endmacro %}

Expand Down
18 changes: 18 additions & 0 deletions brian2/tests/test_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,24 @@ def test_bool_to_int():
assert_equal(s_mon.intexpr2.flatten(), [1, 0])


@pytest.mark.standalone_compatible
def test_integer_power():
# See github issue #1500
G = NeuronGroup(
3,
"""
intval1 : integer
intval2 : integer
k : integer (constant)
""",
)
G.k = [0, 1, 2]
G.run_regularly("intval1 = 2**k; intval2 = (-1)**k")
run(defaultclock.dt)
assert_equal(G.intval1[:], [1, 2, 4])
assert_equal(G.intval2[:], [1, -1, 1])


@pytest.mark.codegen_independent
def test_timestep_function():
dt = defaultclock.dt_
Expand Down

0 comments on commit 2cca2a4

Please sign in to comment.