Skip to content

Commit

Permalink
Merge 6b8f1ae into ecc567a
Browse files Browse the repository at this point in the history
  • Loading branch information
tBuLi committed Mar 19, 2020
2 parents ecc567a + 6b8f1ae commit 01b727a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion symfit/core/printing.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Users using both ``symfit`` and ``sympy`` should be aware of this.
"""

import pkg_resources
from sympy import HadamardProduct, MatPow, Idx, Inverse
from sympy.printing.codeprinter import CodePrinter

Expand Down Expand Up @@ -41,6 +41,15 @@ def _print_HadamardProduct(self, printer):
printer.doprint(self.args[1]))
HadamardProduct._numpycode = _print_HadamardProduct

if pkg_resources.parse_version(pkg_resources.get_distribution('sympy').version) \
> pkg_resources.parse_version('1.4'):
from sympy import HadamardPower

def _print_HadamardPower(self, printer):
return "%s**%s" % (printer.doprint(self.args[0]),
printer.doprint(self.args[1]))
HadamardPower._numpycode = _print_HadamardPower

def _print_Idx(self, printer):
"""
Print ``Idx`` objects.
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ode.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def test_initial_parameters():
fit = Fit(ode_model, t=tdata, a=AA, c=AAB, d=BAAB)
results = fit.execute()
print(results)
assert results.value(a0) == 10
assert results.value(c0) == pytest.approx(0)
assert results.value(a0) == pytest.approx(10, abs=1e-8)
assert results.value(c0) == pytest.approx(0, abs=1e-8)

assert ode_model.params == [a0, c0, k, l, m, p]
assert ode_model.initial_params == [a0, c0]
Expand Down

0 comments on commit 01b727a

Please sign in to comment.