Skip to content

Commit

Permalink
Add lambdify support for harmonic()
Browse files Browse the repository at this point in the history
  • Loading branch information
Parcly-Taxel committed Aug 30, 2022
1 parent aeaeea6 commit e63a2e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions sympy/printing/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,9 @@ def _print_bernoulli(self, expr):
# scipy's bernoulli is inconsistent with SymPy's so rewrite
return self._print(expr._eval_rewrite_as_zeta(*expr.args))

def _print_harmonic(self, expr):
return self._print(expr._eval_rewrite_as_zeta(*expr.args))

def _print_Integral(self, e):
integration_vars, limits = _unpack_integral_limits(e)

Expand Down
12 changes: 11 additions & 1 deletion sympy/utilities/tests/test_lambdify.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from sympy.core.singleton import S
from sympy.core.symbol import (Dummy, symbols)
from sympy.functions.combinatorial.factorials import (RisingFactorial, factorial)
from sympy.functions.combinatorial.numbers import bernoulli
from sympy.functions.combinatorial.numbers import bernoulli, harmonic
from sympy.functions.elementary.complexes import Abs
from sympy.functions.elementary.exponential import exp, log
from sympy.functions.elementary.hyperbolic import acosh
Expand Down Expand Up @@ -1476,6 +1476,16 @@ def test_scipy_bernoulli():
assert bern(1) == 0.5


def test_scipy_harmonic():
if not scipy:
skip("scipy not installed")

hn = lambdify((x,), harmonic(x), modules='scipy')
assert hn(2) == 1.5
hnm = lambdify((x, y), harmonic(x, y), modules='scipy')
assert hnm(2, 2) == 1.25


def test_cupy_array_arg():
if not cupy:
skip("CuPy not installed")
Expand Down

0 comments on commit e63a2e6

Please sign in to comment.