-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sympy code optimizations optional (#1878)
Turns out that applying sympy optimizations as introduced in #1377 is potentially very costly. Therefore, they are disabled by default. They can be enabled by setting `AmiciCxxCodePrinter.optimizations` as shown in the test case.
- Loading branch information
Showing
2 changed files
with
35 additions
and
6 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,14 @@ | ||
from amici.cxxcodeprinter import AmiciCxxCodePrinter | ||
from sympy.codegen.rewriting import optims_c99 | ||
import sympy as sp | ||
|
||
|
||
def test_optimizations(): | ||
"""Check that AmiciCxxCodePrinter handles optimizations correctly.""" | ||
try: | ||
old_optim = AmiciCxxCodePrinter.optimizations | ||
AmiciCxxCodePrinter.optimizations = optims_c99 | ||
cp = AmiciCxxCodePrinter() | ||
assert "expm1" in cp.doprint(sp.sympify("exp(x) - 1")) | ||
finally: | ||
AmiciCxxCodePrinter.optimizations = old_optim |