test_scipy.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. # This testfile tests SymPy <-> SciPy compatibility
  2. # Don't test any SymPy features here. Just pure interaction with SciPy.
  3. # Always write regular SymPy tests for anything, that can be tested in pure
  4. # Python (without scipy). Here we test everything, that a user may need when
  5. # using SymPy with SciPy
  6. from sympy.external import import_module
  7. scipy = import_module('scipy')
  8. if not scipy:
  9. #bin/test will not execute any tests now
  10. disabled = True
  11. from sympy.functions.special.bessel import jn_zeros
  12. def eq(a, b, tol=1e-6):
  13. for x, y in zip(a, b):
  14. if not (abs(x - y) < tol):
  15. return False
  16. return True
  17. def test_jn_zeros():
  18. assert eq(jn_zeros(0, 4, method="scipy"),
  19. [3.141592, 6.283185, 9.424777, 12.566370])
  20. assert eq(jn_zeros(1, 4, method="scipy"),
  21. [4.493409, 7.725251, 10.904121, 14.066193])
  22. assert eq(jn_zeros(2, 4, method="scipy"),
  23. [5.763459, 9.095011, 12.322940, 15.514603])
  24. assert eq(jn_zeros(3, 4, method="scipy"),
  25. [6.987932, 10.417118, 13.698023, 16.923621])
  26. assert eq(jn_zeros(4, 4, method="scipy"),
  27. [8.182561, 11.704907, 15.039664, 18.301255])