test_common.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from __future__ import division, print_function, absolute_import
  2. import pytest
  3. from numpy.testing import assert_equal, assert_allclose, assert_almost_equal
  4. from scipy._lib._numpy_compat import suppress_warnings
  5. from scipy.misc import pade, logsumexp, face, ascent, electrocardiogram
  6. from scipy.special import logsumexp as sc_logsumexp
  7. def test_logsumexp():
  8. # make sure logsumexp can be imported from either scipy.misc or
  9. # scipy.special
  10. with suppress_warnings() as sup:
  11. sup.filter(DeprecationWarning, "`logsumexp` is deprecated")
  12. assert_allclose(logsumexp([0, 1]), sc_logsumexp([0, 1]), atol=1e-16)
  13. def test_pade():
  14. # make sure scipy.misc.pade exists
  15. with suppress_warnings() as sup:
  16. sup.filter(DeprecationWarning, "`pade` is deprecated")
  17. pade([1, 2], 1)
  18. def test_face():
  19. assert_equal(face().shape, (768, 1024, 3))
  20. def test_ascent():
  21. assert_equal(ascent().shape, (512, 512))
  22. def test_electrocardiogram():
  23. # Test shape, dtype and stats of signal
  24. ecg = electrocardiogram()
  25. assert ecg.dtype == float
  26. assert_equal(ecg.shape, (108000,))
  27. assert_almost_equal(ecg.mean(), -0.16510875)
  28. assert_almost_equal(ecg.std(), 0.5992473991177294)