Python C extension to compute the permanent.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

test.py 704B

123456789101112131415161718192021222324252627
  1. import numpy as np
  2. from permanent import permanent
  3. from nose.tools import raises
  4. def test_permanent():
  5. """ Dumb tests """
  6. m = np.eye(10, dtype=complex)
  7. assert permanent(m) == 1
  8. m = np.zeros((10, 10), dtype=complex)
  9. assert permanent(m) == 0
  10. def test_floaty():
  11. """ More tests using a precomputed permanent """
  12. np.random.seed(1234)
  13. m = np.random.uniform(0, 1, 16) + 1j*np.random.uniform(0, 1, 16)
  14. m = m.reshape(4,4)
  15. p = permanent(m)
  16. assert np.allclose(p, -8.766131870776363+1.072095650303524j)
  17. @raises(TypeError)
  18. def test_error():
  19. """ Should raise a TypeError as we are using the wrong dtype """
  20. m = np.eye(10, dtype=float)
  21. permanent(m)