(self)
| 7 | |
| 8 | class TestNumba(unittest.TestCase): |
| 9 | def test_jit(self): |
| 10 | x = np.arange(100).reshape(10, 10) |
| 11 | |
| 12 | @jit(nopython=True) # Set "nopython" mode for best performance, equivalent to @njit |
| 13 | def go_fast(a): # Function is compiled to machine code when called the first time |
| 14 | trace = 0.0 |
| 15 | for i in range(a.shape[0]): # Numba likes loops |
| 16 | trace += np.tanh(a[i, i]) # Numba likes NumPy functions |
| 17 | return a + trace # Numba likes NumPy broadcasting |
| 18 | |
| 19 | self.assertEqual(10, go_fast(x).shape[0]) |
| 20 | |
| 21 | @gpu_test |
| 22 | def test_cuda_jit(self): |
nothing calls this directly
no outgoing calls
no test coverage detected