def test_inspect_function_on_np_all(self): info = inspect_function(np.all) self.check_function_descriptor(info, must_be_defined=True) source_infos = info["source_infos"] self.assertGreater(len(source_infos), 0) c = 0 for srcinfo in source_infos.values(): self.assertIsInstance(srcinfo["kind"], str) self.assertIsInstance(srcinfo["name"], str) self.assertIsInstance(srcinfo["sig"], str) self.assertIsInstance(srcinfo["filename"], str) self.assertIsInstance(srcinfo["lines"], tuple) self.assertIn("docstring", srcinfo) c += 1 self.assertEqual(c, len(source_infos))
def test_inspect_function_on_np_all(self): info = inspect_function(np.all) self.check_function_descriptor(info, must_be_defined=True) source_infos = info['source_infos'] self.assertGreater(len(source_infos), 0) c = 0 for srcinfo in source_infos.values(): self.assertIsInstance(srcinfo['kind'], str) self.assertIsInstance(srcinfo['name'], str) self.assertIsInstance(srcinfo['sig'], str) self.assertIsInstance(srcinfo['filename'], str) self.assertIsInstance(srcinfo['lines'], tuple) self.assertIn('docstring', srcinfo) c += 1 self.assertEqual(c, len(source_infos))
def _jit_func(obj_or_fun, show_code=False, **jit_setting): if callable(obj_or_fun): # integrator if isinstance(obj_or_fun, Integrator): return _jit_intg(obj_or_fun, show_code=show_code, **jit_setting) # bounded method elif hasattr(obj_or_fun, '__self__') and isinstance( obj_or_fun.__self__, Base): return _jit_cls_func(obj_or_fun, host=obj_or_fun.__self__, show_code=show_code, **jit_setting) # wrapped function elif isinstance(obj_or_fun, Function): return _jit_Function(obj_or_fun, show_code=show_code, **jit_setting) # base class function elif isinstance(obj_or_fun, Base): return _jit_cls_func(obj_or_fun.__call__, host=obj_or_fun, show_code=show_code, **jit_setting) else: # native function if not isinstance(obj_or_fun, Dispatcher): if inspector.inspect_function( obj_or_fun)['numba_type'] is None: f = numba.jit(obj_or_fun, **jit_setting) return dict(func=f, arguments=set(), arg2call=Collector(), nodes=Collector()) # numba function or innate supported function return dict(func=obj_or_fun, arguments=set(), arg2call=Collector(), nodes=Collector()) else: raise ValueError
def test_inspect_function_on_range(self): info = inspect_function(range) self.check_function_descriptor(info, must_be_defined=True)