test_sici.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. from __future__ import division, print_function, absolute_import
  2. import numpy as np
  3. import scipy.special as sc
  4. from scipy.special._testutils import FuncData
  5. def test_sici_consistency():
  6. # Make sure the implementation of sici for real arguments agrees
  7. # with the implementation of sici for complex arguments.
  8. # On the negative real axis Cephes drops the imaginary part in ci
  9. def sici(x):
  10. si, ci = sc.sici(x + 0j)
  11. return si.real, ci.real
  12. x = np.r_[-np.logspace(8, -30, 200), 0, np.logspace(-30, 8, 200)]
  13. si, ci = sc.sici(x)
  14. dataset = np.column_stack((x, si, ci))
  15. FuncData(sici, dataset, 0, (1, 2), rtol=1e-12).check()
  16. def test_shichi_consistency():
  17. # Make sure the implementation of shichi for real arguments agrees
  18. # with the implementation of shichi for complex arguments.
  19. # On the negative real axis Cephes drops the imaginary part in chi
  20. def shichi(x):
  21. shi, chi = sc.shichi(x + 0j)
  22. return shi.real, chi.real
  23. # Overflow happens quickly, so limit range
  24. x = np.r_[-np.logspace(np.log10(700), -30, 200), 0,
  25. np.logspace(-30, np.log10(700), 200)]
  26. shi, chi = sc.shichi(x)
  27. dataset = np.column_stack((x, shi, chi))
  28. FuncData(shichi, dataset, 0, (1, 2), rtol=1e-14).check()