MCPcopy Create free account
hub / github.com/Kaggle/docker-python / test_jit

Method test_jit

tests/test_numba.py:9–19  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7
8class 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):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected