def test_nonempty_list_create_no_jit(self): # See Issue #6001: https://github.com/numba/numba/issues/6001 with override_config('DISABLE_JIT', True): with forbid_codegen(): l = List([1, 2, 3]) self.assertEqual(type(l), list) self.assertEqual(l, [1, 2, 3])
def test_jitclass(self): with override_config('DISABLE_JIT', True): with forbid_codegen(): SimpleJITClass = jitclass(simple_class_spec)(SimpleClass) obj = SimpleJITClass() self.assertPreciseEqual(obj.h, 5) cfunc = jit(nopython=True)(simple_class_user) self.assertPreciseEqual(cfunc(obj), 5)
def test_forbid_codegen(self): """ Test that forbid_codegen() prevents code generation using the @jit decorator. """ def f(): return 1 with forbid_codegen(): with self.assertRaises(RuntimeError) as raises: cfunc = jit(nopython=True)(f) cfunc() self.assertIn("codegen forbidden by test case", str(raises.exception))
def test_list_create_no_jit_using_List(self): with override_config('DISABLE_JIT', True): with forbid_codegen(): l = List() self.assertEqual(type(l), list)
def test_dict_create_no_jit_using_empty(self): with override_config('DISABLE_JIT', True): with forbid_codegen(): d = Dict.empty(types.int32, types.float32) self.assertEqual(type(d), dict)
def test_dict_create_no_jit_using_Dict(self): with override_config('DISABLE_JIT', True): with forbid_codegen(): d = Dict() self.assertEqual(type(d), dict)
def test_dict_create_no_jit_using_new_dict(self): with override_config('DISABLE_JIT', True): with forbid_codegen(): d = dictobject.new_dict(int32, float32) self.assertEqual(type(d), dict)
def test_list_create_no_jit(self): with override_config('DISABLE_JIT', True): with forbid_codegen(): l = listobject.new_list(int32) self.assertEqual(type(l), list)
def test_jit(self): with override_config('DISABLE_JIT', True): with forbid_codegen(): cfunc = jit(nopython=True)(simple_nopython) self.assertPreciseEqual(cfunc(2), 3)
def test_list_create_no_jit_using_empty_list(self): with override_config("DISABLE_JIT", True): with forbid_codegen(): l = List.empty_list(types.int32) self.assertEqual(type(l), list)