test_sici.py 1.2 KB

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