Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""
Tests whether things works independent of where symbols are imported from.
"""
import jitcode
import jitcode.sympy_symbols
import sympy
import symengine
symengine_manually = [
symengine.Symbol("t",real=True),
symengine.Function("y",real=True),
symengine.cos,
]
sympy_manually = [
sympy.Symbol("t",real=True),
sympy.Function("y",real=True),
sympy.cos,
]
jitcode_provisions = [
jitcode.t,
jitcode.y,
symengine.cos,
]
jitcode_sympy_provisions = [
jitcode.sympy_symbols.t,
sympy_manually = [
sympy_t,
sympy_y,
sympy.cos,
]
jitcdde_provisions = [
jitcdde.t,
jitcdde.y,
symengine.cos,
]
jitcdde_sympy_provisions = [
jitcdde.sympy_symbols.t,
jitcdde.sympy_symbols.y,
symengine.cos,
]
mixed = [
jitcdde.sympy_symbols.t,
jitcdde.y,
sympy.cos,
]
results = set()
for t,y,cos in [
symengine_manually,
sympy_manually,
jitcdde_provisions,
jitcdde_sympy_provisions,
mixed,
der = (_x ** 2 - 1) ** L
den = 2 ** L * facts[L]
for _ in range(L):
der = der.diff(_x)
for m in range(L + 1):
pol = (1 - _x ** 2) ** (m/2)
if m: der = der.diff(_x)
leg = phase[m] / den * (pol * der).subs({_x: _z / _r})
if not m:
sh[L][m] = rac * leg
continue
N = 2 ** 0.5 * phase[m]
facs = facts[L - m] / facts[L + m]
norm = facs ** 0.5
phi = (m * _x).subs({_x: 'arctan2(_y, _x)'})
fun = cos(phi)
sh[L][m] = N * rac * norm * leg * fun
fun = sin(phi)
sh[L][-m] = N * rac * norm * leg * fun
return sh