Skip to content

Commit

Permalink
SciPyPrinter: polygamma (fix sympygh-23924)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjodah committed Aug 15, 2022
1 parent b1f35f8 commit 376abd4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions sympy/printing/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ def _print_NDimArray(self, expr):
'gamma': 'gamma',
'loggamma': 'gammaln',
'digamma': 'psi',
'polygamma': 'polygamma',
'RisingFactorial': 'poch',
'jacobi': 'eval_jacobi',
'gegenbauer': 'eval_gegenbauer',
Expand Down
6 changes: 3 additions & 3 deletions sympy/utilities/tests/test_lambdify.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from sympy.functions.special.beta_functions import (beta, betainc, betainc_regularized)
from sympy.functions.special.delta_functions import (Heaviside)
from sympy.functions.special.error_functions import (Ei, erf, erfc, fresnelc, fresnels)
from sympy.functions.special.gamma_functions import (digamma, gamma, loggamma)
from sympy.functions.special.gamma_functions import (digamma, gamma, loggamma, polygamma)
from sympy.integrals.integrals import Integral
from sympy.logic.boolalg import (And, false, ITE, Not, Or, true)
from sympy.matrices.expressions.dotproduct import DotProduct
Expand Down Expand Up @@ -1077,7 +1077,7 @@ def test_scipy_fns():
if not scipy:
skip("scipy not installed")

single_arg_sympy_fns = [Ei, erf, erfc, factorial, gamma, loggamma, digamma]
single_arg_sympy_fns = [Ei, erf, erfc, factorial, gamma, loggamma, digamma, polygamma]
single_arg_scipy_fns = [scipy.special.expi, scipy.special.erf, scipy.special.erfc,
scipy.special.factorial, scipy.special.gamma, scipy.special.gammaln,
scipy.special.psi]
Expand All @@ -1097,7 +1097,7 @@ def test_scipy_fns():
tv = numpy.abs(tv)
# SymPy's digamma evaluates as polygamma(0, z)
# which SciPy supports for real arguments only
if sympy_fn == digamma:
if sympy_fn in (digamma, polygamma):
tv = numpy.real(tv)
sympy_result = sympy_fn(tv).evalf()
assert abs(f(tv) - sympy_result) < 1e-13*(1 + abs(sympy_result))
Expand Down

0 comments on commit 376abd4

Please sign in to comment.