Skip to content

Commit e814885

Browse files
Merge pull request #731 from zwicker-group/test_expression
Add tests for ScalarExpression with signature and constants
2 parents e021122 + 1fee863 commit e814885

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

tests/tools/test_expressions.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,3 +478,16 @@ def test_expression_repl(rng):
478478
assert e(4) == 8
479479
assert e.differentiate("σ").value == 0
480480
assert e.differentiate("sigma").value == 2
481+
482+
483+
def test_expression_signature_consts():
484+
"""test the combination of specifying a signature and a constant"""
485+
e = ScalarExpression("a * c", signature=["a", "b"], consts={"c": 3})
486+
assert e(2, 2) == 6
487+
assert e.depends_on("a")
488+
assert not e.depends_on("c")
489+
assert e.differentiate("a")(6, 7) == 3
490+
491+
e = ScalarExpression("a * c", signature=["a", "b"], consts={"c": np.arange(3)})
492+
np.testing.assert_allclose(e(1, 2), np.arange(3))
493+
np.testing.assert_allclose(e.differentiate("a")(6, 7), np.arange(3))

0 commit comments

Comments
 (0)