Skip to content

Commit

Permalink
sage.functions: More modularization fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthias Koeppe committed Jul 15, 2023
1 parent 5095c65 commit 29f49d5
Show file tree
Hide file tree
Showing 9 changed files with 388 additions and 386 deletions.
36 changes: 17 additions & 19 deletions src/sage/functions/airy.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,17 @@
# https://www.gnu.org/licenses/
# ****************************************************************************

from sage.symbolic.function import BuiltinFunction
from sage.symbolic.expression import Expression
from sage.symbolic.ring import SR
from sage.rings.integer_ring import ZZ
from sage.calculus.functional import derivative
from sage.misc.lazy_import import lazy_import
from sage.rings.integer_ring import ZZ
from sage.structure.element import Expression
from sage.symbolic.function import BuiltinFunction

lazy_import('sage.symbolic.ring', 'SR')

lazy_import('sage.libs.mpmath.utils', 'call', as_='_mpmath_utils_call')
lazy_import('mpmath', ['airyai', 'airybi'],
as_=['_mpmath_airyai', '_mpmath_airybi'])


class FunctionAiryAiGeneral(BuiltinFunction):
Expand Down Expand Up @@ -142,10 +148,8 @@ def _evalf_(self, alpha, x, parent=None, algorithm=None):
sage: airy_ai_general(-2, 1.0) # needs mpmath
0.136645379421096
"""
import mpmath
from sage.libs.mpmath import utils as mpmath_utils
return mpmath_utils.call(mpmath.airyai, x, derivative=alpha,
parent=parent)
return _mpmath_utils_call(_mpmath_airyai, x, derivative=alpha,
parent=parent)


class FunctionAiryAiSimple(BuiltinFunction):
Expand Down Expand Up @@ -248,9 +252,7 @@ def _evalf_(self, x, **kwargs):
return CC(y)
return parent(y)
elif algorithm == 'mpmath':
import mpmath
from sage.libs.mpmath import utils as mpmath_utils
return mpmath_utils.call(mpmath.airyai, x, parent=parent)
return _mpmath_utils_call(_mpmath_airyai, x, parent=parent)
else:
raise ValueError("unknown algorithm '%s'" % algorithm)

Expand Down Expand Up @@ -350,9 +352,7 @@ def _evalf_(self, x, **kwargs):
return CC(y)
return parent(y)
elif algorithm == 'mpmath':
import mpmath
from sage.libs.mpmath import utils as mpmath_utils
return mpmath_utils.call(mpmath.airyai, x, derivative=1,
return _mpmath_utils_call(_mpmath_airyai, x, derivative=1,
parent=parent)
else:
raise ValueError("unknown algorithm '%s'" % algorithm)
Expand Down Expand Up @@ -586,7 +586,7 @@ def _evalf_(self, alpha, x, **kwargs):
parent = kwargs.get('parent')
import mpmath
from sage.libs.mpmath import utils as mpmath_utils
return mpmath_utils.call(mpmath.airybi, x, derivative=alpha,
return _mpmath_utils_call(_mpmath_airybi, x, derivative=alpha,
parent=parent)


Expand Down Expand Up @@ -694,7 +694,7 @@ def _evalf_(self, x, **kwargs):
elif algorithm == 'mpmath':
import mpmath
from sage.libs.mpmath import utils as mpmath_utils
return mpmath_utils.call(mpmath.airybi, x, parent=parent)
return _mpmath_utils_call(_mpmath_airybi, x, parent=parent)
else:
raise ValueError("unknown algorithm '%s'" % algorithm)

Expand Down Expand Up @@ -794,9 +794,7 @@ def _evalf_(self, x, **kwargs):
return CC(y)
return parent(y)
elif algorithm == 'mpmath':
import mpmath
from sage.libs.mpmath import utils as mpmath_utils
return mpmath_utils.call(mpmath.airybi, x, derivative=1,
return _mpmath_utils_call(_mpmath_airybi, x, derivative=1,
parent=parent)
else:
raise ValueError("unknown algorithm '%s'" % algorithm)
Expand Down
Loading

0 comments on commit 29f49d5

Please sign in to comment.