You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
1.1 KiB

  1. #!/usr/bin/env python
  2. from __future__ import print_function
  3. import sys
  4. sys.path.append('.')
  5. import example
  6. try:
  7. import numpy as np
  8. except ImportError:
  9. print('NumPy missing')
  10. exit(0)
  11. from example import vectorized_func
  12. from example import vectorized_func2
  13. from example import vectorized_func3
  14. print(vectorized_func3(np.array(3+7j)))
  15. for f in [vectorized_func, vectorized_func2]:
  16. print(f(1, 2, 3))
  17. print(f(np.array(1), np.array(2), 3))
  18. print(f(np.array([1, 3]), np.array([2, 4]), 3))
  19. print(f(np.array([[1, 3, 5], [7, 9, 11]]), np.array([[2, 4, 6], [8, 10, 12]]), 3))
  20. print(np.array([[1, 3, 5], [7, 9, 11]])* np.array([[2, 4, 6], [8, 10, 12]])*3)
  21. print(f(np.array([[1, 2, 3], [4, 5, 6]]), np.array([2, 3, 4]), 2))
  22. print(np.array([[1, 2, 3], [4, 5, 6]])* np.array([2, 3, 4])* 2)
  23. print(f(np.array([[1, 2, 3], [4, 5, 6]]), np.array([[2], [3]]), 2))
  24. print(np.array([[1, 2, 3], [4, 5, 6]])* np.array([[2], [3]])* 2)
  25. from example import selective_func
  26. selective_func(np.array([1], dtype=np.int32))
  27. selective_func(np.array([1.0], dtype=np.float32))
  28. selective_func(np.array([1.0j], dtype=np.complex64))