blob: e21c1a5f7f4df663835dd7e10f88c9773f48fcb5 [file] [log] [blame]
Wenzel Jakob57082212015-09-04 23:42:12 +02001#!/usr/bin/env python
2from __future__ import print_function
Wenzel Jakobd4258ba2015-07-26 16:33:49 +02003import sys
4sys.path.append('.')
5
6import example
Wenzel Jakobfab881c2015-10-18 17:04:24 +02007try:
8 import numpy as np
9except ImportError:
Jason Rhinelander7de9f6c2016-07-08 17:44:12 -040010 # NumPy missing: skip test
11 exit(99)
Wenzel Jakobd4258ba2015-07-26 16:33:49 +020012
13from example import vectorized_func
14from example import vectorized_func2
Wenzel Jakob43398a82015-07-28 16:12:20 +020015from example import vectorized_func3
16
17print(vectorized_func3(np.array(3+7j)))
Wenzel Jakobd4258ba2015-07-26 16:33:49 +020018
19for f in [vectorized_func, vectorized_func2]:
20 print(f(1, 2, 3))
21 print(f(np.array(1), np.array(2), 3))
22 print(f(np.array([1, 3]), np.array([2, 4]), 3))
23 print(f(np.array([[1, 3, 5], [7, 9, 11]]), np.array([[2, 4, 6], [8, 10, 12]]), 3))
24 print(np.array([[1, 3, 5], [7, 9, 11]])* np.array([[2, 4, 6], [8, 10, 12]])*3)
Johan Mabille1dc960c2016-02-11 10:47:11 +010025 print(f(np.array([[1, 2, 3], [4, 5, 6]]), np.array([2, 3, 4]), 2))
26 print(np.array([[1, 2, 3], [4, 5, 6]])* np.array([2, 3, 4])* 2)
27 print(f(np.array([[1, 2, 3], [4, 5, 6]]), np.array([[2], [3]]), 2))
28 print(np.array([[1, 2, 3], [4, 5, 6]])* np.array([[2], [3]])* 2)
29
Wenzel Jakobb47a9de2016-05-19 16:02:09 +020030from example import selective_func
31
32selective_func(np.array([1], dtype=np.int32))
33selective_func(np.array([1.0], dtype=np.float32))
34selective_func(np.array([1.0j], dtype=np.complex64))