[ { "hash": "f0069cde8a80146ebfc322a484aefccfb9f0e8c4", "msg": "1) Finished applying ppimport hooks to scipy.\nNew scipy import timings on PII 400MHz, Debian\nwith postponed import hooks enabled:\n\npearu@localhost:~$ time python2.2 -c 'import scipy'\nreal 0m1.392s\nuser 0m1.320s\nsys 0m0.060s\npearu@localhost:~$ time python2.3 -c 'import scipy'\nreal 0m0.691s\nuser 0m0.650s\nsys 0m0.030s\n\nFor reference, importing scipy to Python 2.2 used\nto take 2-16 seconds depending on whether scipy was\nloaded before or not.\n\n2) New feature in ppimport:\nWhen pre_.py* exists for ppimported\nmodule then this pre_*.py file will\nbe executed to initialize additional attributes\nto postponed module loader. For a python package,\n/pre___init__.py is used to add\nattributes to package loader.\nThis feature is useful for importing documentation\nstrings of a package/module without importing them.\nCurrently this works with scipy.info but I haven't\ntested with pydoc.help yet.\n\n3) Made initial steps for getting scipy documentation\nstrings parsable by docutils.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-03-22T22:28:17+00:00", "author_timezone": 0, "committer_date": "2003-03-22T22:28:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d396654329f4b0eecaba536566c9ff25a69e472e" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 7, "insertions": 21, "lines": 28, "files": 3, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/ppimport.py", "new_path": "scipy_base/ppimport.py", "filename": "ppimport.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -109,10 +109,16 @@ def ppimport(name):\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n- else:\n+ elif p_frame.f_locals.has_key('__path__'):\n+ # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n+ else:\n+ # python module, not tested\n+ p_file = p_frame.f_locals['__file__']\n+ p_dir = os.path.dirname(p_file)\n+ fullname = p_name + '.' + name\n \n module = sys.modules.get(fullname)\n if module is not None:\n", "added_lines": 7, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n self.__dict__ = attr.__dict__\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n module = sys.modules[name]\n assert module is self,`module`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n module = __import__(name,None,None,['*'])\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n self.__dict__ = attr.__dict__\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n else:\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n module = sys.modules[name]\n assert module is self,`module`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n module = __import__(name,None,None,['*'])\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\n", "methods": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "self" ], "start_line": 57, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 76, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 91, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 99, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 156, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 10, "complexity": 1, "token_count": 77, "parameters": [ "self" ], "start_line": 175, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 191, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 198, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "self" ], "start_line": 205, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "self" ], "start_line": 57, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 76, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 91, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 30, "complexity": 6, "token_count": 203, "parameters": [ "name" ], "start_line": 99, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 150, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 10, "complexity": 1, "token_count": 77, "parameters": [ "self" ], "start_line": 169, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 185, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 192, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "self" ], "start_line": 199, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 99, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 } ], "nloc": 151, "complexity": 40, "token_count": 940, "diff_parsed": { "added": [ " elif p_frame.f_locals.has_key('__path__'):", " # python package", " else:", " # python module, not tested", " p_file = p_frame.f_locals['__file__']", " p_dir = os.path.dirname(p_file)", " fullname = p_name + '.' + name" ], "deleted": [ " else:" ] } }, { "old_path": "weave/__init__.py", "new_path": "weave/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,10 +1,9 @@\n-\"\"\" compiler provides several tools:\n+#\n+# weave - C/C++ integration\n+#\n \n- 1. inline() -- a function for including C/C++ code within Python\n- 2. blitz() -- a function for compiling Numeric expressions to C++\n- 3. ext_tools-- a module that helps construct C/C++ extension modules.\n- 4. accelerate -- a module that inline accelerates Python functions\n-\"\"\"\n+import os as _os\n+execfile(_os.path.join(__path__[0],'pre___init__.py'),globals(),locals())\n \n from weave_version import weave_version as __version__\n \n", "added_lines": 5, "deleted_lines": 6, "source_code": "#\n# weave - C/C++ integration\n#\n\nimport os as _os\nexecfile(_os.path.join(__path__[0],'pre___init__.py'),globals(),locals())\n\nfrom weave_version import weave_version as __version__\n\ntry:\n from blitz_tools import blitz\nexcept ImportError:\n pass # Numeric wasn't available \n \nfrom inline_tools import inline\nimport ext_tools\nfrom ext_tools import ext_module, ext_function\ntry:\n from accelerate_tools import accelerate\nexcept:\n pass\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite(level))\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import weave\n return scipy_test.testing.harvest_test_suites(weave,level=level)\n", "source_code_before": "\"\"\" compiler provides several tools:\n\n 1. inline() -- a function for including C/C++ code within Python\n 2. blitz() -- a function for compiling Numeric expressions to C++\n 3. ext_tools-- a module that helps construct C/C++ extension modules.\n 4. accelerate -- a module that inline accelerates Python functions\n\"\"\"\n\nfrom weave_version import weave_version as __version__\n\ntry:\n from blitz_tools import blitz\nexcept ImportError:\n pass # Numeric wasn't available \n \nfrom inline_tools import inline\nimport ext_tools\nfrom ext_tools import ext_module, ext_function\ntry:\n from accelerate_tools import accelerate\nexcept:\n pass\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite(level))\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import weave\n return scipy_test.testing.harvest_test_suites(weave,level=level)\n", "methods": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "level" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 31, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "level" ], "start_line": 26, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 32, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 23, "complexity": 2, "token_count": 120, "diff_parsed": { "added": [ "#", "# weave - C/C++ integration", "#", "import os as _os", "execfile(_os.path.join(__path__[0],'pre___init__.py'),globals(),locals())" ], "deleted": [ "\"\"\" compiler provides several tools:", " 1. inline() -- a function for including C/C++ code within Python", " 2. blitz() -- a function for compiling Numeric expressions to C++", " 3. ext_tools-- a module that helps construct C/C++ extension modules.", " 4. accelerate -- a module that inline accelerates Python functions", "\"\"\"" ] } }, { "old_path": null, "new_path": "weave/pre___init__.py", "filename": "pre___init__.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,9 @@\n+\"\"\"\n+C/C++ integration\n+=================\n+\n+ 1. inline() -- a function for including C/C++ code within Python\n+ 2. blitz() -- a function for compiling Numeric expressions to C++\n+ 3. ext_tools-- a module that helps construct C/C++ extension modules.\n+ 4. accelerate -- a module that inline accelerates Python functions\n+\"\"\"\n", "added_lines": 9, "deleted_lines": 0, "source_code": "\"\"\"\nC/C++ integration\n=================\n\n 1. inline() -- a function for including C/C++ code within Python\n 2. blitz() -- a function for compiling Numeric expressions to C++\n 3. ext_tools-- a module that helps construct C/C++ extension modules.\n 4. accelerate -- a module that inline accelerates Python functions\n\"\"\"\n", "source_code_before": null, "methods": [], "methods_before": [], "changed_methods": [], "nloc": 9, "complexity": 0, "token_count": 1, "diff_parsed": { "added": [ "\"\"\"", "C/C++ integration", "=================", "", " 1. inline() -- a function for including C/C++ code within Python", " 2. blitz() -- a function for compiling Numeric expressions to C++", " 3. ext_tools-- a module that helps construct C/C++ extension modules.", " 4. accelerate -- a module that inline accelerates Python functions", "\"\"\"" ], "deleted": [] } } ] }, { "hash": "aba4027dd43ebb2e3c839595d8690bc0dfb70706", "msg": "Backport to Py2.1 where update will not be available (PyDict_Merge is new to Py2.2)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-03-24T19:00:16+00:00", "author_timezone": 0, "committer_date": "2003-03-24T19:00:16+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f0069cde8a80146ebfc322a484aefccfb9f0e8c4" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 2, "lines": 3, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/scxx/dict.h", "new_path": "weave/scxx/dict.h", "filename": "dict.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -155,10 +155,11 @@ public:\n //-------------------------------------------------------------------------\n // update\n //------------------------------------------------------------------------- \n+#if PY_VERSION_HEX >= 0x02020000\n void update(dict& other) {\n PyDict_Merge(_obj,other,1);\n };\n- \n+#endif\n //-------------------------------------------------------------------------\n // del -- remove key from dictionary\n // overloaded to take all common weave types\n", "added_lines": 2, "deleted_lines": 1, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(DICT_H_INCLUDED_)\n#define DICT_H_INCLUDED_\n#include \n#include \"object.h\"\n#include \"list.h\"\n\nnamespace py {\n\n\nclass dict : public object\n{\npublic:\n\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n dict() : object (PyDict_New()) { lose_ref(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~dict() {};\n\n //-------------------------------------------------------------------------\n // operator= \n //-------------------------------------------------------------------------\n virtual dict& operator=(const dict& other) {\n grab_ref(other);\n return *this;\n };\n dict& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n\n //-------------------------------------------------------------------------\n // type checking\n //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n if (!PyDict_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a dictionary\");\n }\n };\n \n //-------------------------------------------------------------------------\n // operator[] -- object and numeric versions\n //------------------------------------------------------------------------- \n keyed_ref operator [] (object& key) {\n object rslt = PyDict_GetItem(_obj, key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n return keyed_ref(rslt, *this, key);\n };\n keyed_ref operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n };\n \n //-------------------------------------------------------------------------\n // operator[] non-const -- string versions\n //-------------------------------------------------------------------------\n keyed_ref operator [] (const char* key) {\n object rslt = PyDict_GetItemString(_obj, (char*) key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n object _key = key; \n return keyed_ref(rslt, *this, _key);\n };\n keyed_ref operator [] (const std::string& key) {\n return operator [](key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // has_key -- object and numeric versions\n //------------------------------------------------------------------------- \n bool has_key(object& key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n bool has_key(int key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(double key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(const std::complex& key) const {\n object _key = key; \n return has_key(_key);\n };\n\n //-------------------------------------------------------------------------\n // has_key -- string versions\n //-------------------------------------------------------------------------\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n bool has_key(const std::string& key) const {\n return has_key(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // len and length methods\n //------------------------------------------------------------------------- \n int len() const {\n return PyDict_Size(_obj);\n } \n int length() const {\n return PyDict_Size(_obj);\n };\n\n //-------------------------------------------------------------------------\n // set_item\n //-------------------------------------------------------------------------\n virtual void set_item(const char* key, object& val) {\n int rslt = PyDict_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n\n virtual void set_item(object& key, object& val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key must be hashable\");\n };\n\n //-------------------------------------------------------------------------\n // clear\n //------------------------------------------------------------------------- \n void clear() {\n PyDict_Clear(_obj);\n };\n \n //-------------------------------------------------------------------------\n // update\n //------------------------------------------------------------------------- \n#if PY_VERSION_HEX >= 0x02020000\n void update(dict& other) {\n PyDict_Merge(_obj,other,1);\n };\n#endif\n //-------------------------------------------------------------------------\n // del -- remove key from dictionary\n // overloaded to take all common weave types\n //-------------------------------------------------------------------------\n void del(object& key) {\n int rslt = PyDict_DelItem(_obj, key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(int key) {\n object _key = key;\n del(_key);\n };\n void del(double key) {\n object _key = key;\n del(_key);\n };\n void del(const std::complex& key) {\n object _key = key;\n del(_key);\n };\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(const std::string key) {\n del(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // items, keys, and values\n //-------------------------------------------------------------------------\n list items() const {\n PyObject* rslt = PyDict_Items(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get items\");\n return lose_ref(rslt);\n };\n\n list keys() const {\n PyObject* rslt = PyDict_Keys(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get keys\");\n return lose_ref(rslt);\n };\n\n list values() const {\n PyObject* rslt = PyDict_Values(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get values\");\n return lose_ref(rslt);\n };\n};\n\n} // namespace\n#endif // DICT_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(DICT_H_INCLUDED_)\n#define DICT_H_INCLUDED_\n#include \n#include \"object.h\"\n#include \"list.h\"\n\nnamespace py {\n\n\nclass dict : public object\n{\npublic:\n\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n dict() : object (PyDict_New()) { lose_ref(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~dict() {};\n\n //-------------------------------------------------------------------------\n // operator= \n //-------------------------------------------------------------------------\n virtual dict& operator=(const dict& other) {\n grab_ref(other);\n return *this;\n };\n dict& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n\n //-------------------------------------------------------------------------\n // type checking\n //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n if (!PyDict_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a dictionary\");\n }\n };\n \n //-------------------------------------------------------------------------\n // operator[] -- object and numeric versions\n //------------------------------------------------------------------------- \n keyed_ref operator [] (object& key) {\n object rslt = PyDict_GetItem(_obj, key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n return keyed_ref(rslt, *this, key);\n };\n keyed_ref operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n };\n \n //-------------------------------------------------------------------------\n // operator[] non-const -- string versions\n //-------------------------------------------------------------------------\n keyed_ref operator [] (const char* key) {\n object rslt = PyDict_GetItemString(_obj, (char*) key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n object _key = key; \n return keyed_ref(rslt, *this, _key);\n };\n keyed_ref operator [] (const std::string& key) {\n return operator [](key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // has_key -- object and numeric versions\n //------------------------------------------------------------------------- \n bool has_key(object& key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n bool has_key(int key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(double key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(const std::complex& key) const {\n object _key = key; \n return has_key(_key);\n };\n\n //-------------------------------------------------------------------------\n // has_key -- string versions\n //-------------------------------------------------------------------------\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n bool has_key(const std::string& key) const {\n return has_key(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // len and length methods\n //------------------------------------------------------------------------- \n int len() const {\n return PyDict_Size(_obj);\n } \n int length() const {\n return PyDict_Size(_obj);\n };\n\n //-------------------------------------------------------------------------\n // set_item\n //-------------------------------------------------------------------------\n virtual void set_item(const char* key, object& val) {\n int rslt = PyDict_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n\n virtual void set_item(object& key, object& val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key must be hashable\");\n };\n\n //-------------------------------------------------------------------------\n // clear\n //------------------------------------------------------------------------- \n void clear() {\n PyDict_Clear(_obj);\n };\n \n //-------------------------------------------------------------------------\n // update\n //------------------------------------------------------------------------- \n void update(dict& other) {\n PyDict_Merge(_obj,other,1);\n };\n \n //-------------------------------------------------------------------------\n // del -- remove key from dictionary\n // overloaded to take all common weave types\n //-------------------------------------------------------------------------\n void del(object& key) {\n int rslt = PyDict_DelItem(_obj, key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(int key) {\n object _key = key;\n del(_key);\n };\n void del(double key) {\n object _key = key;\n del(_key);\n };\n void del(const std::complex& key) {\n object _key = key;\n del(_key);\n };\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(const std::string key) {\n del(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // items, keys, and values\n //-------------------------------------------------------------------------\n list items() const {\n PyObject* rslt = PyDict_Items(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get items\");\n return lose_ref(rslt);\n };\n\n list keys() const {\n PyObject* rslt = PyDict_Keys(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get keys\");\n return lose_ref(rslt);\n };\n\n list values() const {\n PyObject* rslt = PyDict_Values(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get values\");\n return lose_ref(rslt);\n };\n};\n\n} // namespace\n#endif // DICT_H_INCLUDED_\n", "methods": [ { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 42, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 51, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( object & key)", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "key" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 75, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "key" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( object & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( int key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( double key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: complex & key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: string & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 119, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 129, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , object & val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 136, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( object & key , object & val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 142, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::update", "long_name": "py::dict::update( dict & other)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 159, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( object & key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 167, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 172, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 176, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 180, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: string key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 42, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 51, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( object & key)", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "key" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 75, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "key" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( object & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( int key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( double key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: complex & key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: string & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 119, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 129, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , object & val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 136, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( object & key , object & val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 142, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::update", "long_name": "py::dict::update( dict & other)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 158, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( object & key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 166, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 171, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 175, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 179, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 183, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: string key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 195, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 202, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "changed_methods": [], "nloc": 144, "complexity": 44, "token_count": 926, "diff_parsed": { "added": [ "#if PY_VERSION_HEX >= 0x02020000", "#endif" ], "deleted": [ "" ] } } ] }, { "hash": "d419e6c49b96ff03ff67c7af439da3c94345e903", "msg": "added setup_extension() method to ext_module to return\r\ndistutils.core.Extension object for a weave generated extension. This\r\nis helpful in using weave extensions within setup.py files.\r\n\r\nadded logic inside ext_module.generate_module to check whether the\r\nnew extension module code is different from the code that may already \r\nexist in a previously generated extension module file. If the code is\r\nthe same, the file is not overwritten. This prevents setup.py from thinking\r\nthe module is always out of date and must be recompiled.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-03-25T10:41:21+00:00", "author_timezone": 0, "committer_date": "2003-03-25T10:41:21+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "aba4027dd43ebb2e3c839595d8690bc0dfb70706" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 50, "insertions": 98, "lines": 148, "files": 4, "dmm_unit_size": 0.8275862068965517, "dmm_unit_complexity": 0.5862068965517241, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/install_data.py", "new_path": "scipy_distutils/command/install_data.py", "filename": "install_data.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -6,7 +6,6 @@\n #of willy-nilly\n class install_data (old_install_data):\n def finalize_options (self):\n- print 'hhhhhhhhhhhheeeeeeeeeeerrrrrrrrrrrreeeeeeeeeeeee'\n self.set_undefined_options('install',\n ('install_lib', 'install_dir'),\n ('root', 'root'),\n", "added_lines": 0, "deleted_lines": 1, "source_code": "from distutils.command.install_data import *\nfrom distutils.command.install_data import install_data as old_install_data\n\n#data installer with improved intelligence over distutils\n#data files are copied into the project directory instead\n#of willy-nilly\nclass install_data (old_install_data):\n def finalize_options (self):\n self.set_undefined_options('install',\n ('install_lib', 'install_dir'),\n ('root', 'root'),\n ('force', 'force'),\n )\n", "source_code_before": "from distutils.command.install_data import *\nfrom distutils.command.install_data import install_data as old_install_data\n\n#data installer with improved intelligence over distutils\n#data files are copied into the project directory instead\n#of willy-nilly\nclass install_data (old_install_data):\n def finalize_options (self):\n print 'hhhhhhhhhhhheeeeeeeeeeerrrrrrrrrrrreeeeeeeeeeeee'\n self.set_undefined_options('install',\n ('install_lib', 'install_dir'),\n ('root', 'root'),\n ('force', 'force'),\n )\n", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "install_data.py", "nloc": 6, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 8, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "methods_before": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "install_data.py", "nloc": 7, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 8, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "install_data.py", "nloc": 7, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 8, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": 9, "complexity": 1, "token_count": 55, "diff_parsed": { "added": [], "deleted": [ " print 'hhhhhhhhhhhheeeeeeeeeeerrrrrrrrrrrreeeeeeeeeeeee'" ] } }, { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -66,7 +66,59 @@ def _init_posix():\n \n class CompileError(exceptions.Exception):\n pass\n+\n+\n+def create_extension(module_path, **kw):\n+ \"\"\" Create an Extension that can be buil by setup.py\n+ \n+ See build_extension for information on keyword arguments.\n+ \"\"\"\n+ from distutils.core import Extension\n+ \n+ # this is a screwy trick to get rid of a ton of warnings on Unix\n+ import distutils.sysconfig\n+ distutils.sysconfig.get_config_vars()\n+ if distutils.sysconfig._config_vars.has_key('OPT'):\n+ flags = distutils.sysconfig._config_vars['OPT'] \n+ flags = flags.replace('-Wall','')\n+ distutils.sysconfig._config_vars['OPT'] = flags\n \n+ # get the name of the module and the extension directory it lives in. \n+ module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n+ module_name,ext = os.path.splitext(cpp_name) \n+ \n+ # the business end of the function\n+ sources = kw.get('sources',[])\n+ kw['sources'] = [module_path] + sources \n+ \n+ #--------------------------------------------------------------------\n+ # added access to environment variable that user can set to specify\n+ # where python (and other) include files are located. This is \n+ # very useful on systems where python is installed by the root, but\n+ # the user has also installed numerous packages in their own \n+ # location.\n+ #--------------------------------------------------------------------\n+ if os.environ.has_key('PYTHONINCLUDE'):\n+ path_string = os.environ['PYTHONINCLUDE'] \n+ if sys.platform == \"win32\":\n+ extra_include_dirs = path_string.split(';')\n+ else: \n+ extra_include_dirs = path_string.split(':')\n+ include_dirs = kw.get('include_dirs',[])\n+ kw['include_dirs'] = include_dirs + extra_include_dirs\n+\n+ # SunOS specific\n+ # fix for issue with linking to libstdc++.a. see:\n+ # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n+ platform = sys.platform\n+ version = sys.version.lower()\n+ if platform[:5] == 'sunos' and version.find('gcc') != -1:\n+ extra_link_args = kw.get('extra_link_args',[])\n+ kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n+ \n+ ext = Extension(module_name, **kw)\n+ return ext \n+ \n def build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n@@ -197,37 +249,7 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n verb = 0\n \n t1 = time.time() \n- # add module to the needed source code files and build extension\n- sources = kw.get('sources',[])\n- kw['sources'] = [module_path] + sources \n- \n- #--------------------------------------------------------------------\n- # added access to environment variable that user can set to specify\n- # where python (and other) include files are located. This is \n- # very useful on systems where python is installed by the root, but\n- # the user has also installed numerous packages in their own \n- # location.\n- #--------------------------------------------------------------------\n- if os.environ.has_key('PYTHONINCLUDE'):\n- path_string = os.environ['PYTHONINCLUDE'] \n- if sys.platform == \"win32\":\n- extra_include_dirs = path_string.split(';')\n- else: \n- extra_include_dirs = path_string.split(':')\n- include_dirs = kw.get('include_dirs',[])\n- kw['include_dirs'] = include_dirs + extra_include_dirs\n-\n- # SunOS specific\n- # fix for issue with linking to libstdc++.a. see:\n- # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n- platform = sys.platform\n- version = sys.version.lower()\n- if platform[:5] == 'sunos' and version.find('gcc') != -1:\n- extra_link_args = kw.get('extra_link_args',[])\n- kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n- \n- ext = Extension(module_name, **kw)\n- \n+ ext = create_extension(module_path,**kw)\n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n", "added_lines": 53, "deleted_lines": 31, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n \n # The following line is a HACK to fix a problem with building the\n # freetype shared library under Mac OS X:\n ld += ' -framework AppKit'\n \n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n\n\ndef create_extension(module_path, **kw):\n \"\"\" Create an Extension that can be buil by setup.py\n \n See build_extension for information on keyword arguments.\n \"\"\"\n from distutils.core import Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # the business end of the function\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n return ext \n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n ext = create_extension(module_path,**kw)\n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n \n # The following line is a HACK to fix a problem with building the\n # freetype shared library under Mac OS X:\n ld += ' -framework AppKit'\n \n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n # add module to the needed source code files and build extension\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n \n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 13, "complexity": 3, "token_count": 95, "parameters": [], "start_line": 33, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "create_extension", "long_name": "create_extension( module_path , ** kw )", "filename": "build_tools.py", "nloc": 27, "complexity": 6, "token_count": 247, "parameters": [ "module_path", "kw" ], "start_line": 71, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 47, "complexity": 7, "token_count": 317, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 122, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 161, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 285, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 297, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 300, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 308, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 331, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 353, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 373, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 383, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 399, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 442, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "build_tools.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 505, "end_line": 545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 556, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 566, "end_line": 592, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 597, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 601, "end_line": 603, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 13, "complexity": 3, "token_count": 95, "parameters": [], "start_line": 33, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 62, "complexity": 11, "token_count": 454, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 70, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 191, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 263, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 278, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 286, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 309, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 331, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 351, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 361, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 377, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 420, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "build_tools.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 483, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 534, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 544, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 575, "end_line": 577, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 579, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "create_extension", "long_name": "create_extension( module_path , ** kw )", "filename": "build_tools.py", "nloc": 27, "complexity": 6, "token_count": 247, "parameters": [ "module_path", "kw" ], "start_line": 71, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 47, "complexity": 7, "token_count": 317, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 122, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 161, "top_nesting_level": 0 } ], "nloc": 330, "complexity": 67, "token_count": 1955, "diff_parsed": { "added": [ "", "", "def create_extension(module_path, **kw):", " \"\"\" Create an Extension that can be buil by setup.py", "", " See build_extension for information on keyword arguments.", " \"\"\"", " from distutils.core import Extension", "", " # this is a screwy trick to get rid of a ton of warnings on Unix", " import distutils.sysconfig", " distutils.sysconfig.get_config_vars()", " if distutils.sysconfig._config_vars.has_key('OPT'):", " flags = distutils.sysconfig._config_vars['OPT']", " flags = flags.replace('-Wall','')", " distutils.sysconfig._config_vars['OPT'] = flags", " # get the name of the module and the extension directory it lives in.", " module_dir,cpp_name = os.path.split(os.path.abspath(module_path))", " module_name,ext = os.path.splitext(cpp_name)", "", " # the business end of the function", " sources = kw.get('sources',[])", " kw['sources'] = [module_path] + sources", "", " #--------------------------------------------------------------------", " # added access to environment variable that user can set to specify", " # where python (and other) include files are located. This is", " # very useful on systems where python is installed by the root, but", " # the user has also installed numerous packages in their own", " # location.", " #--------------------------------------------------------------------", " if os.environ.has_key('PYTHONINCLUDE'):", " path_string = os.environ['PYTHONINCLUDE']", " if sys.platform == \"win32\":", " extra_include_dirs = path_string.split(';')", " else:", " extra_include_dirs = path_string.split(':')", " include_dirs = kw.get('include_dirs',[])", " kw['include_dirs'] = include_dirs + extra_include_dirs", "", " # SunOS specific", " # fix for issue with linking to libstdc++.a. see:", " # http://mail.python.org/pipermail/python-dev/2001-March/013510.html", " platform = sys.platform", " version = sys.version.lower()", " if platform[:5] == 'sunos' and version.find('gcc') != -1:", " extra_link_args = kw.get('extra_link_args',[])", " kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args", "", " ext = Extension(module_name, **kw)", " return ext", "", " ext = create_extension(module_path,**kw)" ], "deleted": [ " # add module to the needed source code files and build extension", " sources = kw.get('sources',[])", " kw['sources'] = [module_path] + sources", "", " #--------------------------------------------------------------------", " # added access to environment variable that user can set to specify", " # where python (and other) include files are located. This is", " # very useful on systems where python is installed by the root, but", " # the user has also installed numerous packages in their own", " # location.", " #--------------------------------------------------------------------", " if os.environ.has_key('PYTHONINCLUDE'):", " path_string = os.environ['PYTHONINCLUDE']", " if sys.platform == \"win32\":", " extra_include_dirs = path_string.split(';')", " else:", " extra_include_dirs = path_string.split(':')", " include_dirs = kw.get('include_dirs',[])", " kw['include_dirs'] = include_dirs + extra_include_dirs", "", " # SunOS specific", " # fix for issue with linking to libstdc++.a. see:", " # http://mail.python.org/pipermail/python-dev/2001-March/013510.html", " platform = sys.platform", " version = sys.version.lower()", " if platform[:5] == 'sunos' and version.find('gcc') != -1:", " extra_link_args = kw.get('extra_link_args',[])", " kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args", "", " ext = Extension(module_name, **kw)", "" ] } }, { "old_path": "weave/ext_tools.py", "new_path": "weave/ext_tools.py", "filename": "ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -283,19 +283,8 @@ def set_compiler(self,compiler):\n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n- \n- def compile(self,location='.',compiler=None, verbose = 0, **kw):\n- \n- if compiler is not None:\n- self.compiler = compiler\n- \n- # !! removed -- we don't have any compiler dependent code\n- # currently in spec or info classes \n- # hmm. Is there a cleaner way to do this? Seems like\n- # choosing the compiler spagettis around a little. \n- #compiler = build_tools.choose_compiler(self.compiler) \n- #self.set_compiler(compiler)\n- \n+\n+ def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n@@ -316,8 +305,28 @@ def compile(self,location='.',compiler=None, verbose = 0, **kw):\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n- \n+ kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n+ return kw,file\n+ \n+ def setup_extension(self,location='.',**kw):\n+ kw,file = self.build_kw_and_file(location,kw)\n+ return build_tools.create_extension(file, **kw)\n+ \n+ def compile(self,location='.',compiler=None, verbose = 0, **kw):\n+ \n+ if compiler is not None:\n+ self.compiler = compiler\n+ \n+ # !! removed -- we don't have any compiler dependent code\n+ # currently in spec or info classes \n+ # hmm. Is there a cleaner way to do this? Seems like\n+ # choosing the compiler spagettis around a little. \n+ #compiler = build_tools.choose_compiler(self.compiler) \n+ #self.set_compiler(compiler)\n+ \n+ kw,file = self.build_kw_and_file(location,kw)\n+ \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n@@ -327,7 +336,6 @@ def compile(self,location='.',compiler=None, verbose = 0, **kw):\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n- sources = source_files, \n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n@@ -338,9 +346,21 @@ def generate_file_name(module_name,module_location):\n return os.path.abspath(module_file)\n \n def generate_module(module_string, module_file):\n- f =open(module_file,'w')\n- f.write(module_string)\n- f.close()\n+ \"\"\" generate the source code file. Only overwrite\n+ the existing file if the actual source has changed.\n+ \"\"\"\n+ file_changed = 1\n+ if os.path.exists(module_file):\n+ f =open(module_file,'r')\n+ old_string = f.read()\n+ f.close()\n+ if old_string == module_string:\n+ file_changed = 0\n+ if file_changed:\n+ print 'file changed'\n+ f =open(module_file,'w')\n+ f.write(module_string)\n+ f.close()\n return module_file\n \n def assign_variable_types(variables,local_dict = {}, global_dict = {},\n", "added_lines": 38, "deleted_lines": 18, "source_code": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n\n def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n return kw,file\n \n def setup_extension(self,location='.',**kw):\n kw,file = self.build_kw_and_file(location,kw)\n return build_tools.create_extension(file, **kw)\n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n kw,file = self.build_kw_and_file(location,kw)\n \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n \"\"\" generate the source code file. Only overwrite\n the existing file if the actual source has changed.\n \"\"\"\n file_changed = 1\n if os.path.exists(module_file):\n f =open(module_file,'r')\n old_string = f.read()\n f.close()\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n print 'file changed'\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n \n file = self.generate_file(location=location)\n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n sources = source_files, \n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 344, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 14, "complexity": 4, "token_count": 75, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 366, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 403, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 432, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 439, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 450, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 27, "complexity": 4, "token_count": 249, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 287, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 48, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 336, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "module_string", "module_file" ], "start_line": 340, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 346, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 383, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 412, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 426, "end_line": 428, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 430, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 14, "complexity": 4, "token_count": 75, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 335, "complexity": 80, "token_count": 2179, "diff_parsed": { "added": [ "", " def build_kw_and_file(self,location,kw):", " kw['sources'] = kw.get('sources',[]) + source_files", " return kw,file", "", " def setup_extension(self,location='.',**kw):", " kw,file = self.build_kw_and_file(location,kw)", " return build_tools.create_extension(file, **kw)", "", " def compile(self,location='.',compiler=None, verbose = 0, **kw):", "", " if compiler is not None:", " self.compiler = compiler", "", " # !! removed -- we don't have any compiler dependent code", " # currently in spec or info classes", " # hmm. Is there a cleaner way to do this? Seems like", " # choosing the compiler spagettis around a little.", " #compiler = build_tools.choose_compiler(self.compiler)", " #self.set_compiler(compiler)", "", " kw,file = self.build_kw_and_file(location,kw)", "", " \"\"\" generate the source code file. Only overwrite", " the existing file if the actual source has changed.", " \"\"\"", " file_changed = 1", " if os.path.exists(module_file):", " f =open(module_file,'r')", " old_string = f.read()", " f.close()", " if old_string == module_string:", " file_changed = 0", " if file_changed:", " print 'file changed'", " f =open(module_file,'w')", " f.write(module_string)", " f.close()" ], "deleted": [ "", " def compile(self,location='.',compiler=None, verbose = 0, **kw):", "", " if compiler is not None:", " self.compiler = compiler", "", " # !! removed -- we don't have any compiler dependent code", " # currently in spec or info classes", " # hmm. Is there a cleaner way to do this? Seems like", " # choosing the compiler spagettis around a little.", " #compiler = build_tools.choose_compiler(self.compiler)", " #self.set_compiler(compiler)", "", "", " sources = source_files,", " f =open(module_file,'w')", " f.write(module_string)", " f.close()" ] } }, { "old_path": "weave/scxx/object.h", "new_path": "weave/scxx/object.h", "filename": "object.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -678,6 +678,13 @@ public:\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n+\n+ //-------------------------------------------------------------------------\n+ // test for null\n+ //-------------------------------------------------------------------------\n+ bool is_null() { \n+ return (_obj == NULL);\n+ } \n \n /*\n * //-------------------------------------------------------------------------\n", "added_lines": 7, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(unsigned int val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //\n //-------------------------------------------------------------------------\n std::string repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n return std::string(PyString_AsString(result));\n };\n \n std::string str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n return std::string(PyString_AsString(result));\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // test for null\n //-------------------------------------------------------------------------\n bool is_null() { \n return (_obj == NULL);\n } \n \n /*\n * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n#if defined(__GNUC__) && __GNUC__ < 3\n bool not() const {\n#else\n bool operator not() const {\n#endif\n return PyObject_Not(_obj) == 1;\n };\n */\n\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n object is_int() const {\n return PyInt_Check(_obj) == 1;\n };\n\n object is_float() const {\n return PyFloat_Check(_obj) == 1;\n };\n\n object is_complex() const {\n return PyComplex_Check(_obj) == 1;\n };\n \n object is_list() const {\n return PyList_Check(_obj) == 1;\n };\n \n object is_tuple() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_dict() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_string() const {\n return PyString_Check(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // iostream operators\n //-------------------------------------------------------------------------\n friend std::ostream& operator <<(std::ostream& os, py::object& obj);\n //-------------------------------------------------------------------------\n // refcount utilities \n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n\n modified for weave by eric jones.\n*********************************************/\n\n#if !defined(OBJECT_H_INCLUDED_)\n#define OBJECT_H_INCLUDED_\n\n#include \n#include \n#include \n#include \n\n// for debugging\n#include \n\nnamespace py {\n\nvoid fail(PyObject*, const char* msg);\n\n//---------------------------------------------------------------------------\n// py::object -- A simple C++ interface to Python objects.\n//\n// This is the basic type from which all others are derived from. It is \n// also quite useful on its own. The class is very light weight as far as\n// data contents, carrying around only two python pointers.\n//---------------------------------------------------------------------------\n \nclass object \n{\nprotected:\n\n //-------------------------------------------------------------------------\n // _obj is the underlying pointer to the real python object.\n //-------------------------------------------------------------------------\n PyObject* _obj;\n\n //-------------------------------------------------------------------------\n // grab_ref (rename to grab_ref)\n //\n // incref new owner, decref old owner, and adjust to new owner\n //-------------------------------------------------------------------------\n void grab_ref(PyObject* newObj) {\n // be careful to incref before decref if old is same as new\n Py_XINCREF(newObj);\n Py_XDECREF(_own);\n _own = _obj = newObj;\n };\n\n //-------------------------------------------------------------------------\n // lose_ref (rename to lose_ref)\n //\n // decrease reference count without destroying the object.\n //-------------------------------------------------------------------------\n static PyObject* lose_ref(PyObject* o)\n { if (o != 0) --(o->ob_refcnt); return o; }\n\nprivate:\n //-------------------------------------------------------------------------\n // _own is set to _obj if we \"own\" a reference to _obj, else zero\n //-------------------------------------------------------------------------\n PyObject* _own; \n\npublic:\n //-------------------------------------------------------------------------\n // forward declaration of reference obj returned when [] used as an lvalue.\n //-------------------------------------------------------------------------\n class keyed_ref; \n\n object()\n : _obj (0), _own (0) { };\n object(const object& other)\n : _obj (0), _own (0) { grab_ref(other); };\n object(PyObject* obj)\n : _obj (0), _own (0) { grab_ref(obj); };\n\n //-------------------------------------------------------------------------\n // Numeric constructors\n //-------------------------------------------------------------------------\n object(bool val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(int val) { \n _obj = _own = PyInt_FromLong((int)val); \n };\n object(unsigned int val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(long val) { \n _obj = _own = PyInt_FromLong((int)val); \n }; \n object(unsigned long val) { \n _obj = _own = PyLong_FromUnsignedLong(val); \n }; \n object(double val) {\n _obj = _own = PyFloat_FromDouble(val); \n };\n object(const std::complex& val) { \n _obj = _own = PyComplex_FromDoubles(val.real(),val.imag()); \n };\n \n //-------------------------------------------------------------------------\n // string constructors\n //-------------------------------------------------------------------------\n object(const char* val) {\n _obj = _own = PyString_FromString((char*) val); \n };\n object(const std::string& val) : _obj (0), _own (0) { \n _obj = _own = PyString_FromString((char*)val.c_str()); \n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~object() { \n Py_XDECREF(_own); \n };\n \n //-------------------------------------------------------------------------\n // casting operators\n //-------------------------------------------------------------------------\n operator PyObject* () const {\n return _obj;\n };\n \n operator int () const {\n if (!PyInt_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to integer\");\n return PyInt_AsLong(_obj);\n }; \n operator float () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to float\");\n return (float) PyFloat_AsDouble(_obj);\n }; \n operator double () const {\n if (!PyFloat_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to double\");\n return PyFloat_AsDouble(_obj);\n }; \n operator std::complex () const {\n if (!PyComplex_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to complex\");\n return std::complex(PyComplex_RealAsDouble(_obj),\n PyComplex_ImagAsDouble(_obj));\n }; \n operator std::string () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to std::string\");\n return std::string(PyString_AsString(_obj));\n }; \n operator char* () const {\n if (!PyString_Check(_obj))\n fail(PyExc_TypeError, \"cannot convert value to char*\");\n return PyString_AsString(_obj);\n }; \n \n //-------------------------------------------------------------------------\n // equal operator\n //-------------------------------------------------------------------------\n object& operator=(const object& other) {\n grab_ref(other);\n return *this;\n };\n \n //-------------------------------------------------------------------------\n // printing\n //\n // This needs to become more sophisticated and handle objects that \n // implement the file protocol.\n //-------------------------------------------------------------------------\n void print(FILE* f, int flags=0) const {\n int res = PyObject_Print(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n void print(object f, int flags=0) const {\n int res = PyFile_WriteObject(_obj, f, flags);\n if (res == -1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // hasattr -- test if object has specified attribute\n //------------------------------------------------------------------------- \n int hasattr(const char* nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm) == 1;\n };\n int hasattr(const std::string& nm) const {\n return PyObject_HasAttrString(_obj, (char*) nm.c_str()) == 1;\n };\n int hasattr(object& nm) const {\n return PyObject_HasAttr(_obj, nm) == 1;\n };\n \n\n //-------------------------------------------------------------------------\n // attr -- retreive attribute/method from object\n //-------------------------------------------------------------------------\n object attr(const char* nm) const { \n PyObject* val = PyObject_GetAttrString(_obj, (char*) nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n };\n\n object attr(const std::string& nm) const {\n return attr(nm.c_str());\n };\n\n object attr(const object& nm) const {\n PyObject* val = PyObject_GetAttr(_obj, nm);\n if (!val)\n throw 1;\n return object(lose_ref(val)); \n }; \n \n //-------------------------------------------------------------------------\n // setting attributes\n //\n // There is a combinatorial explosion here of function combinations.\n // perhaps there is a casting fix someone can suggest.\n //-------------------------------------------------------------------------\n void set_attr(const char* nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm, val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, object& val) {\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, object& val) {\n int res = PyObject_SetAttr(_obj, nm, val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// int //////////////\n void set_attr(const char* nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, int val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// unsigned long //////////////\n void set_attr(const char* nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, unsigned long val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// double //////////////\n void set_attr(const char* nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, double val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// complex //////////////\n void set_attr(const char* nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::complex& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n ////////////// char* //////////////\n void set_attr(const char* nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const char* val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n\n ////////////// std::string //////////////\n void set_attr(const char* nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm, _val);\n if (res == -1)\n throw 1;\n };\n\n void set_attr(const std::string& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttrString(_obj, (char*) nm.c_str(), _val);\n if (res == -1)\n throw 1;\n };\n \n void set_attr(const object& nm, const std::string& val) {\n py::object _val = py::object(val);\n int res = PyObject_SetAttr(_obj, nm, _val);\n if (res == -1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // del attributes/methods from object\n //-------------------------------------------------------------------------\n void del(const char* nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm);\n if (result == -1)\n throw 1;\n };\n void del(const std::string& nm) {\n int result = PyObject_DelAttrString(_obj, (char*) nm.c_str());\n if (result == -1)\n throw 1;\n };\n void del(const object& nm) {\n int result = PyObject_DelAttr(_obj, nm);\n if (result ==-1)\n throw 1;\n };\n \n //-------------------------------------------------------------------------\n // comparison\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n int cmp(const object& other) const {\n int rslt = 0;\n int rc = PyObject_Cmp(_obj, other, &rslt);\n if (rc == -1)\n fail(PyExc_TypeError, \"cannot make the comparison\");\n return rslt;\n }; \n int cmp(int other) const {\n object _other = object(other);\n return cmp(_other);\n }; \n int cmp(unsigned long other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(double other) const {\n object _other = object(other);\n return cmp(_other);\n };\n int cmp(const std::complex& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n int cmp(const char* other) const {\n object _other = object((char*)other);\n return cmp(_other);\n };\n \n int cmp(const std::string& other) const {\n object _other = object(other);\n return cmp(_other);\n };\n \n bool operator == (const object& other) const {\n return cmp(other) == 0;\n };\n bool operator == (int other) const {\n return cmp(other) == 0;\n };\n bool operator == (unsigned long other) const {\n return cmp(other) == 0;\n };\n bool operator == (double other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::complex& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const std::string& other) const {\n return cmp(other) == 0;\n };\n bool operator == (const char* other) const {\n return cmp(other) == 0;\n };\n\n bool operator != (const object& other) const {\n return cmp(other) != 0;\n };\n bool operator != (int other) const {\n return cmp(other) != 0;\n };\n bool operator != (unsigned long other) const {\n return cmp(other) != 0;\n };\n bool operator != (double other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::complex& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const std::string& other) const {\n return cmp(other) != 0;\n };\n bool operator != (const char* other) const {\n return cmp(other) != 0;\n };\n \n bool operator < (const object& other) const {\n return cmp(other) < 0;\n };\n bool operator < (int other) const {\n return cmp(other) < 0;\n };\n bool operator < (unsigned long other) const {\n return cmp(other) < 0;\n };\n bool operator < (double other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::complex& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const std::string& other) const {\n return cmp(other) < 0;\n };\n bool operator < (const char* other) const {\n return cmp(other) < 0;\n };\n \n bool operator > (const object& other) const {\n return cmp(other) > 0;\n };\n bool operator > (int other) const {\n return cmp(other) > 0;\n };\n bool operator > (unsigned long other) const {\n return cmp(other) > 0;\n };\n bool operator > (double other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::complex& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const std::string& other) const {\n return cmp(other) > 0;\n };\n bool operator > (const char* other) const {\n return cmp(other) > 0;\n };\n\n bool operator >= (const object& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (int other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (unsigned long other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (double other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::complex& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const std::string& other) const {\n return cmp(other) >= 0;\n };\n bool operator >= (const char* other) const {\n return cmp(other) >= 0;\n };\n \n bool operator <= (const object& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (int other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (unsigned long other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (double other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::complex& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const std::string& other) const {\n return cmp(other) <= 0;\n };\n bool operator <= (const char* other) const {\n return cmp(other) <= 0;\n };\n\n //-------------------------------------------------------------------------\n // string representations\n //\n //-------------------------------------------------------------------------\n std::string repr() const { \n object result = PyObject_Repr(_obj);\n if (!(PyObject*)result)\n throw 1;\n return std::string(PyString_AsString(result));\n };\n \n std::string str() const {\n object result = PyObject_Str(_obj);\n if (!(PyObject*)result)\n throw 1;\n return std::string(PyString_AsString(result));\n };\n\n // !! Not Tested \n object unicode() const {\n object result = PyObject_Unicode(_obj);\n if (!(PyObject*)result)\n throw 1;\n lose_ref(result); \n return result;\n };\n \n //-------------------------------------------------------------------------\n // calling methods on object\n //\n // Note: I changed args_tup from a tuple& to a object& so that it could\n // be inlined instead of implemented i weave_imp.cpp. This \n // provides less automatic type checking, but is potentially faster.\n //-------------------------------------------------------------------------\n object object::mcall(const char* nm) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,NULL,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,NULL);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n \n object object::mcall(const char* nm, object& args_tup, object& kw_dict) {\n object method = attr(nm);\n PyObject* result = PyEval_CallObjectWithKeywords(method,args_tup,kw_dict);\n if (!result)\n throw 1; // signal exception has occured.\n return object(lose_ref(result));\n }\n\n object mcall(const std::string& nm) {\n return mcall(nm.c_str());\n }\n object mcall(const std::string& nm, object& args_tup) {\n return mcall(nm.c_str(),args_tup);\n }\n object mcall(const std::string& nm, object& args_tup, object& kw_dict) {\n return mcall(nm.c_str(),args_tup,kw_dict);\n }\n\n //-------------------------------------------------------------------------\n // calling callable objects\n //\n // Note: see not on mcall()\n //-------------------------------------------------------------------------\n object object::call() const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, NULL, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, NULL);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n object object::call(object& args_tup, object& kw_dict) const {\n PyObject *rslt = PyEval_CallObjectWithKeywords(*this, args_tup, kw_dict);\n if (rslt == 0)\n throw 1;\n return object(lose_ref(rslt));\n }\n\n //-------------------------------------------------------------------------\n // check if object is callable\n //-------------------------------------------------------------------------\n bool is_callable() const {\n return PyCallable_Check(_obj) == 1;\n };\n\n //-------------------------------------------------------------------------\n // retreive the objects hash value\n //-------------------------------------------------------------------------\n int hash() const {\n int result = PyObject_Hash(_obj);\n if (result == -1 && PyErr_Occurred())\n throw 1;\n return result; \n };\n \n //-------------------------------------------------------------------------\n // test whether object is true\n //-------------------------------------------------------------------------\n bool is_true() const {\n return PyObject_IsTrue(_obj) == 1;\n };\n \n /*\n * //-------------------------------------------------------------------------\n // test whether object is not true\n //-------------------------------------------------------------------------\n#if defined(__GNUC__) && __GNUC__ < 3\n bool not() const {\n#else\n bool operator not() const {\n#endif\n return PyObject_Not(_obj) == 1;\n };\n */\n\n //-------------------------------------------------------------------------\n // return the variable type for the object\n //-------------------------------------------------------------------------\n object type() const {\n PyObject* result = PyObject_Type(_obj);\n if (!result)\n throw 1;\n return lose_ref(result);\n };\n\n object is_int() const {\n return PyInt_Check(_obj) == 1;\n };\n\n object is_float() const {\n return PyFloat_Check(_obj) == 1;\n };\n\n object is_complex() const {\n return PyComplex_Check(_obj) == 1;\n };\n \n object is_list() const {\n return PyList_Check(_obj) == 1;\n };\n \n object is_tuple() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_dict() const {\n return PyDict_Check(_obj) == 1;\n };\n \n object is_string() const {\n return PyString_Check(_obj) == 1;\n };\n \n //-------------------------------------------------------------------------\n // size, len, and length are all synonyms.\n // \n // length() is useful because it allows the same code to work with STL \n // strings as works with py::objects.\n //-------------------------------------------------------------------------\n int size() const {\n int result = PyObject_Size(_obj);\n if (result == -1)\n throw 1;\n return result;\n };\n int len() const {\n return size();\n };\n int length() const {\n return size();\n };\n\n //-------------------------------------------------------------------------\n // set_item \n //\n // To prevent a combonatorial explosion, only objects are allowed for keys.\n // Users are encouraged to use the [] interface for setting values.\n //------------------------------------------------------------------------- \n virtual void set_item(const object& key, const object& val) {\n int rslt = PyObject_SetItem(_obj, key, val);\n if (rslt==-1)\n throw 1;\n };\n\n //-------------------------------------------------------------------------\n // operator[] \n //-------------------------------------------------------------------------\n // !! defined in weave_imp.cpp\n // !! I'd like to refactor things so that they can be defined here.\n keyed_ref operator [] (object& key);\n keyed_ref operator [] (const char* key);\n keyed_ref operator [] (const std::string& key);\n keyed_ref operator [] (int key);\n keyed_ref operator [] (double key);\n keyed_ref operator [] (const std::complex& key);\n \n //-------------------------------------------------------------------------\n // iter methods\n // !! NOT TESTED\n //-------------------------------------------------------------------------\n \n //-------------------------------------------------------------------------\n // iostream operators\n //-------------------------------------------------------------------------\n friend std::ostream& operator <<(std::ostream& os, py::object& obj);\n //-------------------------------------------------------------------------\n // refcount utilities \n //-------------------------------------------------------------------------\n \n PyObject* disown() {\n _own = 0;\n return _obj;\n };\n \n int refcount() {\n return _obj->ob_refcnt;\n }\n};\n\n\n//---------------------------------------------------------------------------\n// keyed_ref\n//\n// Provides a reference value when operator[] returns an lvalue. The \n// reference has to keep track of its parent object and its key in the parent\n// object so that it can insert a new value into the parent at the \n// appropriate place when a new value is assigned to the keyed_ref object.\n//\n// The keyed_ref class is also used by the py::dict class derived from \n// py::object\n// !! Note: Need to check ref counting on key and parent here.\n//---------------------------------------------------------------------------\nclass object::keyed_ref : public object\n{\n object& _parent;\n object _key;\npublic:\n keyed_ref(object obj, object& parent, object& key)\n : object(obj), _parent(parent), _key(key) {}; \n virtual ~keyed_ref() {};\n\n keyed_ref& operator=(const object& other) {\n grab_ref(other);\n _parent.set_item(_key, other);\n return *this;\n }\n keyed_ref& operator=(int other) {\n object _other = object(other);\n return operator=(_other);\n } \n keyed_ref& operator=(double other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::complex& other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const char* other) {\n object _other = object(other);\n return operator=(_other);\n }\n keyed_ref& operator=(const std::string& other) {\n object _other = object(other);\n return operator=(_other);\n }\n};\n} // namespace\n\n\n#endif // !defined(OBJECT_H_INCLUDED_)\n", "methods": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 133, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 195, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 214, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 246, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 253, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 260, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 268, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 275, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 282, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 290, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 304, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 312, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 363, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 370, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 380, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 385, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 390, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 400, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 407, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 411, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 415, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 419, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 424, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 452, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 474, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 496, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 518, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 562, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 585, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 600, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 608, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 616, "end_line": 622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 624, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 627, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 630, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 639, "end_line": 644, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 645, "end_line": 650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 651, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 661, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 668, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 678, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_null", "long_name": "py::object::is_null()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 685, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 705, "end_line": 710, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_int", "long_name": "py::object::is_int() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 712, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_float", "long_name": "py::object::is_float() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 716, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_complex", "long_name": "py::object::is_complex() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 720, "end_line": 722, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_list", "long_name": "py::object::is_list() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 724, "end_line": 726, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_tuple", "long_name": "py::object::is_tuple() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 728, "end_line": 730, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_dict", "long_name": "py::object::is_dict() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 732, "end_line": 734, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_string", "long_name": "py::object::is_string() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 736, "end_line": 738, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 746, "end_line": 751, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 752, "end_line": 754, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 755, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 765, "end_line": 769, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 796, "end_line": 799, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 801, "end_line": 803, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 824, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 826, "end_line": 826, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 828, "end_line": 832, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 833, "end_line": 836, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 837, "end_line": 840, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 841, "end_line": 844, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 845, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 849, "end_line": 852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::object::grab_ref", "long_name": "py::object::grab_ref( PyObject * newObj)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "newObj" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::lose_ref", "long_name": "py::object::lose_ref( PyObject * o)", "filename": "object.h", "nloc": 2, "complexity": 2, "token_count": 24, "parameters": [ "o" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object()", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const object & other)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "other" ], "start_line": 74, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( PyObject * obj)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "obj" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( bool val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 85, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned int val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 88, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "val" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( unsigned long val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "val" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( double val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: complex & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std" ], "start_line": 100, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const char * val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "val" ], "start_line": 107, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object", "long_name": "py::object::object( const std :: string & val)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 38, "parameters": [ "std" ], "start_line": 110, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::~object", "long_name": "py::object::~object()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 117, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator PyObject *", "long_name": "py::object::operator PyObject *() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator int", "long_name": "py::object::operator int() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 128, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator float", "long_name": "py::object::operator float() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [], "start_line": 133, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator double", "long_name": "py::object::operator double() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator std :: complex < double >", "long_name": "py::object::operator std :: complex < double >() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [], "start_line": 143, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::operator std :: string", "long_name": "py::object::operator std :: string() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 149, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator char *", "long_name": "py::object::operator char *() const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::operator =", "long_name": "py::object::operator =( const object & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 163, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( FILE * f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "f", "flags" ], "start_line": 174, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::print", "long_name": "py::object::print( object f , int flags = 0) const", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "f", "flags" ], "start_line": 180, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const char * nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "nm" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 192, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hasattr", "long_name": "py::object::hasattr( object & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "nm" ], "start_line": 195, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const char * nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 42, "parameters": [ "nm" ], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const std :: string & nm) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 210, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::attr", "long_name": "py::object::attr( const object & nm) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "nm" ], "start_line": 214, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "nm", "val" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 45, "parameters": [ "std", "val" ], "start_line": 233, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "nm", "val" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 246, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 253, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , int val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 260, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 51, "parameters": [ "nm", "val" ], "start_line": 268, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "std", "val" ], "start_line": 275, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , unsigned long val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "nm", "val" ], "start_line": 282, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "val" ], "start_line": 290, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "std", "val" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , double val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "nm", "val" ], "start_line": 304, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 57, "parameters": [ "nm", "std" ], "start_line": 312, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "std", "std" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: complex & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 53, "parameters": [ "nm", "std" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 52, "parameters": [ "nm", "val" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [ "std", "val" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const char * val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 48, "parameters": [ "nm", "val" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const char * nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 54, "parameters": [ "nm", "std" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const std :: string & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 60, "parameters": [ "std", "std" ], "start_line": 363, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::set_attr", "long_name": "py::object::set_attr( const object & nm , const std :: string & val)", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "nm", "std" ], "start_line": 370, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const char * nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "nm" ], "start_line": 380, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const std :: string & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "std" ], "start_line": 385, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::del", "long_name": "py::object::del( const object & nm)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "nm" ], "start_line": 390, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const object & other) const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "other" ], "start_line": 400, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( int other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 407, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( unsigned long other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 411, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( double other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "other" ], "start_line": 415, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: complex & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "std" ], "start_line": 419, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const char * other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 424, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::cmp", "long_name": "py::object::cmp( const std :: string & other) const", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 429, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 434, "end_line": 436, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 440, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 443, "end_line": 445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 449, "end_line": 451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator ==", "long_name": "py::object::operator ==( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 452, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 456, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 459, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 462, "end_line": 464, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 465, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 468, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 471, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator !=", "long_name": "py::object::operator !=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 474, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 478, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 481, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 484, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 487, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 490, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 493, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <", "long_name": "py::object::operator <( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 496, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 500, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 503, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 509, "end_line": 511, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 512, "end_line": 514, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >", "long_name": "py::object::operator >( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 518, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 525, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 528, "end_line": 530, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 531, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 534, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator >=", "long_name": "py::object::operator >=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 540, "end_line": 542, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const object & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 544, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( int other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 547, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( unsigned long other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "other" ], "start_line": 550, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( double other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 553, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: complex & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 556, "end_line": 558, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const std :: string & other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 559, "end_line": 561, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::operator <=", "long_name": "py::object::operator <=( const char * other) const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 562, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::repr", "long_name": "py::object::repr() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 570, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::str", "long_name": "py::object::str() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [], "start_line": 577, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::unicode", "long_name": "py::object::unicode() const", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 585, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 49, "parameters": [ "nm" ], "start_line": 600, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 53, "parameters": [ "nm", "args_tup" ], "start_line": 608, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::object::mcall", "long_name": "py::object::object::mcall( const char * nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 7, "complexity": 2, "token_count": 57, "parameters": [ "nm", "args_tup", "kw_dict" ], "start_line": 616, "end_line": 622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 624, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "std", "args_tup" ], "start_line": 627, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::mcall", "long_name": "py::object::mcall( const std :: string & nm , object & args_tup , object & kw_dict)", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "std", "args_tup", "kw_dict" ], "start_line": 630, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [], "start_line": 639, "end_line": 644, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "args_tup" ], "start_line": 645, "end_line": 650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::object::call", "long_name": "py::object::object::call( object & args_tup , object & kw_dict) const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 47, "parameters": [ "args_tup", "kw_dict" ], "start_line": 651, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_callable", "long_name": "py::object::is_callable() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 661, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::hash", "long_name": "py::object::hash() const", "filename": "object.h", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [], "start_line": 668, "end_line": 673, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_true", "long_name": "py::object::is_true() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 678, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::type", "long_name": "py::object::type() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [], "start_line": 698, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::is_int", "long_name": "py::object::is_int() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 705, "end_line": 707, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_float", "long_name": "py::object::is_float() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 709, "end_line": 711, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_complex", "long_name": "py::object::is_complex() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 713, "end_line": 715, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_list", "long_name": "py::object::is_list() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 717, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_tuple", "long_name": "py::object::is_tuple() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 721, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_dict", "long_name": "py::object::is_dict() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 725, "end_line": 727, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::is_string", "long_name": "py::object::is_string() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [], "start_line": 729, "end_line": 731, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::size", "long_name": "py::object::size() const", "filename": "object.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 739, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::object::len", "long_name": "py::object::len() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 745, "end_line": 747, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::length", "long_name": "py::object::length() const", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 748, "end_line": 750, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::set_item", "long_name": "py::object::set_item( const object & key , const object & val)", "filename": "object.h", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "key", "val" ], "start_line": 758, "end_line": 762, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::disown", "long_name": "py::object::disown()", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 789, "end_line": 792, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::refcount", "long_name": "py::object::refcount()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 794, "end_line": 796, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::keyed_ref", "long_name": "py::object::keyed_ref::keyed_ref( object obj , object & parent , object & key)", "filename": "object.h", "nloc": 2, "complexity": 1, "token_count": 30, "parameters": [ "obj", "parent", "key" ], "start_line": 817, "end_line": 818, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::~keyed_ref", "long_name": "py::object::keyed_ref::~keyed_ref()", "filename": "object.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 819, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const object & other)", "filename": "object.h", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "other" ], "start_line": 821, "end_line": 825, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( int other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 826, "end_line": 829, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( double other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 830, "end_line": 833, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: complex & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "std" ], "start_line": 834, "end_line": 837, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const char * other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "other" ], "start_line": 838, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::object::keyed_ref::operator =", "long_name": "py::object::keyed_ref::operator =( const std :: string & other)", "filename": "object.h", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "std" ], "start_line": 842, "end_line": 845, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::object::is_null", "long_name": "py::object::is_null()", "filename": "object.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 685, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "nloc": 601, "complexity": 192, "token_count": 4364, "diff_parsed": { "added": [ "", " //-------------------------------------------------------------------------", " // test for null", " //-------------------------------------------------------------------------", " bool is_null() {", " return (_obj == NULL);", " }" ], "deleted": [] } } ] }, { "hash": "cf1f7adfb326d48d4771834125526ae97c1d6df8", "msg": "Improved ppimport for nonexisting modules. Added ppimport support to builtin help function. Now both info and help work again on scipy objects.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-03-25T22:16:46+00:00", "author_timezone": 0, "committer_date": "2003-03-25T22:16:46+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d419e6c49b96ff03ff67c7af439da3c94345e903" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 2, "insertions": 9, "lines": 11, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/ppimport.py", "new_path": "scipy_base/ppimport.py", "filename": "ppimport.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -174,14 +174,21 @@ def __init__(self,name,location):\n \n def _ppimport_importer(self):\n name = self.__name__\n- module = sys.modules[name]\n+\ttry:\n+\t module = sys.modules[name]\n+\texcept KeyError:\n+\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n assert module is self,`module`\n \n # uninstall loader\n del sys.modules[name]\n \n #print 'Executing postponed import for %s' %(name)\n- module = __import__(name,None,None,['*'])\n+\ttry:\n+\t module = __import__(name,None,None,['*'])\n+\texcept ImportError:\n+\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n+\t raise\n assert isinstance(module,types.ModuleType),`module`\n \n self.__dict__ = module.__dict__\n", "added_lines": 9, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n self.__dict__ = attr.__dict__\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\ttry:\n\t module = sys.modules[name]\n\texcept KeyError:\n\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n assert module is self,`module`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n\ttry:\n\t module = __import__(name,None,None,['*'])\n\texcept ImportError:\n\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n\t raise\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n self.__dict__ = attr.__dict__\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n module = sys.modules[name]\n assert module is self,`module`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n module = __import__(name,None,None,['*'])\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\n", "methods": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "self" ], "start_line": 57, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 76, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 91, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 99, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 156, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 112, "parameters": [ "self" ], "start_line": 175, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 198, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 205, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "self" ], "start_line": 212, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "self" ], "start_line": 57, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 76, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 91, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 99, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 156, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 10, "complexity": 1, "token_count": 77, "parameters": [ "self" ], "start_line": 175, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 191, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 198, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "self" ], "start_line": 205, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 112, "parameters": [ "self" ], "start_line": 175, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 } ], "nloc": 158, "complexity": 42, "token_count": 975, "diff_parsed": { "added": [ "\ttry:", "\t module = sys.modules[name]", "\texcept KeyError:", "\t raise ImportError,self.__dict__.get('_ppimport_exc_value')", "\ttry:", "\t module = __import__(name,None,None,['*'])", "\texcept ImportError:", "\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)", "\t raise" ], "deleted": [ " module = sys.modules[name]", " module = __import__(name,None,None,['*'])" ] } } ] }, { "hash": "1d8273c7580e4544bfd4685b830a1f92db18c561", "msg": "Backported ppimport to Py2.1. Moved help/ppimport hooks to ppimport.py so that they will be available also for standalone installations", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-03-25T22:46:47+00:00", "author_timezone": 0, "committer_date": "2003-03-25T22:46:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "cf1f7adfb326d48d4771834125526ae97c1d6df8" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 43, "lines": 44, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.6296296296296297, "modified_files": [ { "old_path": "scipy_base/ppimport.py", "new_path": "scipy_base/ppimport.py", "filename": "ppimport.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -58,7 +58,9 @@ def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n- self.__dict__ = attr.__dict__\n+ d = attr.__dict__\n+ if d is not None:\n+ self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n@@ -212,6 +214,8 @@ def __getattr__(self, name):\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n+ elif self.__dict__.has_key('_ppimport_exc_value'):\n+ status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n@@ -219,3 +223,41 @@ def __repr__(self):\n \n __str__ = __repr__\n \n+try:\n+ import pydoc as _pydoc\n+except ImportError:\n+ _pydoc = None\n+if _pydoc is not None:\n+ # Define new built-in 'help'.\n+ # This is a wrapper around pydoc.help (with a twist\n+ # (as in debian site.py) and ppimport support).\n+ class _Helper:\n+ def __repr__ (self):\n+ return \"Type help () for interactive help, \" \\\n+ \"or help (object) for help about object.\"\n+ def __call__ (self, *args, **kwds):\n+ new_args = []\n+ for a in args:\n+ if hasattr(a,'_ppimport_importer') or \\\n+\t\t hasattr(a,'_ppimport_module'):\n+ a = a._ppimport_module\n+ if hasattr(a,'_ppimport_attr'):\n+\t\t a = a._ppimport_attr\n+ new_args.append(a)\n+ return _pydoc.help(*new_args, **kwds)\n+ import __builtin__\n+ __builtin__.help = _Helper()\n+\n+ import inspect as _inspect\n+ _old_inspect_getfile = _inspect.getfile\n+ def _inspect_getfile(object):\n+\ttry:\n+\t if hasattr(object,'_ppimport_importer') or \\\n+\t hasattr(object,'_ppimport_module'):\n+ object = object._ppimport_module\n+ if hasattr(object,'_ppimport_attr'):\n+\t\tobject = object._ppimport_attr\n+\texcept ImportError:\n+\t object = object.__class__\n+\treturn _old_inspect_getfile(object)\n+ _inspect.getfile = _inspect_getfile\n", "added_lines": 43, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\ttry:\n\t module = sys.modules[name]\n\texcept KeyError:\n\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n assert module is self,`module`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n\ttry:\n\t module = __import__(name,None,None,['*'])\n\texcept ImportError:\n\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n\t raise\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_value'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n self.__dict__ = attr.__dict__\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\ttry:\n\t module = sys.modules[name]\n\texcept KeyError:\n\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n assert module is self,`module`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n\ttry:\n\t module = __import__(name,None,None,['*'])\n\texcept ImportError:\n\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n\t raise\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\n", "methods": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 11, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 69, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 78, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 88, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 93, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 101, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 158, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 112, "parameters": [ "self" ], "start_line": 177, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 214, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 235, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 238, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 253, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "self" ], "start_line": 57, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 76, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 91, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 99, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 156, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 112, "parameters": [ "self" ], "start_line": 175, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 198, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 205, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "self" ], "start_line": 212, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 253, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 214, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 11, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 238, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 } ], "nloc": 196, "complexity": 55, "token_count": 1178, "diff_parsed": { "added": [ " d = attr.__dict__", " if d is not None:", " self.__dict__ = d", " elif self.__dict__.has_key('_ppimport_exc_value'):", " status = 'import error'", "try:", " import pydoc as _pydoc", "except ImportError:", " _pydoc = None", "if _pydoc is not None:", " # Define new built-in 'help'.", " # This is a wrapper around pydoc.help (with a twist", " # (as in debian site.py) and ppimport support).", " class _Helper:", " def __repr__ (self):", " return \"Type help () for interactive help, \" \\", " \"or help (object) for help about object.\"", " def __call__ (self, *args, **kwds):", " new_args = []", " for a in args:", " if hasattr(a,'_ppimport_importer') or \\", "\t\t hasattr(a,'_ppimport_module'):", " a = a._ppimport_module", " if hasattr(a,'_ppimport_attr'):", "\t\t a = a._ppimport_attr", " new_args.append(a)", " return _pydoc.help(*new_args, **kwds)", " import __builtin__", " __builtin__.help = _Helper()", "", " import inspect as _inspect", " _old_inspect_getfile = _inspect.getfile", " def _inspect_getfile(object):", "\ttry:", "\t if hasattr(object,'_ppimport_importer') or \\", "\t hasattr(object,'_ppimport_module'):", " object = object._ppimport_module", " if hasattr(object,'_ppimport_attr'):", "\t\tobject = object._ppimport_attr", "\texcept ImportError:", "\t object = object.__class__", "\treturn _old_inspect_getfile(object)", " _inspect.getfile = _inspect_getfile" ], "deleted": [ " self.__dict__ = attr.__dict__" ] } } ] }, { "hash": "0f98f8373dee49b6ca105f535c6a3c279ffabaab", "msg": "linalg may be also available as standalone when import scipy.linalg fails", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-03-28T16:42:15+00:00", "author_timezone": 0, "committer_date": "2003-03-28T16:42:15+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1d8273c7580e4544bfd4685b830a1f92db18c561" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 4, "insertions": 10, "lines": 14, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/polynomial.py", "new_path": "scipy_base/polynomial.py", "filename": "polynomial.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -16,10 +16,16 @@ def get_eigval_func():\n eigvals = scipy.linalg.eigvals\n except ImportError:\n try:\n- import LinearAlgebra\n- eigvals = LinearAlgebra.eigenvalues\n- except:\n- raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n+ import linalg\n+ eigvals = linalg.eigvals\n+ except ImportError:\n+ try:\n+ import LinearAlgebra\n+ eigvals = LinearAlgebra.eigenvalues\n+ except:\n+ raise ImportError, \\\n+ \"You must have scipy.linalg or LinearAlgebra to \"\\\n+ \"use this function.\"\n return eigvals\n \n def poly(seq_of_zeros):\n", "added_lines": 10, "deleted_lines": 4, "source_code": "import Numeric\nfrom Numeric import *\nfrom scimath import *\n\nfrom type_check import isscalar\nfrom matrix_base import diag\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\n\n__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n \ndef get_eigval_func():\n try:\n import scipy.linalg\n eigvals = scipy.linalg.eigvals\n except ImportError:\n try:\n import linalg\n eigvals = linalg.eigvals\n except ImportError:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \\\n \"You must have scipy.linalg or LinearAlgebra to \"\\\n \"use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n eig = get_eigval_func()\n seq_of_zeros=eig(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = convolve(a,[1, -seq_of_zeros[k]], mode=2)\n\n \n if a.typecode() in ['F','D']:\n # if complex roots are all complex conjugates, the roots are real.\n roots = asarray(seq_of_zeros,'D')\n pos_roots = sort_complex(compress(roots.imag > 0,roots))\n neg_roots = conjugate(sort_complex(compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n eig = get_eigval_func()\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n \n # find non-zero array entries\n non_zero = nonzero(ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n \n # casting: if incoming array isn't floating point, make it floating point.\n if p.typecode() not in ['f','d','F','D']:\n p = p.astype('d')\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(ones((N-2,),p.typecode()),-1)\n A[0,:] = -p[1:] / p[0]\n roots = eig(A)\n else:\n return array([])\n\n # tack any zeros onto the back of the array \n roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n return roots\n\ndef polyint(p,m=1,k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*Numeric.ones(m)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n y = Numeric.zeros(len(p)+1,'d')\n y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)\n y[-1] = k[0] \n val = polyint(y,m-1,k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n \ndef polyder(p,m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y,m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyval(p,x):\n \"\"\"Evaluate the polymnomial p at x.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n \"\"\"\n x = Numeric.asarray(x)\n p = Numeric.asarray(p)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) + a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 + Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) - a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 - Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1,a2):\n \"\"\"Multiplies two polynomials represented as lists.\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n val = Numeric.convolve(a1,a2)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polydiv(a1,a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n q, r = deconvolve(a1,a2)\n while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q, r = map(poly1d,(q,r))\n return q, r\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal.\n \"\"\"\n try:\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = Numeric.ones(N-D+1,Numeric.Float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - Numeric.convolve(den,quot,mode=2)\n return quot, rem\n\nimport re\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr,n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else: \n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n \n \nclass poly1d:\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r,poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key == '__coerce__':\n raise KeyError\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", "source_code_before": "import Numeric\nfrom Numeric import *\nfrom scimath import *\n\nfrom type_check import isscalar\nfrom matrix_base import diag\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\n\n__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n \ndef get_eigval_func():\n try:\n import scipy.linalg\n eigvals = scipy.linalg.eigvals\n except ImportError:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n eig = get_eigval_func()\n seq_of_zeros=eig(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = convolve(a,[1, -seq_of_zeros[k]], mode=2)\n\n \n if a.typecode() in ['F','D']:\n # if complex roots are all complex conjugates, the roots are real.\n roots = asarray(seq_of_zeros,'D')\n pos_roots = sort_complex(compress(roots.imag > 0,roots))\n neg_roots = conjugate(sort_complex(compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n eig = get_eigval_func()\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n \n # find non-zero array entries\n non_zero = nonzero(ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n \n # casting: if incoming array isn't floating point, make it floating point.\n if p.typecode() not in ['f','d','F','D']:\n p = p.astype('d')\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(ones((N-2,),p.typecode()),-1)\n A[0,:] = -p[1:] / p[0]\n roots = eig(A)\n else:\n return array([])\n\n # tack any zeros onto the back of the array \n roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n return roots\n\ndef polyint(p,m=1,k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*Numeric.ones(m)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n y = Numeric.zeros(len(p)+1,'d')\n y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)\n y[-1] = k[0] \n val = polyint(y,m-1,k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n \ndef polyder(p,m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y,m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyval(p,x):\n \"\"\"Evaluate the polymnomial p at x.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n \"\"\"\n x = Numeric.asarray(x)\n p = Numeric.asarray(p)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) + a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 + Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) - a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 - Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1,a2):\n \"\"\"Multiplies two polynomials represented as lists.\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n val = Numeric.convolve(a1,a2)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polydiv(a1,a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n q, r = deconvolve(a1,a2)\n while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q, r = map(poly1d,(q,r))\n return q, r\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal.\n \"\"\"\n try:\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = Numeric.ones(N-D+1,Numeric.Float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - Numeric.convolve(den,quot,mode=2)\n return quot, rem\n\nimport re\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr,n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else: \n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n \n \nclass poly1d:\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r,poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key == '__coerce__':\n raise KeyError\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", "methods": [ { "name": "get_eigval_func", "long_name": "get_eigval_func( )", "filename": "polynomial.py", "nloc": 17, "complexity": 4, "token_count": 52, "parameters": [], "start_line": 13, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "poly", "long_name": "poly( seq_of_zeros )", "filename": "polynomial.py", "nloc": 23, "complexity": 9, "token_count": 195, "parameters": [ "seq_of_zeros" ], "start_line": 31, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "roots", "long_name": "roots( p )", "filename": "polynomial.py", "nloc": 19, "complexity": 4, "token_count": 190, "parameters": [ "p" ], "start_line": 71, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "polyint", "long_name": "polyint( p , m = 1 , k = None )", "filename": "polynomial.py", "nloc": 24, "complexity": 8, "token_count": 192, "parameters": [ "p", "m", "k" ], "start_line": 110, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "polyder", "long_name": "polyder( p , m = 1 )", "filename": "polynomial.py", "nloc": 15, "complexity": 4, "token_count": 99, "parameters": [ "p", "m" ], "start_line": 142, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 7, "complexity": 2, "token_count": 63, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "polyadd", "long_name": "polyadd( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 175, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polysub", "long_name": "polysub( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 193, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polymul", "long_name": "polymul( a1 , a2 )", "filename": "polynomial.py", "nloc": 6, "complexity": 3, "token_count": 46, "parameters": [ "a1", "a2" ], "start_line": 212, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "polydiv", "long_name": "polydiv( a1 , a2 )", "filename": "polynomial.py", "nloc": 8, "complexity": 5, "token_count": 94, "parameters": [ "a1", "a2" ], "start_line": 221, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "deconvolve", "long_name": "deconvolve( signal , divisor )", "filename": "polynomial.py", "nloc": 18, "complexity": 3, "token_count": 115, "parameters": [ "signal", "divisor" ], "start_line": 232, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_raise_power", "long_name": "_raise_power( astr , wrap = 70 )", "filename": "polynomial.py", "nloc": 25, "complexity": 5, "token_count": 194, "parameters": [ "astr", "wrap" ], "start_line": 255, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , c_or_r , r = 0 )", "filename": "polynomial.py", "nloc": 15, "complexity": 6, "token_count": 122, "parameters": [ "self", "c_or_r", "r" ], "start_line": 299, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__array__", "long_name": "__array__( self , t = None )", "filename": "polynomial.py", "nloc": 5, "complexity": 2, "token_count": 34, "parameters": [ "self", "t" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 321, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 326, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "polynomial.py", "nloc": 41, "complexity": 17, "token_count": 244, "parameters": [ "self" ], "start_line": 329, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "val" ], "start_line": 373, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__mul__", "long_name": "__mul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 376, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rmul__", "long_name": "__rmul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 383, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__add__", "long_name": "__add__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 390, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 397, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__pow__", "long_name": "__pow__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 5, "token_count": 57, "parameters": [ "self", "val" ], "start_line": 404, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__sub__", "long_name": "__sub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 412, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__div__", "long_name": "__div__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 426, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rdiv__", "long_name": "__rdiv__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 433, "end_line": 438, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , key , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "key", "val" ], "start_line": 440, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , key )", "filename": "polynomial.py", "nloc": 11, "complexity": 5, "token_count": 65, "parameters": [ "self", "key" ], "start_line": 443, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "val" ], "start_line": 455, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , key , val )", "filename": "polynomial.py", "nloc": 11, "complexity": 3, "token_count": 94, "parameters": [ "self", "key", "val" ], "start_line": 463, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "integ", "long_name": "integ( self , m = 1 , k = 0 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "self", "m", "k" ], "start_line": 475, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "deriv", "long_name": "deriv( self , m = 1 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "m" ], "start_line": 478, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_eigval_func", "long_name": "get_eigval_func( )", "filename": "polynomial.py", "nloc": 11, "complexity": 3, "token_count": 37, "parameters": [], "start_line": 13, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "poly", "long_name": "poly( seq_of_zeros )", "filename": "polynomial.py", "nloc": 23, "complexity": 9, "token_count": 195, "parameters": [ "seq_of_zeros" ], "start_line": 25, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "roots", "long_name": "roots( p )", "filename": "polynomial.py", "nloc": 19, "complexity": 4, "token_count": 190, "parameters": [ "p" ], "start_line": 65, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "polyint", "long_name": "polyint( p , m = 1 , k = None )", "filename": "polynomial.py", "nloc": 24, "complexity": 8, "token_count": 192, "parameters": [ "p", "m", "k" ], "start_line": 104, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "polyder", "long_name": "polyder( p , m = 1 )", "filename": "polynomial.py", "nloc": 15, "complexity": 4, "token_count": 99, "parameters": [ "p", "m" ], "start_line": 136, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 7, "complexity": 2, "token_count": 63, "parameters": [ "p", "x" ], "start_line": 154, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "polyadd", "long_name": "polyadd( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 169, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polysub", "long_name": "polysub( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 187, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polymul", "long_name": "polymul( a1 , a2 )", "filename": "polynomial.py", "nloc": 6, "complexity": 3, "token_count": 46, "parameters": [ "a1", "a2" ], "start_line": 206, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "polydiv", "long_name": "polydiv( a1 , a2 )", "filename": "polynomial.py", "nloc": 8, "complexity": 5, "token_count": 94, "parameters": [ "a1", "a2" ], "start_line": 215, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "deconvolve", "long_name": "deconvolve( signal , divisor )", "filename": "polynomial.py", "nloc": 18, "complexity": 3, "token_count": 115, "parameters": [ "signal", "divisor" ], "start_line": 226, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_raise_power", "long_name": "_raise_power( astr , wrap = 70 )", "filename": "polynomial.py", "nloc": 25, "complexity": 5, "token_count": 194, "parameters": [ "astr", "wrap" ], "start_line": 249, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , c_or_r , r = 0 )", "filename": "polynomial.py", "nloc": 15, "complexity": 6, "token_count": 122, "parameters": [ "self", "c_or_r", "r" ], "start_line": 293, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__array__", "long_name": "__array__( self , t = None )", "filename": "polynomial.py", "nloc": 5, "complexity": 2, "token_count": 34, "parameters": [ "self", "t" ], "start_line": 309, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 315, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 320, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "polynomial.py", "nloc": 41, "complexity": 17, "token_count": 244, "parameters": [ "self" ], "start_line": 323, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "val" ], "start_line": 367, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__mul__", "long_name": "__mul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 370, "end_line": 375, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rmul__", "long_name": "__rmul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 377, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__add__", "long_name": "__add__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 384, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 391, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__pow__", "long_name": "__pow__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 5, "token_count": 57, "parameters": [ "self", "val" ], "start_line": 398, "end_line": 404, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__sub__", "long_name": "__sub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 406, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 413, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__div__", "long_name": "__div__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 420, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rdiv__", "long_name": "__rdiv__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 427, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , key , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "key", "val" ], "start_line": 434, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , key )", "filename": "polynomial.py", "nloc": 11, "complexity": 5, "token_count": 65, "parameters": [ "self", "key" ], "start_line": 437, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "val" ], "start_line": 449, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , key , val )", "filename": "polynomial.py", "nloc": 11, "complexity": 3, "token_count": 94, "parameters": [ "self", "key", "val" ], "start_line": 457, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "integ", "long_name": "integ( self , m = 1 , k = 0 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "self", "m", "k" ], "start_line": 469, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "deriv", "long_name": "deriv( self , m = 1 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "m" ], "start_line": 472, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "get_eigval_func", "long_name": "get_eigval_func( )", "filename": "polynomial.py", "nloc": 17, "complexity": 4, "token_count": 52, "parameters": [], "start_line": 13, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 379, "complexity": 120, "token_count": 2716, "diff_parsed": { "added": [ " import linalg", " eigvals = linalg.eigvals", " except ImportError:", " try:", " import LinearAlgebra", " eigvals = LinearAlgebra.eigenvalues", " except:", " raise ImportError, \\", " \"You must have scipy.linalg or LinearAlgebra to \"\\", " \"use this function.\"" ], "deleted": [ " import LinearAlgebra", " eigvals = LinearAlgebra.eigenvalues", " except:", " raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"" ] } } ] }, { "hash": "7281e96076d1d63d66bc237c8494a1cefe2f2c1b", "msg": "Fixed 'setup.py sdist'->untar->'setup.py build' cycle.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-03-28T22:15:16+00:00", "author_timezone": 0, "committer_date": "2003-03-28T22:15:16+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0f98f8373dee49b6ca105f535c6a3c279ffabaab" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 6, "lines": 7, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_py.py", "new_path": "scipy_distutils/command/build_py.py", "filename": "build_py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,4 +1,6 @@\n+\n import os\n+import sys\n from glob import glob\n #from distutils.command.build_py import *\n from distutils.command.build_py import build_py as old_build_py\n@@ -24,9 +26,12 @@ def in_build_py_ignore(file, _cache={}):\n \n class build_py(old_build_py):\n \n- def find_package_modules (self, package, package_dir):\n+ def find_package_modules(self, package, package_dir):\n # we filter all files that are setup.py or setup_xxx.py\n # or listed in .build_py_ignore file of files base directory.\n+ if 'sdist' in sys.argv:\n+ return old_build_py.find_package_modules(self,package,package_dir)\n+\n self.check_package(package, package_dir)\n module_files = glob(os.path.join(package_dir, \"*.py\"))\n modules = []\n", "added_lines": 6, "deleted_lines": 1, "source_code": "\nimport os\nimport sys\nfrom glob import glob\n#from distutils.command.build_py import *\nfrom distutils.command.build_py import build_py as old_build_py\nfrom fnmatch import fnmatch\n\ndef is_setup_script(file):\n file = os.path.basename(file)\n return fnmatch(file,\"setup.py\")\n #return (fnmatch(file,\"setup.py\") or fnmatch(file,\"setup_*.py\"))\n\ndef in_build_py_ignore(file, _cache={}):\n base,file = os.path.split(file)\n ignore_list = _cache.get(base)\n if ignore_list is None:\n ignore_list = []\n fn = os.path.join(base,'.build_py_ignore')\n if os.path.isfile(fn):\n f = open(fn,'r')\n ignore_list = [x for x in f.read().split('\\n') if x]\n f.close()\n _cache[base] = ignore_list\n return file in ignore_list\n\nclass build_py(old_build_py):\n\n def find_package_modules(self, package, package_dir):\n # we filter all files that are setup.py or setup_xxx.py\n # or listed in .build_py_ignore file of files base directory.\n if 'sdist' in sys.argv:\n return old_build_py.find_package_modules(self,package,package_dir)\n\n self.check_package(package, package_dir)\n module_files = glob(os.path.join(package_dir, \"*.py\"))\n modules = []\n setup_script = os.path.abspath(self.distribution.script_name)\n\n for f in module_files:\n abs_f = os.path.abspath(f)\n if not in_build_py_ignore(abs_f) \\\n and abs_f != setup_script and not is_setup_script(f):\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n else:\n self.debug_print(\"excluding %s\" % f)\n return modules\n", "source_code_before": "import os\nfrom glob import glob\n#from distutils.command.build_py import *\nfrom distutils.command.build_py import build_py as old_build_py\nfrom fnmatch import fnmatch\n\ndef is_setup_script(file):\n file = os.path.basename(file)\n return fnmatch(file,\"setup.py\")\n #return (fnmatch(file,\"setup.py\") or fnmatch(file,\"setup_*.py\"))\n\ndef in_build_py_ignore(file, _cache={}):\n base,file = os.path.split(file)\n ignore_list = _cache.get(base)\n if ignore_list is None:\n ignore_list = []\n fn = os.path.join(base,'.build_py_ignore')\n if os.path.isfile(fn):\n f = open(fn,'r')\n ignore_list = [x for x in f.read().split('\\n') if x]\n f.close()\n _cache[base] = ignore_list\n return file in ignore_list\n\nclass build_py(old_build_py):\n\n def find_package_modules (self, package, package_dir):\n # we filter all files that are setup.py or setup_xxx.py\n # or listed in .build_py_ignore file of files base directory.\n self.check_package(package, package_dir)\n module_files = glob(os.path.join(package_dir, \"*.py\"))\n modules = []\n setup_script = os.path.abspath(self.distribution.script_name)\n\n for f in module_files:\n abs_f = os.path.abspath(f)\n if not in_build_py_ignore(abs_f) \\\n and abs_f != setup_script and not is_setup_script(f):\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n else:\n self.debug_print(\"excluding %s\" % f)\n return modules\n", "methods": [ { "name": "is_setup_script", "long_name": "is_setup_script( file )", "filename": "build_py.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "file" ], "start_line": 9, "end_line": 11, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "in_build_py_ignore", "long_name": "in_build_py_ignore( file , _cache = { } )", "filename": "build_py.py", "nloc": 12, "complexity": 5, "token_count": 104, "parameters": [ "file", "_cache" ], "start_line": 14, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_package_modules", "long_name": "find_package_modules( self , package , package_dir )", "filename": "build_py.py", "nloc": 16, "complexity": 6, "token_count": 145, "parameters": [ "self", "package", "package_dir" ], "start_line": 29, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "methods_before": [ { "name": "is_setup_script", "long_name": "is_setup_script( file )", "filename": "build_py.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "file" ], "start_line": 7, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "in_build_py_ignore", "long_name": "in_build_py_ignore( file , _cache = { } )", "filename": "build_py.py", "nloc": 12, "complexity": 5, "token_count": 104, "parameters": [ "file", "_cache" ], "start_line": 12, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_package_modules", "long_name": "find_package_modules( self , package , package_dir )", "filename": "build_py.py", "nloc": 14, "complexity": 5, "token_count": 127, "parameters": [ "self", "package", "package_dir" ], "start_line": 27, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "find_package_modules", "long_name": "find_package_modules( self , package , package_dir )", "filename": "build_py.py", "nloc": 16, "complexity": 6, "token_count": 145, "parameters": [ "self", "package", "package_dir" ], "start_line": 29, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 37, "complexity": 12, "token_count": 302, "diff_parsed": { "added": [ "", "import sys", " def find_package_modules(self, package, package_dir):", " if 'sdist' in sys.argv:", " return old_build_py.find_package_modules(self,package,package_dir)", "" ], "deleted": [ " def find_package_modules (self, package, package_dir):" ] } } ] }, { "hash": "786056b68879b21a1166f8d40fdab2abf8a3e450", "msg": "added check for the existence of a couple of extension function method names that are present in scipy_distutils classes but absent in distutils classes. This allows us to mix distutil extensions in with scipy_distutil extension within one build process. weave returns distutil extension objects, so this is useful", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-03-29T04:30:26+00:00", "author_timezone": 0, "committer_date": "2003-03-29T04:30:26+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7281e96076d1d63d66bc237c8494a1cefe2f2c1b" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 2, "insertions": 9, "lines": 11, "files": 2, "dmm_unit_size": 0.5, "dmm_unit_complexity": 0.5, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -94,7 +94,11 @@ def build_extension(self, ext):\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n- elif ext.has_cxx_sources():\n+ # check for functions existence so that we can mix distutils\n+ # extension with scipy_distutils functions without breakage\n+ elif (hasattr(ext,'has_cxx_sources') and\n+ ext.has_cxx_sources()):\n+\n if save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n", "added_lines": 5, "deleted_lines": 1, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(ext_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(ext_name) and \\\n ext_name not in ext.libraries:\n ext.libraries.insert(0,ext_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n ext.library_dirs.append(build_flib.build_flib)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(ext_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(ext_name) and \\\n ext_name not in ext.libraries:\n ext.libraries.insert(0,ext_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n ext.library_dirs.append(build_flib.build_flib)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n elif ext.has_cxx_sources():\n if save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 73, "complexity": 26, "token_count": 541, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 101, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 123, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 72, "complexity": 25, "token_count": 532, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 97, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 119, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 73, "complexity": 26, "token_count": 541, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 101, "top_nesting_level": 1 } ], "nloc": 93, "complexity": 29, "token_count": 665, "diff_parsed": { "added": [ " # check for functions existence so that we can mix distutils", " # extension with scipy_distutils functions without breakage", " elif (hasattr(ext,'has_cxx_sources') and", " ext.has_cxx_sources()):", "" ], "deleted": [ " elif ext.has_cxx_sources():" ] } }, { "old_path": "scipy_distutils/dist.py", "new_path": "scipy_distutils/dist.py", "filename": "dist.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -14,7 +14,10 @@ def __init__ (self, attrs=None):\n def has_f2py_sources(self):\n if self.has_ext_modules():\n for ext in self.ext_modules:\n- if ext.has_f2py_sources():\n+ # check for functions existence so that we can mix distutils\n+ # extension with scipy_distutils functions without breakage\n+ if (hasattr(ext,'has_f2py_sources') and \n+ ext.has_f2py_sources()):\n return 1\n return 0\n \n", "added_lines": 4, "deleted_lines": 1, "source_code": "from distutils.dist import *\nfrom distutils.dist import Distribution as OldDistribution\nfrom distutils.errors import DistutilsSetupError\n\nfrom types import *\n\n\n\nclass Distribution (OldDistribution):\n def __init__ (self, attrs=None):\n self.fortran_libraries = None\n OldDistribution.__init__(self, attrs)\n\n def has_f2py_sources(self):\n if self.has_ext_modules():\n for ext in self.ext_modules:\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n if (hasattr(ext,'has_f2py_sources') and \n ext.has_f2py_sources()):\n return 1\n return 0\n\n def has_f_libraries(self):\n if self.fortran_libraries and len(self.fortran_libraries) > 0:\n return 1\n return self.has_f2py_sources() # f2py might generate fortran sources.\n\n def check_data_file_list(self):\n \"\"\"Ensure that the list of data_files (presumably provided as a\n command option 'data_files') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (name, list_of_libraries).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n print 'check_data_file_list'\n if type(self.data_files) is not ListType:\n raise DistutilsSetupError, \\\n \"'data_files' option must be a list of tuples\"\n\n for lib in self.data_files:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'data_files' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'data_files' \" + \\\n \"must be a string (the package with the data_file)\"\n\n if type(lib[1]) is not ListType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'data_files' \" + \\\n \"must be a list of files.\"\n # for lib\n\n # check_data_file_list ()\n \n def get_data_files (self):\n print 'get_data_files'\n self.check_data_file_list()\n filenames = []\n \n # Gets data files specified\n for ext in self.data_files:\n filenames.extend(ext[1])\n\n return filenames\n", "source_code_before": "from distutils.dist import *\nfrom distutils.dist import Distribution as OldDistribution\nfrom distutils.errors import DistutilsSetupError\n\nfrom types import *\n\n\n\nclass Distribution (OldDistribution):\n def __init__ (self, attrs=None):\n self.fortran_libraries = None\n OldDistribution.__init__(self, attrs)\n\n def has_f2py_sources(self):\n if self.has_ext_modules():\n for ext in self.ext_modules:\n if ext.has_f2py_sources():\n return 1\n return 0\n\n def has_f_libraries(self):\n if self.fortran_libraries and len(self.fortran_libraries) > 0:\n return 1\n return self.has_f2py_sources() # f2py might generate fortran sources.\n\n def check_data_file_list(self):\n \"\"\"Ensure that the list of data_files (presumably provided as a\n command option 'data_files') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (name, list_of_libraries).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n print 'check_data_file_list'\n if type(self.data_files) is not ListType:\n raise DistutilsSetupError, \\\n \"'data_files' option must be a list of tuples\"\n\n for lib in self.data_files:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'data_files' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'data_files' \" + \\\n \"must be a string (the package with the data_file)\"\n\n if type(lib[1]) is not ListType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'data_files' \" + \\\n \"must be a list of files.\"\n # for lib\n\n # check_data_file_list ()\n \n def get_data_files (self):\n print 'get_data_files'\n self.check_data_file_list()\n filenames = []\n \n # Gets data files specified\n for ext in self.data_files:\n filenames.extend(ext[1])\n\n return filenames\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , attrs = None )", "filename": "dist.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self", "attrs" ], "start_line": 10, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "dist.py", "nloc": 7, "complexity": 5, "token_count": 39, "parameters": [ "self" ], "start_line": 14, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 4, "complexity": 3, "token_count": 27, "parameters": [ "self" ], "start_line": 24, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_data_file_list", "long_name": "check_data_file_list( self )", "filename": "dist.py", "nloc": 17, "complexity": 7, "token_count": 92, "parameters": [ "self" ], "start_line": 29, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_data_files", "long_name": "get_data_files( self )", "filename": "dist.py", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [ "self" ], "start_line": 58, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , attrs = None )", "filename": "dist.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self", "attrs" ], "start_line": 10, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "dist.py", "nloc": 6, "complexity": 4, "token_count": 30, "parameters": [ "self" ], "start_line": 14, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "dist.py", "nloc": 4, "complexity": 3, "token_count": 27, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_data_file_list", "long_name": "check_data_file_list( self )", "filename": "dist.py", "nloc": 17, "complexity": 7, "token_count": 92, "parameters": [ "self" ], "start_line": 26, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_data_files", "long_name": "get_data_files( self )", "filename": "dist.py", "nloc": 7, "complexity": 2, "token_count": 34, "parameters": [ "self" ], "start_line": 55, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "dist.py", "nloc": 7, "complexity": 5, "token_count": 39, "parameters": [ "self" ], "start_line": 14, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": 43, "complexity": 18, "token_count": 249, "diff_parsed": { "added": [ " # check for functions existence so that we can mix distutils", " # extension with scipy_distutils functions without breakage", " if (hasattr(ext,'has_f2py_sources') and", " ext.has_f2py_sources()):" ], "deleted": [ " if ext.has_f2py_sources():" ] } } ] }, { "hash": "ef17bfac4931386c6c25edc37645c5fa260eaf84", "msg": "setup_extension now uses scipy_distutils instead of distutil extensions so that C++ files are linked correctly. If fails over to distutils if scipy_distutils isn't present in hopes that it will do the right thing.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-03-29T06:24:37+00:00", "author_timezone": 0, "committer_date": "2003-03-29T06:24:37+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "786056b68879b21a1166f8d40fdab2abf8a3e450" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 2, "insertions": 10, "lines": 12, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.5, "modified_files": [ { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -73,7 +73,12 @@ def create_extension(module_path, **kw):\n \n See build_extension for information on keyword arguments.\n \"\"\"\n- from distutils.core import Extension\n+ # some (most?) platforms will fail to link C++ correctly\n+ # unless scipy_distutils is used.\n+ try:\n+ from scipy_distutils.core import Extension\n+ except ImportError:\n+ from distutils.core import Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n@@ -204,7 +209,10 @@ def build_extension(module_path,compiler_name = '',build_dir = None,\n extension_name.\n \"\"\"\n success = 0\n- from distutils.core import setup, Extension\n+ try:\n+ from scipy_distutils.core import setup, Extension\n+ except ImportError:\n+ from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n", "added_lines": 10, "deleted_lines": 2, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n \n # The following line is a HACK to fix a problem with building the\n # freetype shared library under Mac OS X:\n ld += ' -framework AppKit'\n \n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n\n\ndef create_extension(module_path, **kw):\n \"\"\" Create an Extension that can be buil by setup.py\n \n See build_extension for information on keyword arguments.\n \"\"\"\n # some (most?) platforms will fail to link C++ correctly\n # unless scipy_distutils is used.\n try:\n from scipy_distutils.core import Extension\n except ImportError:\n from distutils.core import Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # the business end of the function\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n return ext \n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n try:\n from scipy_distutils.core import setup, Extension\n except ImportError:\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n ext = create_extension(module_path,**kw)\n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n \n # The following line is a HACK to fix a problem with building the\n # freetype shared library under Mac OS X:\n ld += ' -framework AppKit'\n \n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n\n\ndef create_extension(module_path, **kw):\n \"\"\" Create an Extension that can be buil by setup.py\n \n See build_extension for information on keyword arguments.\n \"\"\"\n from distutils.core import Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # the business end of the function\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n return ext \n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n ext = create_extension(module_path,**kw)\n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 13, "complexity": 3, "token_count": 95, "parameters": [], "start_line": 33, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "create_extension", "long_name": "create_extension( module_path , ** kw )", "filename": "build_tools.py", "nloc": 30, "complexity": 7, "token_count": 258, "parameters": [ "module_path", "kw" ], "start_line": 71, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 50, "complexity": 8, "token_count": 330, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 127, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 293, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 305, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 308, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 316, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 339, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 361, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 381, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 391, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 407, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 450, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "build_tools.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 513, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 564, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 574, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 605, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 609, "end_line": 611, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 13, "complexity": 3, "token_count": 95, "parameters": [], "start_line": 33, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "create_extension", "long_name": "create_extension( module_path , ** kw )", "filename": "build_tools.py", "nloc": 27, "complexity": 6, "token_count": 247, "parameters": [ "module_path", "kw" ], "start_line": 71, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 47, "complexity": 7, "token_count": 317, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 122, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 161, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 285, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 297, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 300, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 308, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 331, "end_line": 351, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 353, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 373, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 383, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 399, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 442, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "build_tools.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 505, "end_line": 545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 556, "end_line": 564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 566, "end_line": 592, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 597, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 601, "end_line": 603, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "create_extension", "long_name": "create_extension( module_path , ** kw )", "filename": "build_tools.py", "nloc": 30, "complexity": 7, "token_count": 258, "parameters": [ "module_path", "kw" ], "start_line": 71, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 50, "complexity": 8, "token_count": 330, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 127, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 0 } ], "nloc": 336, "complexity": 69, "token_count": 1979, "diff_parsed": { "added": [ " # some (most?) platforms will fail to link C++ correctly", " # unless scipy_distutils is used.", " try:", " from scipy_distutils.core import Extension", " except ImportError:", " from distutils.core import Extension", " try:", " from scipy_distutils.core import setup, Extension", " except ImportError:", " from distutils.core import setup, Extension" ], "deleted": [ " from distutils.core import Extension", " from distutils.core import setup, Extension" ] } } ] }, { "hash": "fb2b56cd02b70df12a5f6c520d7b37e4f0bf54c5", "msg": "fixed C++ builds on windows", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-03-29T06:39:37+00:00", "author_timezone": 0, "committer_date": "2003-03-29T06:39:37+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ef17bfac4931386c6c25edc37645c5fa260eaf84" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -99,7 +99,7 @@ def build_extension(self, ext):\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n \n- if save_linker_so[0]=='gcc':\n+ if save_linker_so and save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(ext_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(ext_name) and \\\n ext_name not in ext.libraries:\n ext.libraries.insert(0,ext_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n ext.library_dirs.append(build_flib.build_flib)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so and save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(ext_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(ext_name) and \\\n ext_name not in ext.libraries:\n ext.libraries.insert(0,ext_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n ext.library_dirs.append(build_flib.build_flib)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 73, "complexity": 27, "token_count": 543, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 101, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 123, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 73, "complexity": 26, "token_count": 541, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 101, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 123, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 73, "complexity": 27, "token_count": 543, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 101, "top_nesting_level": 1 } ], "nloc": 93, "complexity": 30, "token_count": 667, "diff_parsed": { "added": [ " if save_linker_so and save_linker_so[0]=='gcc':" ], "deleted": [ " if save_linker_so[0]=='gcc':" ] } } ] }, { "hash": "184fbdee6751ebe906bc5cc51a85f2c8f50c803b", "msg": "*** empty log message ***", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-04-10T23:52:21+00:00", "author_timezone": 0, "committer_date": "2003-04-10T23:52:21+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fb2b56cd02b70df12a5f6c520d7b37e4f0bf54c5" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 8, "insertions": 9, "lines": 17, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "weave/wx_spec.py", "new_path": "weave/wx_spec.py", "filename": "wx_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -4,7 +4,7 @@\n \n # these may need user configuration.\n if sys.platform == \"win32\":\n- wx_base = r'c:\\wxpython-2.3.3.1'\n+ wx_base = r'c:\\third\\wxpython-2.4.0.7'\n else:\n # probably should do some more discovery here.\n wx_base = '/usr/lib/wxPython'\n@@ -89,18 +89,19 @@ def init_info(self):\n #self.define_macros.append(('WINVER', '0x0350'))\n \n self.library_dirs.append(os.path.join(wx_base,'lib'))\n+ #self.include_dirs.append(os.path.join(wx_base,'include')) \n+ self.include_dirs.append(wx_base) \n self.include_dirs.append(os.path.join(wx_base,'include')) \n- \n-\n+ self.include_dirs.append(os.path.join(wx_base,'include','msw')) \n # how do I discover unicode or not unicode?? \n # non-unicode \n- #self.libraries.append('wxmswh')\n- #self.include_dirs.append(os.path.join(wx_base,'lib','mswdllh'))\n+ self.libraries.append('wxmsw24h')\n+ self.include_dirs.append(os.path.join(wx_base,'lib'))\n \n # unicode\n- self.libraries.append('wxmswuh')\n- self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))\n- self.define_macros.append(('UNICODE', '1'))\n+ #self.libraries.append('wxmswuh')\n+ #self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))\n+ #self.define_macros.append(('UNICODE', '1'))\n else:\n # make sure the gtk files are available \n # ?? Do I need to link to them?\n", "added_lines": 9, "deleted_lines": 8, "source_code": "import common_info\nfrom c_spec import common_base_converter\nimport sys,os\n\n# these may need user configuration.\nif sys.platform == \"win32\":\n wx_base = r'c:\\third\\wxpython-2.4.0.7'\nelse:\n # probably should do some more discovery here.\n wx_base = '/usr/lib/wxPython'\n\ndef get_wxconfig(flag):\n wxconfig = os.path.join(wx_base,'bin','wx-config')\n import commands\n res,settings = commands.getstatusoutput(wxconfig + ' --' + flag)\n if res:\n msg = wxconfig + ' failed. Impossible to learn wxPython settings'\n raise RuntimeError, msg\n return settings.split()\n\nwx_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj,const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n } \n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nclass wx_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n self.headers.append('\"wx/wx.h\"')\n if sys.platform == \"win32\": \n # These will be used in many cases\n self.headers.append('') \n \n # These are needed for linking.\n self.libraries.extend(['kernel32','user32','gdi32','comdlg32',\n 'winspool', 'winmm', 'shell32', \n 'oldnames', 'comctl32', 'ctl3d32',\n 'odbc32', 'ole32', 'oleaut32', \n 'uuid', 'rpcrt4', 'advapi32', 'wsock32'])\n \n # not sure which of these macros are needed.\n self.define_macros.append(('WIN32', '1'))\n self.define_macros.append(('__WIN32__', '1'))\n self.define_macros.append(('_WINDOWS', '1'))\n self.define_macros.append(('STRICT', '1'))\n # I think this will only work on NT/2000/XP set\n # set to 0x0400 for earlier versions.\n # Hmmm. setting this breaks stuff\n #self.define_macros.append(('WINVER', '0x0350'))\n\n self.library_dirs.append(os.path.join(wx_base,'lib'))\n #self.include_dirs.append(os.path.join(wx_base,'include')) \n self.include_dirs.append(wx_base) \n self.include_dirs.append(os.path.join(wx_base,'include')) \n self.include_dirs.append(os.path.join(wx_base,'include','msw')) \n # how do I discover unicode or not unicode?? \n # non-unicode \n self.libraries.append('wxmsw24h')\n self.include_dirs.append(os.path.join(wx_base,'lib'))\n \n # unicode\n #self.libraries.append('wxmswuh')\n #self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))\n #self.define_macros.append(('UNICODE', '1'))\n else:\n # make sure the gtk files are available \n # ?? Do I need to link to them?\n self.headers.append('\"gdk/gdk.h\"')\n # !! This shouldn't be hard coded.\n self.include_dirs.append(\"/usr/include/gtk-1.2\")\n self.include_dirs.append(\"/usr/include/glib-1.2\")\n self.include_dirs.append(\"/usr/lib/glib/include\")\n cxxflags = get_wxconfig('cxxflags')\n libflags = get_wxconfig('libs') + get_wxconfig('gl-libs')\n \n #older versions of wx do not support the ldflags.\n try:\n ldflags = get_wxconfig('ldflags')\n except RuntimeError:\n ldflags = []\n \n self.extra_compile_args.extend(cxxflags)\n self.extra_link_args.extend(libflags)\n self.extra_link_args.extend(ldflags) \n self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n wx_class = value.this.split('_')[-2]\n if wx_class[:2] == 'wx':\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return wx_to_c_template % self.template_vars()\n\n #def c_to_py_code(self):\n # return simple_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.this.split('_')[-2]\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\" ", "source_code_before": "import common_info\nfrom c_spec import common_base_converter\nimport sys,os\n\n# these may need user configuration.\nif sys.platform == \"win32\":\n wx_base = r'c:\\wxpython-2.3.3.1'\nelse:\n # probably should do some more discovery here.\n wx_base = '/usr/lib/wxPython'\n\ndef get_wxconfig(flag):\n wxconfig = os.path.join(wx_base,'bin','wx-config')\n import commands\n res,settings = commands.getstatusoutput(wxconfig + ' --' + flag)\n if res:\n msg = wxconfig + ' failed. Impossible to learn wxPython settings'\n raise RuntimeError, msg\n return settings.split()\n\nwx_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj,const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n } \n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nclass wx_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n self.headers.append('\"wx/wx.h\"')\n if sys.platform == \"win32\": \n # These will be used in many cases\n self.headers.append('') \n \n # These are needed for linking.\n self.libraries.extend(['kernel32','user32','gdi32','comdlg32',\n 'winspool', 'winmm', 'shell32', \n 'oldnames', 'comctl32', 'ctl3d32',\n 'odbc32', 'ole32', 'oleaut32', \n 'uuid', 'rpcrt4', 'advapi32', 'wsock32'])\n \n # not sure which of these macros are needed.\n self.define_macros.append(('WIN32', '1'))\n self.define_macros.append(('__WIN32__', '1'))\n self.define_macros.append(('_WINDOWS', '1'))\n self.define_macros.append(('STRICT', '1'))\n # I think this will only work on NT/2000/XP set\n # set to 0x0400 for earlier versions.\n # Hmmm. setting this breaks stuff\n #self.define_macros.append(('WINVER', '0x0350'))\n\n self.library_dirs.append(os.path.join(wx_base,'lib'))\n self.include_dirs.append(os.path.join(wx_base,'include')) \n \n\n # how do I discover unicode or not unicode?? \n # non-unicode \n #self.libraries.append('wxmswh')\n #self.include_dirs.append(os.path.join(wx_base,'lib','mswdllh'))\n \n # unicode\n self.libraries.append('wxmswuh')\n self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))\n self.define_macros.append(('UNICODE', '1'))\n else:\n # make sure the gtk files are available \n # ?? Do I need to link to them?\n self.headers.append('\"gdk/gdk.h\"')\n # !! This shouldn't be hard coded.\n self.include_dirs.append(\"/usr/include/gtk-1.2\")\n self.include_dirs.append(\"/usr/include/glib-1.2\")\n self.include_dirs.append(\"/usr/lib/glib/include\")\n cxxflags = get_wxconfig('cxxflags')\n libflags = get_wxconfig('libs') + get_wxconfig('gl-libs')\n \n #older versions of wx do not support the ldflags.\n try:\n ldflags = get_wxconfig('ldflags')\n except RuntimeError:\n ldflags = []\n \n self.extra_compile_args.extend(cxxflags)\n self.extra_link_args.extend(libflags)\n self.extra_link_args.extend(ldflags) \n self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n wx_class = value.this.split('_')[-2]\n if wx_class[:2] == 'wx':\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return wx_to_c_template % self.template_vars()\n\n #def c_to_py_code(self):\n # return simple_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.this.split('_')[-2]\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\" ", "methods": [ { "name": "get_wxconfig", "long_name": "get_wxconfig( flag )", "filename": "wx_spec.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "flag" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 56, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 40, "complexity": 3, "token_count": 345, "parameters": [ "self" ], "start_line": 60, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "wx_spec.py", "nloc": 9, "complexity": 3, "token_count": 44, "parameters": [ "self", "value" ], "start_line": 127, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "wx_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 137, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "wx_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 147, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 153, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "wx_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 160, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_wxconfig", "long_name": "get_wxconfig( flag )", "filename": "wx_spec.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "flag" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 56, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 39, "complexity": 3, "token_count": 332, "parameters": [ "self" ], "start_line": 60, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "wx_spec.py", "nloc": 9, "complexity": 3, "token_count": 44, "parameters": [ "self", "value" ], "start_line": 126, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "wx_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 136, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "wx_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 146, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 152, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "wx_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 159, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 40, "complexity": 3, "token_count": 345, "parameters": [ "self" ], "start_line": 60, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 } ], "nloc": 136, "complexity": 18, "token_count": 657, "diff_parsed": { "added": [ " wx_base = r'c:\\third\\wxpython-2.4.0.7'", " #self.include_dirs.append(os.path.join(wx_base,'include'))", " self.include_dirs.append(wx_base)", " self.include_dirs.append(os.path.join(wx_base,'include','msw'))", " self.libraries.append('wxmsw24h')", " self.include_dirs.append(os.path.join(wx_base,'lib'))", " #self.libraries.append('wxmswuh')", " #self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))", " #self.define_macros.append(('UNICODE', '1'))" ], "deleted": [ " wx_base = r'c:\\wxpython-2.3.3.1'", "", "", " #self.libraries.append('wxmswh')", " #self.include_dirs.append(os.path.join(wx_base,'lib','mswdllh'))", " self.libraries.append('wxmswuh')", " self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))", " self.define_macros.append(('UNICODE', '1'))" ] } } ] }, { "hash": "415e02ac4d800de29cff7a4a8b7b0fb4fe8e270d", "msg": "Adding Lahey compiler support (thanks to Fernando Perez and Pierre Schnizer)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-04-19T09:38:49+00:00", "author_timezone": 0, "committer_date": "2003-04-19T09:38:49+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "184fbdee6751ebe906bc5cc51a85f2c8f50c803b" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 51, "lines": 52, "files": 1, "dmm_unit_size": 0.25806451612903225, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.3225806451612903, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -47,6 +47,7 @@\n Gnu\n VAST\n F [unsupported]\n+ Lahey\n \"\"\"\n \n import distutils\n@@ -93,13 +94,17 @@ def run_command(command):\n else:\n run_command = commands.getstatusoutput\n \n-fcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST|F'\n+fcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n+ r'|Lahey|F'\n \n def show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n+ else:\n+ print yellow_text('Not found/available: %s Fortran compiler'\\\n+ % (compiler.vendor))\n \n class build_flib (build_clib):\n \n@@ -609,6 +614,8 @@ def get_version(self):\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n+ if not self.version:\n+ self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n@@ -1438,6 +1445,48 @@ def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n \n+# fperez\n+# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n+# bug in the version matching regexp and added verbose flag.\n+# /fperez\n+class lahey_fortran_compiler(fortran_compiler_base):\n+ vendor = 'Lahey'\n+ ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n+\n+ def __init__(self, fc = None, f90c = None,verbose=0):\n+ fortran_compiler_base.__init__(self,verbose=verbose)\n+ \n+ if fc is None:\n+ fc = 'lf95'\n+ if f90c is None:\n+ f90c = fc\n+\n+ self.f77_compiler = fc\n+ self.f90_compiler = f90c\n+\n+ switches = ''\n+ debug = ' -g --chk --chkglobal '\n+ self.f77_switches = self.f90_switches = switches\n+ self.f77_switches = self.f77_switches + ' --fix '\n+ self.f77_debug = self.f90_debug = debug\n+ self.f77_opt = self.f90_opt = self.get_opt()\n+ \n+ self.ver_cmd = self.f77_compiler+' --version'\n+ try:\n+ dir = os.environ['LAHEY']\n+ self.library_dirs = [os.path.join(dir,'lib')]\n+ except KeyError:\n+ self.library_dirs = []\n+\n+ self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n+\n+ def get_opt(self):\n+ opt = ' -O'\n+ return opt\n+\n+ def get_linker_so(self):\n+ return [self.f77_compiler ,'--shared']\n+\n ##############################################################################\n \n def find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n@@ -1474,6 +1523,7 @@ def find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n+ lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n \n", "added_lines": 51, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 72, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 100, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 137, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 158, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 199, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 208, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 230, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 237, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 246, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 267, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 280, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 293, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 352, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 390, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 417, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 455, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 489, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 494, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 501, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 510, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 517, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 538, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 583, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 596, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 625, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 631, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 638, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 664, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 677, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 742, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 759, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 793, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 836, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 843, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 866, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 879, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 901, "end_line": 921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 923, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 927, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 930, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 947, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 970, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 996, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1044, "end_line": 1106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1108, "end_line": 1125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1127, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1135, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1159, "end_line": 1188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1190, "end_line": 1204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1206, "end_line": 1207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1209, "end_line": 1215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1224, "end_line": 1227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1235, "end_line": 1256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1258, "end_line": 1260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1262, "end_line": 1263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1277, "end_line": 1305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1311, "end_line": 1312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1325, "end_line": 1356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1358, "end_line": 1359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1367, "end_line": 1391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1393, "end_line": 1396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1398, "end_line": 1399, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1415, "end_line": 1442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1444, "end_line": 1446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1456, "end_line": 1481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1483, "end_line": 1485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1487, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1492, "end_line": 1500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 71, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 87, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 26, "parameters": [], "start_line": 98, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 132, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 153, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 183, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 187, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 194, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 203, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 225, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 232, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 241, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 262, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 275, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 288, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 332, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 347, "end_line": 368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 385, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 412, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 443, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 450, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 455, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 484, "end_line": 487, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 489, "end_line": 494, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 496, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 501, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 505, "end_line": 507, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 509, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 512, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 533, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 578, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 588, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 130, "parameters": [ "self" ], "start_line": 591, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 616, "end_line": 617, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 618, "end_line": 619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 620, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 622, "end_line": 623, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 624, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 631, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 654, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 657, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 670, "end_line": 733, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 735, "end_line": 750, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 752, "end_line": 753, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 786, "end_line": 827, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 829, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 836, "end_line": 854, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 859, "end_line": 860, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 872, "end_line": 892, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 894, "end_line": 914, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 916, "end_line": 918, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 920, "end_line": 921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 923, "end_line": 933, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 940, "end_line": 961, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 963, "end_line": 981, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 989, "end_line": 1035, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1037, "end_line": 1099, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1101, "end_line": 1118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1120, "end_line": 1126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1128, "end_line": 1136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1138, "end_line": 1139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1141, "end_line": 1142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1152, "end_line": 1181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1183, "end_line": 1197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1199, "end_line": 1200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1202, "end_line": 1208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1217, "end_line": 1220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1228, "end_line": 1249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1251, "end_line": 1253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1255, "end_line": 1256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1270, "end_line": 1298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1304, "end_line": 1305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1318, "end_line": 1349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1351, "end_line": 1352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1360, "end_line": 1384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1386, "end_line": 1389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1391, "end_line": 1392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1408, "end_line": 1435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1437, "end_line": 1439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1443, "end_line": 1451, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 100, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1487, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1456, "end_line": 1481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 596, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1483, "end_line": 1485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "nloc": 1112, "complexity": 290, "token_count": 6554, "diff_parsed": { "added": [ " Lahey", "fcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\", " r'|Lahey|F'", " else:", " print yellow_text('Not found/available: %s Fortran compiler'\\", " % (compiler.vendor))", " if not self.version:", " self.announce(red_text('failed to match version!'))", "# fperez", "# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a", "# bug in the version matching regexp and added verbose flag.", "# /fperez", "class lahey_fortran_compiler(fortran_compiler_base):", " vendor = 'Lahey'", " ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'", "", " def __init__(self, fc = None, f90c = None,verbose=0):", " fortran_compiler_base.__init__(self,verbose=verbose)", "", " if fc is None:", " fc = 'lf95'", " if f90c is None:", " f90c = fc", "", " self.f77_compiler = fc", " self.f90_compiler = f90c", "", " switches = ''", " debug = ' -g --chk --chkglobal '", " self.f77_switches = self.f90_switches = switches", " self.f77_switches = self.f77_switches + ' --fix '", " self.f77_debug = self.f90_debug = debug", " self.f77_opt = self.f90_opt = self.get_opt()", "", " self.ver_cmd = self.f77_compiler+' --version'", " try:", " dir = os.environ['LAHEY']", " self.library_dirs = [os.path.join(dir,'lib')]", " except KeyError:", " self.library_dirs = []", "", " self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']", "", " def get_opt(self):", " opt = ' -O'", " return opt", "", " def get_linker_so(self):", " return [self.f77_compiler ,'--shared']", "", " lahey_fortran_compiler," ], "deleted": [ "fcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST|F'" ] } } ] }, { "hash": "d998fffb69dd77ff51bf253dc4d15711a296c070", "msg": "added a new converter that can handle the SWIG pointer conversions based on namespaces in C++. This is used in the freetype and agg wrappers.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-04-20T08:09:14+00:00", "author_timezone": 0, "committer_date": "2003-04-20T08:09:14+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "415e02ac4d800de29cff7a4a8b7b0fb4fe8e270d" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 0, "insertions": 147, "lines": 147, "files": 2, "dmm_unit_size": 0.7848101265822784, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.9240506329113924, "modified_files": [ { "old_path": null, "new_path": "weave/cpp_namespace_spec.py", "filename": "cpp_namespace_spec.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,110 @@\n+\"\"\" This converter works with classes protected by a namespace with\n+ SWIG pointers (Python strings). To use it to wrap classes in\n+ a C++ namespace called \"ft\", use the following:\n+ \n+ class ft_converter(cpp_namespace_converter):\n+ namespace = 'ft::' \n+\"\"\"\n+\n+from weave import common_info\n+from weave import base_info\n+from weave.base_spec import base_converter\n+\n+cpp_support_template = \\\n+\"\"\"\n+static %(cpp_struct)s* convert_to_%(cpp_clean_struct)s(PyObject* py_obj,char* name)\n+{\n+ %(cpp_struct)s *cpp_ptr = 0;\n+ char* str = PyString_AsString(py_obj);\n+ if (!str)\n+ handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n+ // work on this error reporting...\n+ //std::cout << \"in:\" << name << \" \" py_obj << std::endl;\n+ if (SWIG_GetPtr(str,(void **) &cpp_ptr,\"_%(cpp_struct)s_p\"))\n+ {\n+ handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n+ }\n+ //std::cout << \"out:\" << name << \" \" << str << std::endl;\n+ return cpp_ptr;\n+} \n+\n+static %(cpp_struct)s* py_to_%(cpp_clean_struct)s(PyObject* py_obj,char* name)\n+{\n+ %(cpp_struct)s *cpp_ptr;\n+ char* str = PyString_AsString(py_obj);\n+ if (!str)\n+ handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n+ // work on this error reporting...\n+ if (SWIG_GetPtr(str,(void **) &cpp_ptr,\"_%(cpp_struct)s_p\"))\n+ {\n+ handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n+ }\n+ return cpp_ptr;\n+} \n+\n+std::string %(cpp_clean_struct)s_to_py( %(cpp_struct)s* cpp_ptr)\n+{\n+ char ptr_string[%(ptr_string_len)s]; \n+ SWIG_MakePtr(ptr_string, cpp_ptr, \"_%(cpp_struct)s_p\");\n+ return std::string(ptr_string);\n+} \n+\n+\"\"\" \n+\n+class cpp_namespace_converter(base_converter):\n+ _build_information = [common_info.swig_info()]\n+ def __init__(self,class_name=None):\n+ self.type_name = 'unkown cpp_object'\n+ self.name = 'no name' \n+ if class_name:\n+ # customize support_code for whatever type I was handed.\n+ clean_name = class_name.replace('::','_')\n+ clean_name = clean_name.replace('<','_')\n+ clean_name = clean_name.replace('>','_')\n+ clean_name = clean_name.replace(' ','_')\n+ # should be enough for 64 bit machines\n+ str_len = len(clean_name) + 20 \n+ vals = {'cpp_struct': class_name,\n+ 'cpp_clean_struct': clean_name,\n+ 'ptr_string_len': str_len }\n+ specialized_support = cpp_support_template % vals\n+ custom = base_info.base_info()\n+ custom._support_code = [specialized_support]\n+ self._build_information = self._build_information + [custom]\n+ self.type_name = class_name\n+\n+ def type_match(self,value):\n+ try:\n+ cpp_ident = value.split('_')[2]\n+ if cpp_ident.find(self.namespace) != -1:\n+ return 1\n+ except:\n+ pass\n+ return 0\n+ \n+ def type_spec(self,name,value):\n+ # factory\n+ ptr_fields = value.split('_')\n+ class_name = '_'.join(ptr_fields[2:-1])\n+ new_spec = self.__class__(class_name)\n+ new_spec.name = name \n+ return new_spec\n+ \n+ def declaration_code(self,inline=0):\n+ type = self.type_name\n+ clean_type = type.replace('::','_')\n+ name = self.name\n+ var_name = self.retrieve_py_variable(inline)\n+ template = '%(type)s *%(name)s = '\\\n+ 'convert_to_%(clean_type)s(%(var_name)s,\"%(name)s\");\\n'\n+ code = template % locals()\n+ return code\n+ \n+ def __repr__(self):\n+ msg = \"(%s:: name: %s)\" % (self.type_name,self.name)\n+ return msg\n+ def __cmp__(self,other):\n+ #only works for equal\n+ return cmp(self.name,other.name) or \\\n+ cmp(self.__class__, other.__class__) or \\\n+ cmp(self.type_name,other.type_name)\n", "added_lines": 110, "deleted_lines": 0, "source_code": "\"\"\" This converter works with classes protected by a namespace with\n SWIG pointers (Python strings). To use it to wrap classes in\n a C++ namespace called \"ft\", use the following:\n \n class ft_converter(cpp_namespace_converter):\n namespace = 'ft::' \n\"\"\"\n\nfrom weave import common_info\nfrom weave import base_info\nfrom weave.base_spec import base_converter\n\ncpp_support_template = \\\n\"\"\"\nstatic %(cpp_struct)s* convert_to_%(cpp_clean_struct)s(PyObject* py_obj,char* name)\n{\n %(cpp_struct)s *cpp_ptr = 0;\n char* str = PyString_AsString(py_obj);\n if (!str)\n handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n // work on this error reporting...\n //std::cout << \"in:\" << name << \" \" py_obj << std::endl;\n if (SWIG_GetPtr(str,(void **) &cpp_ptr,\"_%(cpp_struct)s_p\"))\n {\n handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n }\n //std::cout << \"out:\" << name << \" \" << str << std::endl;\n return cpp_ptr;\n} \n\nstatic %(cpp_struct)s* py_to_%(cpp_clean_struct)s(PyObject* py_obj,char* name)\n{\n %(cpp_struct)s *cpp_ptr;\n char* str = PyString_AsString(py_obj);\n if (!str)\n handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n // work on this error reporting...\n if (SWIG_GetPtr(str,(void **) &cpp_ptr,\"_%(cpp_struct)s_p\"))\n {\n handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);\n }\n return cpp_ptr;\n} \n\nstd::string %(cpp_clean_struct)s_to_py( %(cpp_struct)s* cpp_ptr)\n{\n char ptr_string[%(ptr_string_len)s]; \n SWIG_MakePtr(ptr_string, cpp_ptr, \"_%(cpp_struct)s_p\");\n return std::string(ptr_string);\n} \n\n\"\"\" \n\nclass cpp_namespace_converter(base_converter):\n _build_information = [common_info.swig_info()]\n def __init__(self,class_name=None):\n self.type_name = 'unkown cpp_object'\n self.name = 'no name' \n if class_name:\n # customize support_code for whatever type I was handed.\n clean_name = class_name.replace('::','_')\n clean_name = clean_name.replace('<','_')\n clean_name = clean_name.replace('>','_')\n clean_name = clean_name.replace(' ','_')\n # should be enough for 64 bit machines\n str_len = len(clean_name) + 20 \n vals = {'cpp_struct': class_name,\n 'cpp_clean_struct': clean_name,\n 'ptr_string_len': str_len }\n specialized_support = cpp_support_template % vals\n custom = base_info.base_info()\n custom._support_code = [specialized_support]\n self._build_information = self._build_information + [custom]\n self.type_name = class_name\n\n def type_match(self,value):\n try:\n cpp_ident = value.split('_')[2]\n if cpp_ident.find(self.namespace) != -1:\n return 1\n except:\n pass\n return 0\n \n def type_spec(self,name,value):\n # factory\n ptr_fields = value.split('_')\n class_name = '_'.join(ptr_fields[2:-1])\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n \n def declaration_code(self,inline=0):\n type = self.type_name\n clean_type = type.replace('::','_')\n name = self.name\n var_name = self.retrieve_py_variable(inline)\n template = '%(type)s *%(name)s = '\\\n 'convert_to_%(clean_type)s(%(var_name)s,\"%(name)s\");\\n'\n code = template % locals()\n return code\n \n def __repr__(self):\n msg = \"(%s:: name: %s)\" % (self.type_name,self.name)\n return msg\n def __cmp__(self,other):\n #only works for equal\n return cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.type_name,other.type_name)\n", "source_code_before": null, "methods": [ { "name": "__init__", "long_name": "__init__( self , class_name = None )", "filename": "cpp_namespace_spec.py", "nloc": 17, "complexity": 2, "token_count": 120, "parameters": [ "self", "class_name" ], "start_line": 56, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "cpp_namespace_spec.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [ "self", "value" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "cpp_namespace_spec.py", "nloc": 6, "complexity": 1, "token_count": 46, "parameters": [ "self", "name", "value" ], "start_line": 85, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , inline = 0 )", "filename": "cpp_namespace_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self", "inline" ], "start_line": 93, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "cpp_namespace_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "cpp_namespace_spec.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "self", "other" ], "start_line": 106, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "methods_before": [], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , class_name = None )", "filename": "cpp_namespace_spec.py", "nloc": 17, "complexity": 2, "token_count": 120, "parameters": [ "self", "class_name" ], "start_line": 56, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , inline = 0 )", "filename": "cpp_namespace_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self", "inline" ], "start_line": 93, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "cpp_namespace_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "cpp_namespace_spec.py", "nloc": 6, "complexity": 1, "token_count": 46, "parameters": [ "self", "name", "value" ], "start_line": 85, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "cpp_namespace_spec.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [ "self", "value" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "cpp_namespace_spec.py", "nloc": 4, "complexity": 3, "token_count": 42, "parameters": [ "self", "other" ], "start_line": 106, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 99, "complexity": 11, "token_count": 359, "diff_parsed": { "added": [ "\"\"\" This converter works with classes protected by a namespace with", " SWIG pointers (Python strings). To use it to wrap classes in", " a C++ namespace called \"ft\", use the following:", "", " class ft_converter(cpp_namespace_converter):", " namespace = 'ft::'", "\"\"\"", "", "from weave import common_info", "from weave import base_info", "from weave.base_spec import base_converter", "", "cpp_support_template = \\", "\"\"\"", "static %(cpp_struct)s* convert_to_%(cpp_clean_struct)s(PyObject* py_obj,char* name)", "{", " %(cpp_struct)s *cpp_ptr = 0;", " char* str = PyString_AsString(py_obj);", " if (!str)", " handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);", " // work on this error reporting...", " //std::cout << \"in:\" << name << \" \" py_obj << std::endl;", " if (SWIG_GetPtr(str,(void **) &cpp_ptr,\"_%(cpp_struct)s_p\"))", " {", " handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);", " }", " //std::cout << \"out:\" << name << \" \" << str << std::endl;", " return cpp_ptr;", "}", "", "static %(cpp_struct)s* py_to_%(cpp_clean_struct)s(PyObject* py_obj,char* name)", "{", " %(cpp_struct)s *cpp_ptr;", " char* str = PyString_AsString(py_obj);", " if (!str)", " handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);", " // work on this error reporting...", " if (SWIG_GetPtr(str,(void **) &cpp_ptr,\"_%(cpp_struct)s_p\"))", " {", " handle_conversion_error(py_obj,\"%(cpp_struct)s\", name);", " }", " return cpp_ptr;", "}", "", "std::string %(cpp_clean_struct)s_to_py( %(cpp_struct)s* cpp_ptr)", "{", " char ptr_string[%(ptr_string_len)s];", " SWIG_MakePtr(ptr_string, cpp_ptr, \"_%(cpp_struct)s_p\");", " return std::string(ptr_string);", "}", "", "\"\"\"", "", "class cpp_namespace_converter(base_converter):", " _build_information = [common_info.swig_info()]", " def __init__(self,class_name=None):", " self.type_name = 'unkown cpp_object'", " self.name = 'no name'", " if class_name:", " # customize support_code for whatever type I was handed.", " clean_name = class_name.replace('::','_')", " clean_name = clean_name.replace('<','_')", " clean_name = clean_name.replace('>','_')", " clean_name = clean_name.replace(' ','_')", " # should be enough for 64 bit machines", " str_len = len(clean_name) + 20", " vals = {'cpp_struct': class_name,", " 'cpp_clean_struct': clean_name,", " 'ptr_string_len': str_len }", " specialized_support = cpp_support_template % vals", " custom = base_info.base_info()", " custom._support_code = [specialized_support]", " self._build_information = self._build_information + [custom]", " self.type_name = class_name", "", " def type_match(self,value):", " try:", " cpp_ident = value.split('_')[2]", " if cpp_ident.find(self.namespace) != -1:", " return 1", " except:", " pass", " return 0", "", " def type_spec(self,name,value):", " # factory", " ptr_fields = value.split('_')", " class_name = '_'.join(ptr_fields[2:-1])", " new_spec = self.__class__(class_name)", " new_spec.name = name", " return new_spec", "", " def declaration_code(self,inline=0):", " type = self.type_name", " clean_type = type.replace('::','_')", " name = self.name", " var_name = self.retrieve_py_variable(inline)", " template = '%(type)s *%(name)s = '\\", " 'convert_to_%(clean_type)s(%(var_name)s,\"%(name)s\");\\n'", " code = template % locals()", " return code", "", " def __repr__(self):", " msg = \"(%s:: name: %s)\" % (self.type_name,self.name)", " return msg", " def __cmp__(self,other):", " #only works for equal", " return cmp(self.name,other.name) or \\", " cmp(self.__class__, other.__class__) or \\", " cmp(self.type_name,other.type_name)" ], "deleted": [] } }, { "old_path": "weave/scxx/dict.h", "new_path": "weave/scxx/dict.h", "filename": "dict.h", "extension": "h", "change_type": "MODIFY", "diff": "@@ -55,6 +55,36 @@ public:\n }\n };\n \n+ //-------------------------------------------------------------------------\n+ // get -- object, numeric, and string versions\n+ //------------------------------------------------------------------------- \n+ object get (object& key) {\n+ object rslt = PyDict_GetItem(_obj, key);\n+ return rslt;\n+ };\n+ object get (int key) {\n+ object _key = object(key);\n+ return get(_key);\n+ };\n+ object get (double key) {\n+ object _key = object(key);\n+ return get(_key);\n+ };\n+ object get (const std::complex& key) {\n+ object _key = object(key);\n+ return get(_key);\n+ }; \n+ object get (const char* key) {\n+ object rslt = PyDict_GetItemString(_obj, (char*) key);\n+ return rslt;\n+ };\n+ object get (const std::string& key) {\n+ return get(key.c_str());\n+ };\n+ object get (char key) {\n+ return get(&key);\n+ };\n+ \n //-------------------------------------------------------------------------\n // operator[] -- object and numeric versions\n //------------------------------------------------------------------------- \n@@ -91,6 +121,10 @@ public:\n return operator [](key.c_str());\n };\n \n+ keyed_ref operator [] (char key) {\n+ return operator [](&key);\n+ };\n+\n //-------------------------------------------------------------------------\n // has_key -- object and numeric versions\n //------------------------------------------------------------------------- \n@@ -119,6 +153,9 @@ public:\n bool has_key(const std::string& key) const {\n return has_key(key.c_str());\n };\n+ bool has_key(char key) const {\n+ return has_key(&key);\n+ };\n \n //-------------------------------------------------------------------------\n // len and length methods\n", "added_lines": 37, "deleted_lines": 0, "source_code": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(DICT_H_INCLUDED_)\n#define DICT_H_INCLUDED_\n#include \n#include \"object.h\"\n#include \"list.h\"\n\nnamespace py {\n\n\nclass dict : public object\n{\npublic:\n\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n dict() : object (PyDict_New()) { lose_ref(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~dict() {};\n\n //-------------------------------------------------------------------------\n // operator= \n //-------------------------------------------------------------------------\n virtual dict& operator=(const dict& other) {\n grab_ref(other);\n return *this;\n };\n dict& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n\n //-------------------------------------------------------------------------\n // type checking\n //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n if (!PyDict_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a dictionary\");\n }\n };\n \n //-------------------------------------------------------------------------\n // get -- object, numeric, and string versions\n //------------------------------------------------------------------------- \n object get (object& key) {\n object rslt = PyDict_GetItem(_obj, key);\n return rslt;\n };\n object get (int key) {\n object _key = object(key);\n return get(_key);\n };\n object get (double key) {\n object _key = object(key);\n return get(_key);\n };\n object get (const std::complex& key) {\n object _key = object(key);\n return get(_key);\n }; \n object get (const char* key) {\n object rslt = PyDict_GetItemString(_obj, (char*) key);\n return rslt;\n };\n object get (const std::string& key) {\n return get(key.c_str());\n };\n object get (char key) {\n return get(&key);\n };\n \n //-------------------------------------------------------------------------\n // operator[] -- object and numeric versions\n //------------------------------------------------------------------------- \n keyed_ref operator [] (object& key) {\n object rslt = PyDict_GetItem(_obj, key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n return keyed_ref(rslt, *this, key);\n };\n keyed_ref operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n };\n \n //-------------------------------------------------------------------------\n // operator[] non-const -- string versions\n //-------------------------------------------------------------------------\n keyed_ref operator [] (const char* key) {\n object rslt = PyDict_GetItemString(_obj, (char*) key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n object _key = key; \n return keyed_ref(rslt, *this, _key);\n };\n keyed_ref operator [] (const std::string& key) {\n return operator [](key.c_str());\n };\n\n keyed_ref operator [] (char key) {\n return operator [](&key);\n };\n\n //-------------------------------------------------------------------------\n // has_key -- object and numeric versions\n //------------------------------------------------------------------------- \n bool has_key(object& key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n bool has_key(int key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(double key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(const std::complex& key) const {\n object _key = key; \n return has_key(_key);\n };\n\n //-------------------------------------------------------------------------\n // has_key -- string versions\n //-------------------------------------------------------------------------\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n bool has_key(const std::string& key) const {\n return has_key(key.c_str());\n };\n bool has_key(char key) const {\n return has_key(&key);\n };\n\n //-------------------------------------------------------------------------\n // len and length methods\n //------------------------------------------------------------------------- \n int len() const {\n return PyDict_Size(_obj);\n } \n int length() const {\n return PyDict_Size(_obj);\n };\n\n //-------------------------------------------------------------------------\n // set_item\n //-------------------------------------------------------------------------\n virtual void set_item(const char* key, object& val) {\n int rslt = PyDict_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n\n virtual void set_item(object& key, object& val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key must be hashable\");\n };\n\n //-------------------------------------------------------------------------\n // clear\n //------------------------------------------------------------------------- \n void clear() {\n PyDict_Clear(_obj);\n };\n \n //-------------------------------------------------------------------------\n // update\n //------------------------------------------------------------------------- \n#if PY_VERSION_HEX >= 0x02020000\n void update(dict& other) {\n PyDict_Merge(_obj,other,1);\n };\n#endif\n //-------------------------------------------------------------------------\n // del -- remove key from dictionary\n // overloaded to take all common weave types\n //-------------------------------------------------------------------------\n void del(object& key) {\n int rslt = PyDict_DelItem(_obj, key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(int key) {\n object _key = key;\n del(_key);\n };\n void del(double key) {\n object _key = key;\n del(_key);\n };\n void del(const std::complex& key) {\n object _key = key;\n del(_key);\n };\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(const std::string key) {\n del(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // items, keys, and values\n //-------------------------------------------------------------------------\n list items() const {\n PyObject* rslt = PyDict_Items(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get items\");\n return lose_ref(rslt);\n };\n\n list keys() const {\n PyObject* rslt = PyDict_Keys(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get keys\");\n return lose_ref(rslt);\n };\n\n list values() const {\n PyObject* rslt = PyDict_Values(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get values\");\n return lose_ref(rslt);\n };\n};\n\n} // namespace\n#endif // DICT_H_INCLUDED_\n", "source_code_before": "/******************************************** \n copyright 1999 McMillan Enterprises, Inc.\n www.mcmillan-inc.com\n \n modified for weave by eric jones\n*********************************************/\n\n#if !defined(DICT_H_INCLUDED_)\n#define DICT_H_INCLUDED_\n#include \n#include \"object.h\"\n#include \"list.h\"\n\nnamespace py {\n\n\nclass dict : public object\n{\npublic:\n\n //-------------------------------------------------------------------------\n // constructors\n //-------------------------------------------------------------------------\n dict() : object (PyDict_New()) { lose_ref(_obj); }\n dict(const dict& other) : object(other) {};\n dict(PyObject* obj) : object(obj) {\n _violentTypeCheck();\n };\n \n //-------------------------------------------------------------------------\n // destructor\n //-------------------------------------------------------------------------\n virtual ~dict() {};\n\n //-------------------------------------------------------------------------\n // operator= \n //-------------------------------------------------------------------------\n virtual dict& operator=(const dict& other) {\n grab_ref(other);\n return *this;\n };\n dict& operator=(const object& other) {\n grab_ref(other);\n _violentTypeCheck();\n return *this;\n };\n\n //-------------------------------------------------------------------------\n // type checking\n //-------------------------------------------------------------------------\n virtual void _violentTypeCheck() {\n if (!PyDict_Check(_obj)) {\n grab_ref(0);\n fail(PyExc_TypeError, \"Not a dictionary\");\n }\n };\n \n //-------------------------------------------------------------------------\n // operator[] -- object and numeric versions\n //------------------------------------------------------------------------- \n keyed_ref operator [] (object& key) {\n object rslt = PyDict_GetItem(_obj, key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n return keyed_ref(rslt, *this, key);\n };\n keyed_ref operator [] (int key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (double key) {\n object _key = object(key);\n return operator [](_key);\n };\n keyed_ref operator [] (const std::complex& key) {\n object _key = object(key);\n return operator [](_key);\n };\n \n //-------------------------------------------------------------------------\n // operator[] non-const -- string versions\n //-------------------------------------------------------------------------\n keyed_ref operator [] (const char* key) {\n object rslt = PyDict_GetItemString(_obj, (char*) key);\n if (!(PyObject*)rslt)\n PyErr_Clear(); // Ignore key errors\n object _key = key; \n return keyed_ref(rslt, *this, _key);\n };\n keyed_ref operator [] (const std::string& key) {\n return operator [](key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // has_key -- object and numeric versions\n //------------------------------------------------------------------------- \n bool has_key(object& key) const {\n return PyMapping_HasKey(_obj, key)==1;\n };\n bool has_key(int key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(double key) const {\n object _key = key; \n return has_key(_key);\n };\n bool has_key(const std::complex& key) const {\n object _key = key; \n return has_key(_key);\n };\n\n //-------------------------------------------------------------------------\n // has_key -- string versions\n //-------------------------------------------------------------------------\n bool has_key(const char* key) const {\n return PyMapping_HasKeyString(_obj, (char*) key)==1;\n };\n bool has_key(const std::string& key) const {\n return has_key(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // len and length methods\n //------------------------------------------------------------------------- \n int len() const {\n return PyDict_Size(_obj);\n } \n int length() const {\n return PyDict_Size(_obj);\n };\n\n //-------------------------------------------------------------------------\n // set_item\n //-------------------------------------------------------------------------\n virtual void set_item(const char* key, object& val) {\n int rslt = PyDict_SetItemString(_obj, (char*) key, val);\n if (rslt==-1)\n fail(PyExc_RuntimeError, \"Cannot add key / value\");\n };\n\n virtual void set_item(object& key, object& val) const {\n int rslt = PyDict_SetItem(_obj, key, val);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key must be hashable\");\n };\n\n //-------------------------------------------------------------------------\n // clear\n //------------------------------------------------------------------------- \n void clear() {\n PyDict_Clear(_obj);\n };\n \n //-------------------------------------------------------------------------\n // update\n //------------------------------------------------------------------------- \n#if PY_VERSION_HEX >= 0x02020000\n void update(dict& other) {\n PyDict_Merge(_obj,other,1);\n };\n#endif\n //-------------------------------------------------------------------------\n // del -- remove key from dictionary\n // overloaded to take all common weave types\n //-------------------------------------------------------------------------\n void del(object& key) {\n int rslt = PyDict_DelItem(_obj, key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(int key) {\n object _key = key;\n del(_key);\n };\n void del(double key) {\n object _key = key;\n del(_key);\n };\n void del(const std::complex& key) {\n object _key = key;\n del(_key);\n };\n void del(const char* key) {\n int rslt = PyDict_DelItemString(_obj, (char*) key);\n if (rslt==-1)\n fail(PyExc_KeyError, \"Key not found\");\n };\n void del(const std::string key) {\n del(key.c_str());\n };\n\n //-------------------------------------------------------------------------\n // items, keys, and values\n //-------------------------------------------------------------------------\n list items() const {\n PyObject* rslt = PyDict_Items(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get items\");\n return lose_ref(rslt);\n };\n\n list keys() const {\n PyObject* rslt = PyDict_Keys(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get keys\");\n return lose_ref(rslt);\n };\n\n list values() const {\n PyObject* rslt = PyDict_Values(_obj);\n if (rslt==0)\n fail(PyExc_RuntimeError, \"failed to get values\");\n return lose_ref(rslt);\n };\n};\n\n} // namespace\n#endif // DICT_H_INCLUDED_\n", "methods": [ { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 42, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 51, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( object & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "key" ], "start_line": 61, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "key" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "key" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 73, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( const char * key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "key" ], "start_line": 77, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 81, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( char key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "key" ], "start_line": 84, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( object & key)", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "key" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 105, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "key" ], "start_line": 113, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 120, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( char key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "key" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( object & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 131, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( int key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 134, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( double key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 138, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: complex & key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 142, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 150, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: string & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 153, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( char key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "key" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 166, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , object & val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 173, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( object & key , object & val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 179, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::update", "long_name": "py::dict::update( dict & other)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 196, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( object & key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 209, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 213, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 217, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 221, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: string key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 226, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 233, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 240, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 247, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "methods_before": [ { "name": "py::dict::dict", "long_name": "py::dict::dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 17, "parameters": [], "start_line": 24, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( const dict & other)", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 14, "parameters": [ "other" ], "start_line": 25, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::dict", "long_name": "py::dict::dict( PyObject * obj)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "obj" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::~dict", "long_name": "py::dict::~dict()", "filename": "dict.h", "nloc": 1, "complexity": 1, "token_count": 5, "parameters": [], "start_line": 33, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 1, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const dict & other)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "other" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator =", "long_name": "py::dict::operator =( const object & other)", "filename": "dict.h", "nloc": 5, "complexity": 1, "token_count": 23, "parameters": [ "other" ], "start_line": 42, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::_violentTypeCheck", "long_name": "py::dict::_violentTypeCheck()", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 27, "parameters": [], "start_line": 51, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( object & key)", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "key" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 25, "parameters": [ "key" ], "start_line": 71, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "std" ], "start_line": 75, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const char * key)", "filename": "dict.h", "nloc": 7, "complexity": 2, "token_count": 54, "parameters": [ "key" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "std" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( object & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 97, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( int key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( double key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "key" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: complex & key) const", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "std" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const char * key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "key" ], "start_line": 116, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( const std :: string & key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "std" ], "start_line": 119, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::len", "long_name": "py::dict::len() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 126, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::length", "long_name": "py::dict::length() const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 129, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( const char * key , object & val)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "key", "val" ], "start_line": 136, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::set_item", "long_name": "py::dict::set_item( object & key , object & val) const", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 39, "parameters": [ "key", "val" ], "start_line": 142, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::clear", "long_name": "py::dict::clear()", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [], "start_line": 151, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::update", "long_name": "py::dict::update( dict & other)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "other" ], "start_line": 159, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( object & key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 32, "parameters": [ "key" ], "start_line": 167, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 172, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 17, "parameters": [ "key" ], "start_line": 176, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "std" ], "start_line": 180, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const char * key)", "filename": "dict.h", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "key" ], "start_line": 184, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "py::dict::del", "long_name": "py::dict::del( const std :: string key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "std" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::items", "long_name": "py::dict::items() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 196, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::keys", "long_name": "py::dict::keys() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 203, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 }, { "name": "py::dict::values", "long_name": "py::dict::values() const", "filename": "dict.h", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [], "start_line": 210, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "py::dict::get", "long_name": "py::dict::get( int key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "key" ], "start_line": 65, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( char key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "key" ], "start_line": 84, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( const std :: complex & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "std" ], "start_line": 73, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::has_key", "long_name": "py::dict::has_key( char key) const", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "key" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( double key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "key" ], "start_line": 69, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::operator [ ]", "long_name": "py::dict::operator [ ]( char key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "key" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( object & key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 21, "parameters": [ "key" ], "start_line": 61, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( const char * key)", "filename": "dict.h", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "key" ], "start_line": 77, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "py::dict::get", "long_name": "py::dict::get( const std :: string & key)", "filename": "dict.h", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "std" ], "start_line": 81, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 } ], "nloc": 176, "complexity": 53, "token_count": 1129, "diff_parsed": { "added": [ " //-------------------------------------------------------------------------", " // get -- object, numeric, and string versions", " //-------------------------------------------------------------------------", " object get (object& key) {", " object rslt = PyDict_GetItem(_obj, key);", " return rslt;", " };", " object get (int key) {", " object _key = object(key);", " return get(_key);", " };", " object get (double key) {", " object _key = object(key);", " return get(_key);", " };", " object get (const std::complex& key) {", " object _key = object(key);", " return get(_key);", " };", " object get (const char* key) {", " object rslt = PyDict_GetItemString(_obj, (char*) key);", " return rslt;", " };", " object get (const std::string& key) {", " return get(key.c_str());", " };", " object get (char key) {", " return get(&key);", " };", "", " keyed_ref operator [] (char key) {", " return operator [](&key);", " };", "", " bool has_key(char key) const {", " return has_key(&key);", " };" ], "deleted": [] } } ] }, { "hash": "338676abb35f3ba31532116a7bdf7f10c6f0801f", "msg": "Catching also ImportError that can happen when e.g. ppimported cluster module is not installed but getmodule tries to access its __dict__", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-04-23T19:10:31+00:00", "author_timezone": 0, "committer_date": "2003-04-23T19:10:31+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d998fffb69dd77ff51bf253dc4d15711a296c070" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/catalog.py", "new_path": "weave/catalog.py", "filename": "catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -73,7 +73,7 @@ def getmodule(object):\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n- except (TypeError, KeyError):\n+ except (TypeError, KeyError, ImportError):\n pass \n return value\n \n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport pickle\nimport tempfile\n\ntry:\n import dbhash\n import shelve\n dumb = 0\nexcept ImportError:\n import dumb_shelve as shelve\n dumb = 1\n\n#For testing...\n#import dumb_shelve as shelve\n#dumb = 1\n\n#import shelve\n#dumb = 0\n \ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except (TypeError, KeyError, ImportError):\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n\ndef create_dir(p):\n \"\"\" Create a directory and any necessary intermediate directories.\"\"\"\n if not os.path.exists(p):\n try:\n os.mkdir(p)\n except OSError:\n # perhaps one or more intermediate path components don't exist\n # try to create them\n base,dir = os.path.split(p)\n create_dir(base)\n # don't enclose this one in try/except - we want the user to\n # get failure info\n os.mkdir(p)\n\ndef is_writable(dir):\n dummy = os.path.join(dir, \"dummy\")\n try:\n open(dummy, 'w')\n except IOError:\n return 0\n os.unlink(dummy)\n return 1\n\ndef whoami():\n \"\"\"return a string identifying the user.\"\"\"\n return os.environ.get(\"USER\") or os.environ.get(\"USERNAME\") or \"unknown\"\n\ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n \n # add a subdirectory for the OS.\n # It might be better to do this at a different location so that\n # it wasn't only the default directory that gets this behavior. \n #path = os.path.join(path,sys.platform)\n else:\n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n \n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\ndef intermediate_dir():\n \"\"\" Location in temp dir for storing .cpp and .o files during\n builds.\n \"\"\"\n python_name = \"python%d%d_intermediate\" % tuple(sys.version_info[:2]) \n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n if not os.path.exists(path):\n create_dir(path)\n return path\n \ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n Well... it should be. Stuck with dumbdbm for now and the modes\n almost don't matter. We do some checking for 'r' mode, but that\n is about it.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n try:\n # code reliant on the fact that we are using dumbdbm\n if dumb and mode == 'r' and not os.path.exists(catalog_file+'.dat'):\n sh = None\n else:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n # open every stinking file to check if it exists.\n # This is because anydbm doesn't provide a consistent naming \n # convention across platforms for its files \n existing_files = []\n for file in files:\n if get_catalog(os.path.dirname(file),'r') is not None:\n existing_files.append(file)\n # This is the non-portable (and much faster) old code\n #existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else:\n # if it is in the cache, then it is also\n # been persisted \n return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_dir = self.get_writable_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n import glob\n files = glob.glob(cat_file+'*')\n for f in files:\n os.remove(f)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n # Prabhu was getting some corrupt catalog errors. I'll put a try/except\n # to protect against this, but should really try and track down the issue.\n function_list = [function]\n try:\n function_list = function_list + cat.get(code,[])\n except pickle.UnpicklingError:\n pass\n cat[code] = function_list\n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport pickle\nimport tempfile\n\ntry:\n import dbhash\n import shelve\n dumb = 0\nexcept ImportError:\n import dumb_shelve as shelve\n dumb = 1\n\n#For testing...\n#import dumb_shelve as shelve\n#dumb = 1\n\n#import shelve\n#dumb = 0\n \ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except (TypeError, KeyError):\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n\ndef create_dir(p):\n \"\"\" Create a directory and any necessary intermediate directories.\"\"\"\n if not os.path.exists(p):\n try:\n os.mkdir(p)\n except OSError:\n # perhaps one or more intermediate path components don't exist\n # try to create them\n base,dir = os.path.split(p)\n create_dir(base)\n # don't enclose this one in try/except - we want the user to\n # get failure info\n os.mkdir(p)\n\ndef is_writable(dir):\n dummy = os.path.join(dir, \"dummy\")\n try:\n open(dummy, 'w')\n except IOError:\n return 0\n os.unlink(dummy)\n return 1\n\ndef whoami():\n \"\"\"return a string identifying the user.\"\"\"\n return os.environ.get(\"USER\") or os.environ.get(\"USERNAME\") or \"unknown\"\n\ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n \n # add a subdirectory for the OS.\n # It might be better to do this at a different location so that\n # it wasn't only the default directory that gets this behavior. \n #path = os.path.join(path,sys.platform)\n else:\n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n \n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\ndef intermediate_dir():\n \"\"\" Location in temp dir for storing .cpp and .o files during\n builds.\n \"\"\"\n python_name = \"python%d%d_intermediate\" % tuple(sys.version_info[:2]) \n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n if not os.path.exists(path):\n create_dir(path)\n return path\n \ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n Well... it should be. Stuck with dumbdbm for now and the modes\n almost don't matter. We do some checking for 'r' mode, but that\n is about it.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n try:\n # code reliant on the fact that we are using dumbdbm\n if dumb and mode == 'r' and not os.path.exists(catalog_file+'.dat'):\n sh = None\n else:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n # open every stinking file to check if it exists.\n # This is because anydbm doesn't provide a consistent naming \n # convention across platforms for its files \n existing_files = []\n for file in files:\n if get_catalog(os.path.dirname(file),'r') is not None:\n existing_files.append(file)\n # This is the non-portable (and much faster) old code\n #existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else:\n # if it is in the cache, then it is also\n # been persisted \n return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_dir = self.get_writable_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n import glob\n files = glob.glob(cat_file+'*')\n for f in files:\n os.remove(f)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n # Prabhu was getting some corrupt catalog errors. I'll put a try/except\n # to protect against this, but should really try and track down the issue.\n function_list = [function]\n try:\n function_list = function_list + cat.get(code,[])\n except pickle.UnpicklingError:\n pass\n cat[code] = function_list\n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 81, "parameters": [ "object" ], "start_line": 53, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 80, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 91, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "create_dir", "long_name": "create_dir( p )", "filename": "catalog.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "p" ], "start_line": 115, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "is_writable", "long_name": "is_writable( dir )", "filename": "catalog.py", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [ "dir" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "whoami", "long_name": "whoami( )", "filename": "catalog.py", "nloc": 2, "complexity": 3, "token_count": 25, "parameters": [], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 17, "complexity": 5, "token_count": 141, "parameters": [], "start_line": 142, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "intermediate_dir", "long_name": "intermediate_dir( )", "filename": "catalog.py", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 56, "parameters": [], "start_line": 191, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 202, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 216, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 13, "complexity": 6, "token_count": 80, "parameters": [ "module_path", "mode" ], "start_line": 243, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 299, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 316, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 323, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 332, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 348, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 372, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 7, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 383, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 410, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 398, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 421, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 428, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 445, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 450, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 464, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 472, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 504, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 536, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 65, "parameters": [ "self", "code", "module_dir" ], "start_line": 543, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 577, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 31, "complexity": 7, "token_count": 194, "parameters": [ "self", "code", "function" ], "start_line": 610, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 657, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 681, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 685, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 79, "parameters": [ "object" ], "start_line": 53, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 80, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 91, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "create_dir", "long_name": "create_dir( p )", "filename": "catalog.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "p" ], "start_line": 115, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "is_writable", "long_name": "is_writable( dir )", "filename": "catalog.py", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [ "dir" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "whoami", "long_name": "whoami( )", "filename": "catalog.py", "nloc": 2, "complexity": 3, "token_count": 25, "parameters": [], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 17, "complexity": 5, "token_count": 141, "parameters": [], "start_line": 142, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "intermediate_dir", "long_name": "intermediate_dir( )", "filename": "catalog.py", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 56, "parameters": [], "start_line": 191, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 202, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 216, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 13, "complexity": 6, "token_count": 80, "parameters": [ "module_path", "mode" ], "start_line": 243, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 299, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 316, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 323, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 332, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 348, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 372, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 7, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 383, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 410, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 398, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 421, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 428, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 445, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 450, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 464, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 472, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 504, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 536, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 65, "parameters": [ "self", "code", "module_dir" ], "start_line": 543, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 577, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 31, "complexity": 7, "token_count": 194, "parameters": [ "self", "code", "function" ], "start_line": 610, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 657, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 681, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 685, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 81, "parameters": [ "object" ], "start_line": 53, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 } ], "nloc": 368, "complexity": 108, "token_count": 2036, "diff_parsed": { "added": [ " except (TypeError, KeyError, ImportError):" ], "deleted": [ " except (TypeError, KeyError):" ] } } ] }, { "hash": "680ac1244a1fb01b364c3cb0598a0b8edd410025", "msg": "Added _f2py suffix to Fortran library names to avoid name conflicts.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-04-23T20:58:49+00:00", "author_timezone": 0, "committer_date": "2003-04-23T20:58:49+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "338676abb35f3ba31532116a7bdf7f10c6f0801f" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 7, "insertions": 10, "lines": 17, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -34,10 +34,11 @@ def build_extension(self, ext):\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n+ flib_name = ext_name + '_f2py'\n \n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n- if build_flib.has_f_library(ext_name):\n+ if build_flib.has_f_library(flib_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n@@ -51,13 +52,15 @@ def build_extension(self, ext):\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n- if build_flib.has_f_library(ext_name) and \\\n- ext_name not in ext.libraries:\n- ext.libraries.insert(0,ext_name)\n+ if build_flib.has_f_library(flib_name) and \\\n+ flib_name not in ext.libraries:\n+ ext.libraries.insert(0,flib_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n- ext.library_dirs.append(build_flib.build_flib)\n+ d = build_flib.build_flib\n+ if d not in ext.library_dirs:\n+ ext.library_dirs.append(d)\n \n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n", "added_lines": 8, "deleted_lines": 5, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n flib_name = ext_name + '_f2py'\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(flib_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(flib_name) and \\\n flib_name not in ext.libraries:\n ext.libraries.insert(0,flib_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n d = build_flib.build_flib\n if d not in ext.library_dirs:\n ext.library_dirs.append(d)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so and save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(ext_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(ext_name) and \\\n ext_name not in ext.libraries:\n ext.libraries.insert(0,ext_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n ext.library_dirs.append(build_flib.build_flib)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so and save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 76, "complexity": 28, "token_count": 559, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 104, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 126, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 73, "complexity": 27, "token_count": 543, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 101, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 123, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 76, "complexity": 28, "token_count": 559, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 104, "top_nesting_level": 1 } ], "nloc": 96, "complexity": 31, "token_count": 683, "diff_parsed": { "added": [ " flib_name = ext_name + '_f2py'", " if build_flib.has_f_library(flib_name):", " if build_flib.has_f_library(flib_name) and \\", " flib_name not in ext.libraries:", " ext.libraries.insert(0,flib_name)", " d = build_flib.build_flib", " if d not in ext.library_dirs:", " ext.library_dirs.append(d)" ], "deleted": [ " if build_flib.has_f_library(ext_name):", " if build_flib.has_f_library(ext_name) and \\", " ext_name not in ext.libraries:", " ext.libraries.insert(0,ext_name)", " ext.library_dirs.append(build_flib.build_flib)" ] } }, { "old_path": "scipy_distutils/command/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -230,7 +230,7 @@ def fortran_sources_to_flib(self, ext):\n fortran_libraries = self.distribution.fortran_libraries\n \n ext_name = string.split(ext.name,'.')[-1]\n- name = ext_name\n+ name = ext_name+'_f2py'\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n@@ -239,7 +239,7 @@ def fortran_sources_to_flib(self, ext):\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n- \n+\n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n self.warn(red_text('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext_name`)))\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn(red_text('Only one .pyf file can be used per Extension'\\\n ' but got %s.' % (len(f2py_sources))))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name+'_f2py'\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n\n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n self.warn(red_text('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext_name`)))\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn(red_text('Only one .pyf file can be used per Extension'\\\n ' but got %s.' % (len(f2py_sources))))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n \n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 38, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 47, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 101, "complexity": 28, "token_count": 722, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 198, "parameters": [ "self", "ext" ], "start_line": 210, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 38, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 47, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 101, "complexity": 28, "token_count": 722, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 196, "parameters": [ "self", "ext" ], "start_line": 210, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 198, "parameters": [ "self", "ext" ], "start_line": 210, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "nloc": 175, "complexity": 43, "token_count": 1200, "diff_parsed": { "added": [ " name = ext_name+'_f2py'", "" ], "deleted": [ " name = ext_name", "" ] } } ] }, { "hash": "70637f538f9389260b91e527c521b122a1d18f1e", "msg": "fixed a naming error for add_extra_compile_arg method.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-05-12T19:55:13+00:00", "author_timezone": 0, "committer_date": "2003-05-12T19:55:13+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "680ac1244a1fb01b364c3cb0598a0b8edd410025" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/base_info.py", "new_path": "weave/base_info.py", "filename": "base_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -94,9 +94,9 @@ def add_define_macro(self,define_macro):\n self._define_macros.append(define_macro)\n def add_undefine_macro(self,undefine_macro):\n self._undefine_macros.append(undefine_macro) \n- def add_extra_compile_args(self,compile_arg):\n+ def add_extra_compile_arg(self,compile_arg):\n return self._extra_compile_args.append(compile_arg)\n- def add_extra_link_args(self,link_arg):\n+ def add_extra_link_arg(self,link_arg):\n return self._extra_link_args.append(link_arg) \n \n class info_list(UserList.UserList):\n", "added_lines": 2, "deleted_lines": 2, "source_code": "\"\"\"\n base_info holds classes that define the information\n needed for building C++ extension modules for Python that\n handle different data types. The information includes\n such as include files, libraries, and even code snippets.\n \n base_info -- base class for cxx_info, blitz_info, etc. \n info_list -- a handy list class for working with multiple\n info classes at the same time. \n\"\"\"\nimport os\nimport UserList\n\nclass base_info:\n _warnings =[]\n _headers = []\n _include_dirs = []\n _libraries = []\n _library_dirs = []\n _support_code = []\n _module_init_code = []\n _sources = []\n _define_macros = []\n _undefine_macros = []\n _extra_compile_args = []\n _extra_link_args = []\n compiler = ''\n def set_compiler(self,compiler):\n self.check_compiler(compiler)\n self.compiler = compiler\n # it would probably be better to specify what the arguments are\n # to avoid confusion, but I don't think these classes will get\n # very complicated, and I don't really know the variety of things\n # that should be passed in at this point.\n def check_compiler(self,compiler):\n pass \n def warnings(self): \n return self._warnings\n def headers(self): \n return self._headers\n def include_dirs(self):\n return self._include_dirs\n def libraries(self):\n return self._libraries\n def library_dirs(self):\n return self._library_dirs\n def support_code(self):\n return self._support_code\n def module_init_code(self):\n return self._module_init_code\n def sources(self):\n return self._sources\n def define_macros(self):\n return self._define_macros\n def undefine_macros(self):\n return self._undefine_macros\n def extra_compile_args(self):\n return self._extra_compile_args\n def extra_link_args(self):\n return self._extra_link_args \n \nclass custom_info(base_info):\n def __init__(self):\n self._warnings =[]\n self._headers = []\n self._include_dirs = []\n self._libraries = []\n self._library_dirs = []\n self._support_code = []\n self._module_init_code = []\n self._sources = []\n self._define_macros = []\n self._undefine_macros = []\n self._extra_compile_args = []\n self._extra_link_args = []\n\n def add_warning(self,warning):\n self._warnings.append(warning)\n def add_header(self,header):\n self._headers.append(header)\n def add_include_dir(self,include_dir):\n self._include_dirs.append(include_dir)\n def add_library(self,library):\n self._libraries.append(library)\n def add_library_dir(self,library_dir):\n self._library_dirs.append(library_dir)\n def add_support_code(self,support_code):\n self._support_code.append(support_code)\n def add_module_init_code(self,module_init_code):\n self._module_init_code.append(module_init_code)\n def add_source(self,source):\n self._sources.append(source)\n def add_define_macro(self,define_macro):\n self._define_macros.append(define_macro)\n def add_undefine_macro(self,undefine_macro):\n self._undefine_macros.append(undefine_macro) \n def add_extra_compile_arg(self,compile_arg):\n return self._extra_compile_args.append(compile_arg)\n def add_extra_link_arg(self,link_arg):\n return self._extra_link_args.append(link_arg) \n\nclass info_list(UserList.UserList):\n def get_unique_values(self,attribute):\n all_values = [] \n for info in self:\n vals = eval('info.'+attribute+'()')\n all_values.extend(vals)\n return unique_values(all_values)\n\n def extra_compile_args(self):\n return self.get_unique_values('extra_compile_args')\n def extra_link_args(self):\n return self.get_unique_values('extra_link_args')\n def sources(self):\n return self.get_unique_values('sources') \n def define_macros(self):\n return self.get_unique_values('define_macros')\n def sources(self):\n return self.get_unique_values('sources')\n def warnings(self):\n return self.get_unique_values('warnings')\n def headers(self):\n return self.get_unique_values('headers')\n def include_dirs(self):\n return self.get_unique_values('include_dirs')\n def libraries(self):\n return self.get_unique_values('libraries')\n def library_dirs(self):\n return self.get_unique_values('library_dirs')\n def support_code(self):\n return self.get_unique_values('support_code')\n def module_init_code(self):\n return self.get_unique_values('module_init_code')\n\ndef unique_values(lst):\n all_values = [] \n for value in lst:\n if value not in all_values:\n all_values.append(value)\n return all_values\n\n", "source_code_before": "\"\"\"\n base_info holds classes that define the information\n needed for building C++ extension modules for Python that\n handle different data types. The information includes\n such as include files, libraries, and even code snippets.\n \n base_info -- base class for cxx_info, blitz_info, etc. \n info_list -- a handy list class for working with multiple\n info classes at the same time. \n\"\"\"\nimport os\nimport UserList\n\nclass base_info:\n _warnings =[]\n _headers = []\n _include_dirs = []\n _libraries = []\n _library_dirs = []\n _support_code = []\n _module_init_code = []\n _sources = []\n _define_macros = []\n _undefine_macros = []\n _extra_compile_args = []\n _extra_link_args = []\n compiler = ''\n def set_compiler(self,compiler):\n self.check_compiler(compiler)\n self.compiler = compiler\n # it would probably be better to specify what the arguments are\n # to avoid confusion, but I don't think these classes will get\n # very complicated, and I don't really know the variety of things\n # that should be passed in at this point.\n def check_compiler(self,compiler):\n pass \n def warnings(self): \n return self._warnings\n def headers(self): \n return self._headers\n def include_dirs(self):\n return self._include_dirs\n def libraries(self):\n return self._libraries\n def library_dirs(self):\n return self._library_dirs\n def support_code(self):\n return self._support_code\n def module_init_code(self):\n return self._module_init_code\n def sources(self):\n return self._sources\n def define_macros(self):\n return self._define_macros\n def undefine_macros(self):\n return self._undefine_macros\n def extra_compile_args(self):\n return self._extra_compile_args\n def extra_link_args(self):\n return self._extra_link_args \n \nclass custom_info(base_info):\n def __init__(self):\n self._warnings =[]\n self._headers = []\n self._include_dirs = []\n self._libraries = []\n self._library_dirs = []\n self._support_code = []\n self._module_init_code = []\n self._sources = []\n self._define_macros = []\n self._undefine_macros = []\n self._extra_compile_args = []\n self._extra_link_args = []\n\n def add_warning(self,warning):\n self._warnings.append(warning)\n def add_header(self,header):\n self._headers.append(header)\n def add_include_dir(self,include_dir):\n self._include_dirs.append(include_dir)\n def add_library(self,library):\n self._libraries.append(library)\n def add_library_dir(self,library_dir):\n self._library_dirs.append(library_dir)\n def add_support_code(self,support_code):\n self._support_code.append(support_code)\n def add_module_init_code(self,module_init_code):\n self._module_init_code.append(module_init_code)\n def add_source(self,source):\n self._sources.append(source)\n def add_define_macro(self,define_macro):\n self._define_macros.append(define_macro)\n def add_undefine_macro(self,undefine_macro):\n self._undefine_macros.append(undefine_macro) \n def add_extra_compile_args(self,compile_arg):\n return self._extra_compile_args.append(compile_arg)\n def add_extra_link_args(self,link_arg):\n return self._extra_link_args.append(link_arg) \n\nclass info_list(UserList.UserList):\n def get_unique_values(self,attribute):\n all_values = [] \n for info in self:\n vals = eval('info.'+attribute+'()')\n all_values.extend(vals)\n return unique_values(all_values)\n\n def extra_compile_args(self):\n return self.get_unique_values('extra_compile_args')\n def extra_link_args(self):\n return self.get_unique_values('extra_link_args')\n def sources(self):\n return self.get_unique_values('sources') \n def define_macros(self):\n return self.get_unique_values('define_macros')\n def sources(self):\n return self.get_unique_values('sources')\n def warnings(self):\n return self.get_unique_values('warnings')\n def headers(self):\n return self.get_unique_values('headers')\n def include_dirs(self):\n return self.get_unique_values('include_dirs')\n def libraries(self):\n return self.get_unique_values('libraries')\n def library_dirs(self):\n return self.get_unique_values('library_dirs')\n def support_code(self):\n return self.get_unique_values('support_code')\n def module_init_code(self):\n return self.get_unique_values('module_init_code')\n\ndef unique_values(lst):\n all_values = [] \n for value in lst:\n if value not in all_values:\n all_values.append(value)\n return all_values\n\n", "methods": [ { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "base_info.py", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "self", "compiler" ], "start_line": 28, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_compiler", "long_name": "check_compiler( self , compiler )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "compiler" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "warnings", "long_name": "warnings( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 37, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "headers", "long_name": "headers( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 39, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "include_dirs", "long_name": "include_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 41, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "libraries", "long_name": "libraries( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 43, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dirs", "long_name": "library_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 49, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "sources", "long_name": "sources( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 51, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "define_macros", "long_name": "define_macros( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 53, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "undefine_macros", "long_name": "undefine_macros( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 55, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "extra_compile_args", "long_name": "extra_compile_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "extra_link_args", "long_name": "extra_link_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 59, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "base_info.py", "nloc": 13, "complexity": 1, "token_count": 77, "parameters": [ "self" ], "start_line": 63, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "add_warning", "long_name": "add_warning( self , warning )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "warning" ], "start_line": 77, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_header", "long_name": "add_header( self , header )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "header" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_include_dir", "long_name": "add_include_dir( self , include_dir )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "include_dir" ], "start_line": 81, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , library )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "library" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_library_dir", "long_name": "add_library_dir( self , library_dir )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "library_dir" ], "start_line": 85, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_support_code", "long_name": "add_support_code( self , support_code )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "support_code" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_module_init_code", "long_name": "add_module_init_code( self , module_init_code )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "module_init_code" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_source", "long_name": "add_source( self , source )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "source" ], "start_line": 91, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_define_macro", "long_name": "add_define_macro( self , define_macro )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "define_macro" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_undefine_macro", "long_name": "add_undefine_macro( self , undefine_macro )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "undefine_macro" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_extra_compile_arg", "long_name": "add_extra_compile_arg( self , compile_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "compile_arg" ], "start_line": 97, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_extra_link_arg", "long_name": "add_extra_link_arg( self , link_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "link_arg" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_unique_values", "long_name": "get_unique_values( self , attribute )", "filename": "base_info.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self", "attribute" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "extra_compile_args", "long_name": "extra_compile_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "extra_link_args", "long_name": "extra_link_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 112, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "sources", "long_name": "sources( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 114, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "define_macros", "long_name": "define_macros( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "sources", "long_name": "sources( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 118, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "warnings", "long_name": "warnings( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "headers", "long_name": "headers( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 122, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "include_dirs", "long_name": "include_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 124, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "libraries", "long_name": "libraries( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dirs", "long_name": "library_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 128, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 130, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 132, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "unique_values", "long_name": "unique_values( lst )", "filename": "base_info.py", "nloc": 6, "complexity": 3, "token_count": 28, "parameters": [ "lst" ], "start_line": 135, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "base_info.py", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "self", "compiler" ], "start_line": 28, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_compiler", "long_name": "check_compiler( self , compiler )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "compiler" ], "start_line": 35, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "warnings", "long_name": "warnings( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 37, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "headers", "long_name": "headers( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 39, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "include_dirs", "long_name": "include_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 41, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "libraries", "long_name": "libraries( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 43, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dirs", "long_name": "library_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 45, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 49, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "sources", "long_name": "sources( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 51, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "define_macros", "long_name": "define_macros( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 53, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "undefine_macros", "long_name": "undefine_macros( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 55, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "extra_compile_args", "long_name": "extra_compile_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 57, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "extra_link_args", "long_name": "extra_link_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 59, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "base_info.py", "nloc": 13, "complexity": 1, "token_count": 77, "parameters": [ "self" ], "start_line": 63, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "add_warning", "long_name": "add_warning( self , warning )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "warning" ], "start_line": 77, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_header", "long_name": "add_header( self , header )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "header" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_include_dir", "long_name": "add_include_dir( self , include_dir )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "include_dir" ], "start_line": 81, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_library", "long_name": "add_library( self , library )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "library" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_library_dir", "long_name": "add_library_dir( self , library_dir )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "library_dir" ], "start_line": 85, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_support_code", "long_name": "add_support_code( self , support_code )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "support_code" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_module_init_code", "long_name": "add_module_init_code( self , module_init_code )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "module_init_code" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_source", "long_name": "add_source( self , source )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "source" ], "start_line": 91, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_define_macro", "long_name": "add_define_macro( self , define_macro )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "define_macro" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_undefine_macro", "long_name": "add_undefine_macro( self , undefine_macro )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "undefine_macro" ], "start_line": 95, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_extra_compile_args", "long_name": "add_extra_compile_args( self , compile_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "compile_arg" ], "start_line": 97, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_extra_link_args", "long_name": "add_extra_link_args( self , link_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "link_arg" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_unique_values", "long_name": "get_unique_values( self , attribute )", "filename": "base_info.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self", "attribute" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "extra_compile_args", "long_name": "extra_compile_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 110, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "extra_link_args", "long_name": "extra_link_args( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 112, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "sources", "long_name": "sources( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 114, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "define_macros", "long_name": "define_macros( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 116, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "sources", "long_name": "sources( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 118, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "warnings", "long_name": "warnings( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 120, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "headers", "long_name": "headers( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 122, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "include_dirs", "long_name": "include_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 124, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "libraries", "long_name": "libraries( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "library_dirs", "long_name": "library_dirs( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 128, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 130, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 132, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "unique_values", "long_name": "unique_values( lst )", "filename": "base_info.py", "nloc": 6, "complexity": 3, "token_count": 28, "parameters": [ "lst" ], "start_line": 135, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "add_extra_link_args", "long_name": "add_extra_link_args( self , link_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "link_arg" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_extra_link_arg", "long_name": "add_extra_link_arg( self , link_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "link_arg" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_extra_compile_arg", "long_name": "add_extra_compile_arg( self , compile_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "compile_arg" ], "start_line": 97, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "add_extra_compile_args", "long_name": "add_extra_compile_args( self , compile_arg )", "filename": "base_info.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "compile_arg" ], "start_line": 97, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "nloc": 130, "complexity": 44, "token_count": 716, "diff_parsed": { "added": [ " def add_extra_compile_arg(self,compile_arg):", " def add_extra_link_arg(self,link_arg):" ], "deleted": [ " def add_extra_compile_args(self,compile_arg):", " def add_extra_link_args(self,link_arg):" ] } } ] }, { "hash": "451ff2b2197f5fe16eb7cf3e7d12a5b95da2e738", "msg": "Updated compaq compiler for OSF1/Tru64 and Linux", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-05-18T12:07:03+00:00", "author_timezone": 0, "committer_date": "2003-05-18T12:07:03+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "70637f538f9389260b91e527c521b122a1d18f1e" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 12, "insertions": 15, "lines": 27, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.42857142857142855, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1358,17 +1358,20 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n \n-\n+#http://www.compaq.com/fortran/docs/\n class compaq_fortran_compiler(fortran_compiler_base):\n \n vendor = 'Compaq'\n- ver_match = r'Compaq Fortran (?P[^\\s]*)'\n+ ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n \n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n \n if fc is None:\n- fc = 'fort'\n+ if sys.platform[:5]=='linux':\n+ fc = 'fort'\n+ else:\n+ fc = 'f90'\n if f90c is None:\n f90c = fc\n \n@@ -1376,19 +1379,16 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n self.f90_compiler = f90c\n \n switches = ' -assume no2underscore -nomixed_str_len_arg '\n- debug = ' -g -check_bounds '\n+ debug = ' -g -check bounds '\n \n- self.f77_switches = self.f90_switches = switches\n+ self.f77_switches = ' -f77rtl -fixed ' + switches\n+ self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n- self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n-\n- # XXX: uncomment if required\n- #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n+ self.f90_fixed_switch = ' -fixed '\n \n- # XXX: fix the version showing flag\n- self.ver_cmd = self.f77_compiler+' -V '\n+ self.ver_cmd = self.f77_compiler+' -version'\n \n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n@@ -1396,7 +1396,10 @@ def get_opt(self):\n return opt\n \n def get_linker_so(self):\n- return [self.f77_compiler,'-shared']\n+ if sys.platform[:5]=='linux':\n+ return [self.f77_compiler,'-shared']\n+ else:\n+ return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n \n #http://www.compaq.com/fortran\n class compaq_visual_fortran_compiler(fortran_compiler_base):\n", "added_lines": 15, "deleted_lines": 12, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 72, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 100, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 137, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 158, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 199, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 208, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 230, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 237, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 246, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 267, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 280, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 293, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 352, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 390, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 417, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 455, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 489, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 494, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 501, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 510, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 517, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 538, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 583, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 596, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 625, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 631, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 638, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 664, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 677, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 742, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 759, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 793, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 836, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 843, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 866, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 879, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 901, "end_line": 921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 923, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 927, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 930, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 947, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 970, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 996, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1044, "end_line": 1106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1108, "end_line": 1125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1127, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1135, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1159, "end_line": 1188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1190, "end_line": 1204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1206, "end_line": 1207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1209, "end_line": 1215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1224, "end_line": 1227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1235, "end_line": 1256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1258, "end_line": 1260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1262, "end_line": 1263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1277, "end_line": 1305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1311, "end_line": 1312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1325, "end_line": 1356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1358, "end_line": 1359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1367, "end_line": 1391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1393, "end_line": 1396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "self" ], "start_line": 1398, "end_line": 1402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1418, "end_line": 1445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1447, "end_line": 1449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1459, "end_line": 1484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1486, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1490, "end_line": 1491, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1495, "end_line": 1503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 72, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 100, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 137, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 158, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 199, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 208, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 230, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 237, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 246, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 267, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 280, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 293, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 352, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 390, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 417, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 455, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 489, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 494, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 501, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 510, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 517, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 538, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 583, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 596, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 625, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 631, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 638, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 664, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 677, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 742, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 759, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 793, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 836, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 843, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 866, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 879, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 901, "end_line": 921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 923, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 927, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 930, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 947, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 970, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 996, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1044, "end_line": 1106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1108, "end_line": 1125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1127, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1135, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1159, "end_line": 1188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1190, "end_line": 1204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1206, "end_line": 1207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1209, "end_line": 1215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1224, "end_line": 1227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1235, "end_line": 1256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1258, "end_line": 1260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1262, "end_line": 1263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1277, "end_line": 1305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1311, "end_line": 1312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1325, "end_line": 1356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1358, "end_line": 1359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 15, "complexity": 3, "token_count": 104, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1367, "end_line": 1391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1393, "end_line": 1396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1398, "end_line": 1399, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1415, "end_line": 1442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1444, "end_line": 1446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1456, "end_line": 1481, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1483, "end_line": 1485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1487, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1492, "end_line": 1500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1367, "end_line": 1391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "self" ], "start_line": 1398, "end_line": 1402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 1119, "complexity": 292, "token_count": 6596, "diff_parsed": { "added": [ "#http://www.compaq.com/fortran/docs/", " ver_match = r'Compaq Fortran (?P[^\\s]*).*'", " if sys.platform[:5]=='linux':", " fc = 'fort'", " else:", " fc = 'f90'", " debug = ' -g -check bounds '", " self.f77_switches = ' -f77rtl -fixed ' + switches", " self.f90_switches = switches", " self.f90_fixed_switch = ' -fixed '", " self.ver_cmd = self.f77_compiler+' -version'", " if sys.platform[:5]=='linux':", " return [self.f77_compiler,'-shared']", " else:", " return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']" ], "deleted": [ "", " ver_match = r'Compaq Fortran (?P[^\\s]*)'", " fc = 'fort'", " debug = ' -g -check_bounds '", " self.f77_switches = self.f90_switches = switches", " self.f90_fixed_switch = ' ' # XXX: need fixed format flag", "", " # XXX: uncomment if required", " #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '", " # XXX: fix the version showing flag", " self.ver_cmd = self.f77_compiler+' -V '", " return [self.f77_compiler,'-shared']" ] } } ] }, { "hash": "ed92aab39ebec5e9b3f73b25456108c41da456a0", "msg": "updated mingw support to handle gcc 3.x for building C++ files.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-05-21T02:05:52+00:00", "author_timezone": 0, "committer_date": "2003-05-21T02:05:52+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "451ff2b2197f5fe16eb7cf3e7d12a5b95da2e738" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 8, "insertions": 133, "lines": 141, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.52, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/mingw32_support.py", "new_path": "scipy_distutils/mingw32_support.py", "filename": "mingw32_support.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -22,22 +22,149 @@\n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n+ import distutils.cygwinccompiler\n+ from distutils.version import StrictVersion\n+ from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n+ from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n+ \n+ from distutils.unixccompiler import UnixCCompiler \n+ \n+ # the same as cygwin plus some additional parameters\n+ class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n+ \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n+ \n+ \"\"\"\n+ \n+ compiler_type = 'mingw32'\n+ \n+ def __init__ (self,\n+ verbose=0,\n+ dry_run=0,\n+ force=0):\n+ \n+ distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n+ verbose,dry_run, force)\n+ \n+ # we need to support 3.2 which doesn't match the standard\n+ # get_versions methods regex\n+ if self.gcc_version is None:\n+ import re\n+ out = os.popen('gcc' + ' -dumpversion','r')\n+ out_string = out.read()\n+ out.close()\n+ result = re.search('(\\d+\\.\\d+)',out_string)\n+ if result:\n+ self.gcc_version = StrictVersion(result.group(1)) \n+\n+ # A real mingw32 doesn't need to specify a different entry point,\n+ # but cygwin 2.91.57 in no-cygwin-mode needs it.\n+ if self.gcc_version <= \"2.91.57\":\n+ entry_point = '--entry _DllMain@12'\n+ else:\n+ entry_point = ''\n+ if self.linker_dll == 'dllwrap':\n+ self.linker = 'dllwrap' + ' --driver-name g++'\n+ elif self.linker_dll == 'gcc':\n+ self.linker = 'g++' \n+\n+ # **changes: eric jones 4/11/01\n+ # 1. Check for import library on Windows. Build if it doesn't exist.\n+ if not import_library_exists():\n+ build_import_library()\n+ \n+ # **changes: eric jones 4/11/01\n+ # 2. increased optimization and turned off all warnings\n+ # 3. also added --driver-name g++\n+ #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n+ # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n+ # linker_exe='gcc -mno-cygwin',\n+ # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n+ # % (self.linker, entry_point))\n+ if self.gcc_version <= \"3.0.0\":\n+ self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n+ compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n+ linker_exe='g++ -mno-cygwin',\n+ linker_so='%s -mno-cygwin -mdll -static %s' \n+ % (self.linker, entry_point))\n+ else: \n+ self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n+ compiler_so='gcc -O2 -w -Wstrict-prototypes',\n+ linker_exe='g++ ',\n+ linker_so='g++ -shared')\n+ # Maybe we should also append -mthreads, but then the finished\n+ # dlls need another dll (mingwm10.dll see Mingw32 docs)\n+ # (-mthreads: Support thread-safe exception handling on `Mingw32') \n+ \n+ # no additional libraries needed \n+ self.dll_libraries=[]\n+ \n+ # __init__ ()\n+\n+ def link(self,\n+ target_desc,\n+ objects,\n+ output_filename,\n+ output_dir,\n+ libraries,\n+ library_dirs,\n+ runtime_library_dirs,\n+ None, # export_symbols, we do this in our def-file\n+ debug,\n+ extra_preargs,\n+ extra_postargs,\n+ build_temp):\n+ if self.gcc_version < \"3.0.0\":\n+ distutils.cygwinccompiler.CygwinCCompiler.link(self,\n+ target_desc,\n+ objects,\n+ output_filename,\n+ output_dir,\n+ libraries,\n+ library_dirs,\n+ runtime_library_dirs,\n+ None, # export_symbols, we do this in our def-file\n+ debug,\n+ extra_preargs,\n+ extra_postargs,\n+ build_temp)\n+ else:\n+ UnixCCompiler.link(self,\n+ target_desc,\n+ objects,\n+ output_filename,\n+ output_dir,\n+ libraries,\n+ library_dirs,\n+ runtime_library_dirs,\n+ None, # export_symbols, we do this in our def-file\n+ debug,\n+ extra_preargs,\n+ extra_postargs,\n+ build_temp)\n+\n+ \n+ # On windows platforms, we want to default to mingw32 (gcc)\n+ # because msvc can't build blitz stuff.\n+ # We should also check the version of gcc available...\n+ #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n+ #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n+ # reset the Mingw32 compiler in distutils to the one defined above\n+ distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n+ \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n- if sys.platform == 'win32':\n+ if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n- #print full_path\n if not os.path.exists(full_path):\n return 0\n return 1\n- \n+ \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n- import lib2def\n-\n+ from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n@@ -57,12 +184,10 @@ def build_import_library():\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n- print cmd\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n- print \"WARNING: failed to build import library for gcc. \"\\\n- \"Linking will fail.\"\n+ print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n", "added_lines": 133, "deleted_lines": 8, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if sys.platform == 'win32':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n #print full_path\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n import lib2def\n\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n print cmd\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print \"WARNING: failed to build import library for gcc. \"\\\n \"Linking will fail.\"\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "mingw32_support.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 103, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 154, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 164, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 200, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 218, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 222, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 225, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "methods_before": [ { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 25, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 20, "complexity": 2, "token_count": 192, "parameters": [], "start_line": 36, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 75, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 90, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 97, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 100, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 154, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "mingw32_support.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 103, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 164, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "nloc": 147, "complexity": 20, "token_count": 743, "diff_parsed": { "added": [ " import distutils.cygwinccompiler", " from distutils.version import StrictVersion", " from distutils.ccompiler import gen_preprocess_options, gen_lib_options", " from distutils.errors import DistutilsExecError, CompileError, UnknownFileError", "", " from distutils.unixccompiler import UnixCCompiler", "", " # the same as cygwin plus some additional parameters", " class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):", " \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.", "", " \"\"\"", "", " compiler_type = 'mingw32'", "", " def __init__ (self,", " verbose=0,", " dry_run=0,", " force=0):", "", " distutils.cygwinccompiler.CygwinCCompiler.__init__ (self,", " verbose,dry_run, force)", "", " # we need to support 3.2 which doesn't match the standard", " # get_versions methods regex", " if self.gcc_version is None:", " import re", " out = os.popen('gcc' + ' -dumpversion','r')", " out_string = out.read()", " out.close()", " result = re.search('(\\d+\\.\\d+)',out_string)", " if result:", " self.gcc_version = StrictVersion(result.group(1))", "", " # A real mingw32 doesn't need to specify a different entry point,", " # but cygwin 2.91.57 in no-cygwin-mode needs it.", " if self.gcc_version <= \"2.91.57\":", " entry_point = '--entry _DllMain@12'", " else:", " entry_point = ''", " if self.linker_dll == 'dllwrap':", " self.linker = 'dllwrap' + ' --driver-name g++'", " elif self.linker_dll == 'gcc':", " self.linker = 'g++'", "", " # **changes: eric jones 4/11/01", " # 1. Check for import library on Windows. Build if it doesn't exist.", " if not import_library_exists():", " build_import_library()", "", " # **changes: eric jones 4/11/01", " # 2. increased optimization and turned off all warnings", " # 3. also added --driver-name g++", " #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " # compiler_so='gcc -mno-cygwin -mdll -O2 -w',", " # linker_exe='gcc -mno-cygwin',", " # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s'", " # % (self.linker, entry_point))", " if self.gcc_version <= \"3.0.0\":", " self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',", " linker_exe='g++ -mno-cygwin',", " linker_so='%s -mno-cygwin -mdll -static %s'", " % (self.linker, entry_point))", " else:", " self.set_executables(compiler='gcc -mno-cygwin -O2 -w',", " compiler_so='gcc -O2 -w -Wstrict-prototypes',", " linker_exe='g++ ',", " linker_so='g++ -shared')", " # Maybe we should also append -mthreads, but then the finished", " # dlls need another dll (mingwm10.dll see Mingw32 docs)", " # (-mthreads: Support thread-safe exception handling on `Mingw32')", "", " # no additional libraries needed", " self.dll_libraries=[]", "", " # __init__ ()", "", " def link(self,", " target_desc,", " objects,", " output_filename,", " output_dir,", " libraries,", " library_dirs,", " runtime_library_dirs,", " None, # export_symbols, we do this in our def-file", " debug,", " extra_preargs,", " extra_postargs,", " build_temp):", " if self.gcc_version < \"3.0.0\":", " distutils.cygwinccompiler.CygwinCCompiler.link(self,", " target_desc,", " objects,", " output_filename,", " output_dir,", " libraries,", " library_dirs,", " runtime_library_dirs,", " None, # export_symbols, we do this in our def-file", " debug,", " extra_preargs,", " extra_postargs,", " build_temp)", " else:", " UnixCCompiler.link(self,", " target_desc,", " objects,", " output_filename,", " output_dir,", " libraries,", " library_dirs,", " runtime_library_dirs,", " None, # export_symbols, we do this in our def-file", " debug,", " extra_preargs,", " extra_postargs,", " build_temp)", "", "", " # On windows platforms, we want to default to mingw32 (gcc)", " # because msvc can't build blitz stuff.", " # We should also check the version of gcc available...", " #distutils.ccompiler._default_compilers['nt'] = 'mingw32'", " #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))", " # reset the Mingw32 compiler in distutils to the one defined above", " distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler", "", " if os.name == 'nt':", "", " from scipy_distutils import lib2def", " print 'WARNING: failed to build import library for gcc. Linking will fail.'" ], "deleted": [ " if sys.platform == 'win32':", " #print full_path", "", " import lib2def", "", " print cmd", " print \"WARNING: failed to build import library for gcc. \"\\", " \"Linking will fail.\"" ] } } ] }, { "hash": "4c398c0e3bb6d1212cb53013ed85163a6c2fdfb6", "msg": "Being more verbose in assert failure", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-05-24T21:03:35+00:00", "author_timezone": 0, "committer_date": "2003-05-24T21:03:35+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ed92aab39ebec5e9b3f73b25456108c41da456a0" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/ppimport.py", "new_path": "scipy_base/ppimport.py", "filename": "ppimport.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -180,7 +180,7 @@ def _ppimport_importer(self):\n \t module = sys.modules[name]\n \texcept KeyError:\n \t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n- assert module is self,`module`\n+ assert module is self,`(module, self)`\n \n # uninstall loader\n del sys.modules[name]\n", "added_lines": 1, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\ttry:\n\t module = sys.modules[name]\n\texcept KeyError:\n\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n assert module is self,`(module, self)`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n\ttry:\n\t module = __import__(name,None,None,['*'])\n\texcept ImportError:\n\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n\t raise\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_value'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\ttry:\n\t module = sys.modules[name]\n\texcept KeyError:\n\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n assert module is self,`module`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n\ttry:\n\t module = __import__(name,None,None,['*'])\n\texcept ImportError:\n\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n\t raise\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_value'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "methods": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 11, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 69, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 78, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 88, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 93, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 101, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 158, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 177, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 214, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 235, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 238, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 253, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 11, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 69, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 78, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 88, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 93, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 101, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 158, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 112, "parameters": [ "self" ], "start_line": 177, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 214, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 235, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 238, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 253, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 177, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 } ], "nloc": 196, "complexity": 55, "token_count": 1182, "diff_parsed": { "added": [ " assert module is self,`(module, self)`" ], "deleted": [ " assert module is self,`module`" ] } } ] }, { "hash": "c47e9b2fd35ae5775a2423bc157b64a439d64963", "msg": "ppimport shows more useful messages when importing modules fail for whatever reason. Using exc_info instead of depreciated exc_value and to save traceback.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-05-25T11:12:02+00:00", "author_timezone": 0, "committer_date": "2003-05-25T11:12:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4c398c0e3bb6d1212cb53013ed85163a6c2fdfb6" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 10, "insertions": 21, "lines": 31, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/ppimport.py", "new_path": "scipy_base/ppimport.py", "filename": "ppimport.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -14,6 +14,10 @@\n import sys\n import string\n import types\n+import traceback\n+\n+class PPImportError(ImportError):\n+ pass\n \n def _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n@@ -176,21 +180,28 @@ def __init__(self,name,location):\n \n def _ppimport_importer(self):\n name = self.__name__\n-\ttry:\n-\t module = sys.modules[name]\n+ try:\n+ module = sys.modules[name]\n \texcept KeyError:\n-\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n- assert module is self,`(module, self)`\n+ raise ImportError,self.__dict__.get('_ppimport_exc_info')[1]\n+ if module is not self:\n+ exc_info = self.__dict__.get('_ppimport_exc_info')\n+ if exc_info is not None:\n+ raise PPImportError,\\\n+ ''.join(traceback.format_exception(*exc_info))\n+ else:\n+ assert module is self,`(module, self)`\n \n # uninstall loader\n del sys.modules[name]\n \n #print 'Executing postponed import for %s' %(name)\n-\ttry:\n-\t module = __import__(name,None,None,['*'])\n-\texcept ImportError:\n-\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n-\t raise\n+ try:\n+ module = __import__(name,None,None,['*'])\n+ except: # ImportError:\n+ self.__dict__['_ppimport_exc_info'] = sys.exc_info()\n+ raise\n+\n assert isinstance(module,types.ModuleType),`module`\n \n self.__dict__ = module.__dict__\n@@ -214,7 +225,7 @@ def __getattr__(self, name):\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n- elif self.__dict__.has_key('_ppimport_exc_value'):\n+ elif self.__dict__.has_key('_ppimport_exc_info'):\n status = 'import error'\n else:\n status = 'import postponed'\n", "added_lines": 21, "deleted_lines": 10, "source_code": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\nimport traceback\n\nclass PPImportError(ImportError):\n pass\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n try:\n module = sys.modules[name]\n\texcept KeyError:\n raise ImportError,self.__dict__.get('_ppimport_exc_info')[1]\n if module is not self:\n exc_info = self.__dict__.get('_ppimport_exc_info')\n if exc_info is not None:\n raise PPImportError,\\\n ''.join(traceback.format_exception(*exc_info))\n else:\n assert module is self,`(module, self)`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n try:\n module = __import__(name,None,None,['*'])\n except: # ImportError:\n self.__dict__['_ppimport_exc_info'] = sys.exc_info()\n raise\n\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_info'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n attr = getattr(self.__dict__['_ppimport_attr_module'],\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n # get additional attributes (doc strings, etc)\n # from pre_.py file.\n #filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\ttry:\n\t module = sys.modules[name]\n\texcept KeyError:\n\t raise ImportError,self.__dict__.get('_ppimport_exc_value')\n assert module is self,`(module, self)`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n\ttry:\n\t module = __import__(name,None,None,['*'])\n\texcept ImportError:\n\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)\n\t raise\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_value'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "methods": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 22, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 39, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 11, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 61, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 73, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 82, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 92, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 97, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 105, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 162, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 23, "complexity": 5, "token_count": 157, "parameters": [ "self" ], "start_line": 181, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 218, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 225, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 246, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 249, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 264, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 18, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 35, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 45, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 53, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 11, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 69, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 78, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 88, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 93, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 101, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 10, "complexity": 3, "token_count": 85, "parameters": [ "self", "name", "location" ], "start_line": 158, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 17, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 177, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 200, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 207, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 214, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 235, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 238, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 253, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 23, "complexity": 5, "token_count": 157, "parameters": [ "self" ], "start_line": 181, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 225, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": 205, "complexity": 57, "token_count": 1232, "diff_parsed": { "added": [ "import traceback", "", "class PPImportError(ImportError):", " pass", " try:", " module = sys.modules[name]", " raise ImportError,self.__dict__.get('_ppimport_exc_info')[1]", " if module is not self:", " exc_info = self.__dict__.get('_ppimport_exc_info')", " if exc_info is not None:", " raise PPImportError,\\", " ''.join(traceback.format_exception(*exc_info))", " else:", " assert module is self,`(module, self)`", " try:", " module = __import__(name,None,None,['*'])", " except: # ImportError:", " self.__dict__['_ppimport_exc_info'] = sys.exc_info()", " raise", "", " elif self.__dict__.has_key('_ppimport_exc_info'):" ], "deleted": [ "\ttry:", "\t module = sys.modules[name]", "\t raise ImportError,self.__dict__.get('_ppimport_exc_value')", " assert module is self,`(module, self)`", "\ttry:", "\t module = __import__(name,None,None,['*'])", "\texcept ImportError:", "\t self.__dict__['_ppimport_exc_value'] = str(sys.exc_value)", "\t raise", " elif self.__dict__.has_key('_ppimport_exc_value'):" ] } } ] }, { "hash": "11d26a6d3e3adae9e8873fd9d65806dd18428ebb", "msg": "Changed default of eye(N) to double", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-06-13T23:34:57+00:00", "author_timezone": 0, "committer_date": "2003-06-13T23:34:57+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c47e9b2fd35ae5775a2423bc157b64a439d64963" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/matrix_base.py", "new_path": "scipy_base/matrix_base.py", "filename": "matrix_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -39,7 +39,7 @@ def rot90(m, k=1):\n elif k == 2: return fliplr(flipud(m))\n else: return fliplr(transpose(m)) # k==3\n \n-def eye(N, M=None, k=0, typecode=None):\n+def eye(N, M=None, k=0, typecode='d'):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n and everything else is zeros.\n \"\"\"\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','rot90']\n\nfrom Numeric import *\n\ndef fliplr(m):\n \"\"\" returns a 2-D matrix m with the rows preserved and columns flipped \n in the left/right direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[:, ::-1]\n\ndef flipud(m):\n \"\"\" returns a 2-D matrix with the columns preserved and rows flipped in\n the up/down direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[::-1]\n \n# reshape(x, m, n) is not used, instead use reshape(x, (m, n))\n\ndef rot90(m, k=1):\n \"\"\" returns the matrix found by rotating m by k*90 degrees in the \n counterclockwise direction.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n k = k % 4\n if k == 0: return m\n elif k == 1: return transpose(fliplr(m))\n elif k == 2: return fliplr(flipud(m))\n else: return fliplr(transpose(m)) # k==3\n \ndef eye(N, M=None, k=0, typecode='d'):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n and everything else is zeros.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n\ndef diag(v, k=0):\n \"\"\" returns the k-th diagonal if v is a matrix or returns a matrix \n with v as the k-th diagonal if v is a vector.\n \"\"\"\n v = asarray(v)\n s = v.shape\n if len(s)==1:\n n = s[0]+abs(k)\n if k > 0:\n v = concatenate((zeros(k, v.typecode()),v))\n elif k < 0:\n v = concatenate((v,zeros(-k, v.typecode())))\n return eye(n, k=k)*v\n elif len(s)==2:\n v = add.reduce(eye(s[0], s[1], k=k)*v)\n if k > 0: return v[k:]\n elif k < 0: return v[:k]\n else: return v\n else:\n raise ValueError, \"Input must be 1- or 2-D.\"\n\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','rot90']\n\nfrom Numeric import *\n\ndef fliplr(m):\n \"\"\" returns a 2-D matrix m with the rows preserved and columns flipped \n in the left/right direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[:, ::-1]\n\ndef flipud(m):\n \"\"\" returns a 2-D matrix with the columns preserved and rows flipped in\n the up/down direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[::-1]\n \n# reshape(x, m, n) is not used, instead use reshape(x, (m, n))\n\ndef rot90(m, k=1):\n \"\"\" returns the matrix found by rotating m by k*90 degrees in the \n counterclockwise direction.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n k = k % 4\n if k == 0: return m\n elif k == 1: return transpose(fliplr(m))\n elif k == 2: return fliplr(flipud(m))\n else: return fliplr(transpose(m)) # k==3\n \ndef eye(N, M=None, k=0, typecode=None):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n and everything else is zeros.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n\ndef diag(v, k=0):\n \"\"\" returns the k-th diagonal if v is a matrix or returns a matrix \n with v as the k-th diagonal if v is a vector.\n \"\"\"\n v = asarray(v)\n s = v.shape\n if len(s)==1:\n n = s[0]+abs(k)\n if k > 0:\n v = concatenate((zeros(k, v.typecode()),v))\n elif k < 0:\n v = concatenate((v,zeros(-k, v.typecode())))\n return eye(n, k=k)*v\n elif len(s)==2:\n v = add.reduce(eye(s[0], s[1], k=k)*v)\n if k > 0: return v[k:]\n elif k < 0: return v[:k]\n else: return v\n else:\n raise ValueError, \"Input must be 1- or 2-D.\"\n\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "fliplr", "long_name": "fliplr( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "m" ], "start_line": 9, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "flipud", "long_name": "flipud( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "m" ], "start_line": 18, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "rot90", "long_name": "rot90( m , k = 1 )", "filename": "matrix_base.py", "nloc": 9, "complexity": 5, "token_count": 78, "parameters": [ "m", "k" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "eye", "long_name": "eye( N , M = None , k = 0 , typecode = 'd' )", "filename": "matrix_base.py", "nloc": 10, "complexity": 4, "token_count": 81, "parameters": [ "N", "M", "k", "typecode" ], "start_line": 42, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "diag", "long_name": "diag( v , k = 0 )", "filename": "matrix_base.py", "nloc": 17, "complexity": 7, "token_count": 165, "parameters": [ "v", "k" ], "start_line": 56, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "fliplr", "long_name": "fliplr( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "m" ], "start_line": 9, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "flipud", "long_name": "flipud( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "m" ], "start_line": 18, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "rot90", "long_name": "rot90( m , k = 1 )", "filename": "matrix_base.py", "nloc": 9, "complexity": 5, "token_count": 78, "parameters": [ "m", "k" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "eye", "long_name": "eye( N , M = None , k = 0 , typecode = None )", "filename": "matrix_base.py", "nloc": 10, "complexity": 4, "token_count": 81, "parameters": [ "N", "M", "k", "typecode" ], "start_line": 42, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "diag", "long_name": "diag( v , k = 0 )", "filename": "matrix_base.py", "nloc": 17, "complexity": 7, "token_count": 165, "parameters": [ "v", "k" ], "start_line": 56, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "eye", "long_name": "eye( N , M = None , k = 0 , typecode = 'd' )", "filename": "matrix_base.py", "nloc": 10, "complexity": 4, "token_count": 81, "parameters": [ "N", "M", "k", "typecode" ], "start_line": 42, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "eye", "long_name": "eye( N , M = None , k = 0 , typecode = None )", "filename": "matrix_base.py", "nloc": 10, "complexity": 4, "token_count": 81, "parameters": [ "N", "M", "k", "typecode" ], "start_line": 42, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "nloc": 57, "complexity": 22, "token_count": 464, "diff_parsed": { "added": [ "def eye(N, M=None, k=0, typecode='d'):" ], "deleted": [ "def eye(N, M=None, k=0, typecode=None):" ] } } ] }, { "hash": "295afb0cbf88cf077f402ae539fc19a32e3001ed", "msg": "fixed bug causing ufunction remainder to not work.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-06-26T21:36:08+00:00", "author_timezone": 0, "committer_date": "2003-06-26T21:36:08+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "11d26a6d3e3adae9e8873fd9d65806dd18428ebb" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 6, "insertions": 6, "lines": 12, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/fastumath_unsigned.inc", "new_path": "scipy_base/fastumath_unsigned.inc", "filename": "fastumath_unsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -2838,9 +2838,9 @@ static void InitOperators(PyObject *dictionary) {\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n conjugate_data[11] = (void *)\"conjugate\";\n+ remainder_data[7] = (void *)fmod;\n remainder_data[8] = (void *)fmod;\n- remainder_data[9] = (void *)fmod;\n- remainder_data[10] = (void *)PyNumber_Remainder;\n+ remainder_data[9] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow;\n@@ -2882,9 +2882,9 @@ static void InitOperators(PyObject *dictionary) {\n #endif\n \n conjugate_functions[11] = PyUFunc_O_O_method;\n- remainder_functions[8] = PyUFunc_ff_f_As_dd_d;\n- remainder_functions[9] = PyUFunc_dd_d;\n- remainder_functions[10] = PyUFunc_OO_O;\n+ remainder_functions[7] = PyUFunc_ff_f_As_dd_d;\n+ remainder_functions[8] = PyUFunc_dd_d;\n+ remainder_functions[9] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n@@ -2975,7 +2975,7 @@ static void InitOperators(PyObject *dictionary) {\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n-\t\t\t\t11, 2, 1, PyUFunc_Zero, \"remainder\", \n+\t\t\t\t10, 2, 1, PyUFunc_Zero, \"remainder\", \n \t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n", "added_lines": 6, "deleted_lines": 6, "source_code": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex c_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n\t x = a*b;\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_UINT, PyArray_UINT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod;\n multiply_data[10] = (void *)c_prod;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[7] = (void *)fmod;\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow;\n power_data[10] = (void *)c_pow;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = fastumath_FF_F_As_DD_D;\n multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = fastumath_FF_F_As_DD_D;\n divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[9] = (void *)c_quot_fast;\n true_divide_data[10] = (void *)c_quot_fast;\n true_divide_data[11] = (void *)PyNumber_TrueDivide;\n true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n floor_divide_data[9] = (void *)c_quot_floor_fast;\n floor_divide_data[10] = (void *)c_quot_floor_fast;\n floor_divide_data[11] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[9] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[10] = fastumath_DD_D;\n floor_divide_functions[11] = PyUFunc_OO_O;\n#endif\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[7] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[8] = PyUFunc_dd_d;\n remainder_functions[9] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = PyUFunc_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "source_code_before": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex c_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n\t x = a*b;\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_UINT, PyArray_UINT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod;\n multiply_data[10] = (void *)c_prod;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)fmod;\n remainder_data[10] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow;\n power_data[10] = (void *)c_pow;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = fastumath_FF_F_As_DD_D;\n multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = fastumath_FF_F_As_DD_D;\n divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[9] = (void *)c_quot_fast;\n true_divide_data[10] = (void *)c_quot_fast;\n true_divide_data[11] = (void *)PyNumber_TrueDivide;\n true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n floor_divide_data[9] = (void *)c_quot_floor_fast;\n floor_divide_data[10] = (void *)c_quot_floor_fast;\n floor_divide_data[11] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[9] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[10] = fastumath_DD_D;\n floor_divide_functions[11] = PyUFunc_OO_O;\n#endif\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[8] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[9] = PyUFunc_dd_d;\n remainder_functions[10] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = PyUFunc_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ " remainder_data[7] = (void *)fmod;", " remainder_data[9] = (void *)PyNumber_Remainder;", " remainder_functions[7] = PyUFunc_ff_f_As_dd_d;", " remainder_functions[8] = PyUFunc_dd_d;", " remainder_functions[9] = PyUFunc_OO_O;", "\t\t\t\t10, 2, 1, PyUFunc_Zero, \"remainder\"," ], "deleted": [ " remainder_data[9] = (void *)fmod;", " remainder_data[10] = (void *)PyNumber_Remainder;", " remainder_functions[8] = PyUFunc_ff_f_As_dd_d;", " remainder_functions[9] = PyUFunc_dd_d;", " remainder_functions[10] = PyUFunc_OO_O;", "\t\t\t\t11, 2, 1, PyUFunc_Zero, \"remainder\"," ] } } ] }, { "hash": "5708f46edafb549fd2a9f7ccb963e4c772fc3361", "msg": "Fixed initialization error of divide_safe in fastumath.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-08-04T23:57:44+00:00", "author_timezone": 0, "committer_date": "2003-08-04T23:57:44+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "295afb0cbf88cf077f402ae539fc19a32e3001ed" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 2, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/fastumath_nounsigned.inc", "new_path": "scipy_base/fastumath_nounsigned.inc", "filename": "fastumath_nounsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -2338,7 +2338,7 @@ static void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (vo\n static void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n static void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n #endif\n-static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n static void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n static void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n static void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n", "added_lines": 1, "deleted_lines": 1, "source_code": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n*/\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n \n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex c_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, INT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, INT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\n\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, CFLOAT_logical_and, CDOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, CFLOAT_logical_or, CDOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum,};\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[9] =(void *)PyNumber_Add;\n subtract_data[9] = (void *)PyNumber_Subtract;\n multiply_data[7] = (void *)c_prod;\n multiply_data[8] = (void *)c_prod;\n multiply_data[9] = (void *)PyNumber_Multiply;\n divide_data[7] = (void *)c_quot_fast;\n divide_data[8] = (void *)c_quot_fast;\n divide_data[9] = (void *)PyNumber_Divide;\n divide_safe_data[7] = (void *)c_quot;\n divide_safe_data[8] = (void *)c_quot;\n divide_safe_data[9] = (void *)PyNumber_Divide;\n conjugate_data[9] = (void *)\"conjugate\";\n remainder_data[5] = (void *)fmod;\n remainder_data[6] = (void *)fmod;\n remainder_data[7] = (void *)PyNumber_Remainder;\n power_data[5] = (void *)pow;\n power_data[6] = (void *)pow;\n power_data[7] = (void *)c_pow;\n power_data[8] = (void *)c_pow;\n power_data[9] = (void *)PyNumber_Power;\n absolute_data[8] = (void *)PyNumber_Absolute;\n negative_data[8] = (void *)PyNumber_Negative;\n bitwise_and_data[5] = (void *)PyNumber_And;\n bitwise_or_data[5] = (void *)PyNumber_Or;\n bitwise_xor_data[5] = (void *)PyNumber_Xor;\n invert_data[5] = (void *)PyNumber_Invert;\n left_shift_data[5] = (void *)PyNumber_Lshift;\n right_shift_data[5] = (void *)PyNumber_Rshift;\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[7] = (void *)c_quot_fast;\n true_divide_data[8] = (void *)c_quot_fast;\n true_divide_data[9] = (void *)PyNumber_TrueDivide;\n true_divide_functions[7] = fastumath_FF_F_As_DD_D;\n true_divide_functions[8] = fastumath_DD_D;\n true_divide_functions[9] = PyUFunc_OO_O;\n\n floor_divide_data[7] = (void *)c_quot_floor_fast;\n floor_divide_data[8] = (void *)c_quot_floor_fast;\n floor_divide_data[9] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[7] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[8] = fastumath_DD_D;\n floor_divide_functions[9] = PyUFunc_OO_O;\n#endif\n\n add_functions[9] = PyUFunc_OO_O;\n subtract_functions[9] = PyUFunc_OO_O;\n multiply_functions[7] = fastumath_FF_F_As_DD_D;\n multiply_functions[8] = fastumath_DD_D;\n multiply_functions[9] = PyUFunc_OO_O;\n divide_functions[7] = fastumath_FF_F_As_DD_D;\n divide_functions[8] = fastumath_DD_D;\n divide_functions[9] = PyUFunc_OO_O;\n divide_safe_functions[7] = fastumath_FF_F_As_DD_D;\n divide_safe_functions[8] = fastumath_DD_D;\n divide_safe_functions[9] = PyUFunc_OO_O;\n conjugate_functions[9] = PyUFunc_O_O_method;\n remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[6] = PyUFunc_dd_d;\n remainder_functions[7] = PyUFunc_OO_O;\n power_functions[5] = PyUFunc_ff_f_As_dd_d;\n power_functions[6] = PyUFunc_dd_d;\n power_functions[7] = fastumath_FF_F_As_DD_D;\n power_functions[8] = fastumath_DD_D;\n power_functions[9] = PyUFunc_OO_O;\n absolute_functions[8] = PyUFunc_O_O;\n negative_functions[8] = PyUFunc_O_O;\n bitwise_and_functions[5] = PyUFunc_OO_O;\n bitwise_or_functions[5] = PyUFunc_OO_O;\n bitwise_xor_functions[5] = PyUFunc_OO_O;\n invert_functions[5] = PyUFunc_O_O;\n left_shift_functions[5] = PyUFunc_OO_O;\n right_shift_functions[5] = PyUFunc_OO_O;\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t9, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "source_code_before": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain\n errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares\n the real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n*/\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n \n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex c_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, INT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, INT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\n\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, CFLOAT_logical_and, CDOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, CFLOAT_logical_or, CDOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, CFLOAT_logical_xor, CDOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, CFLOAT_maximum, CDOUBLE_maximum,};\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, CFLOAT_minimum, CDOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[9] =(void *)PyNumber_Add;\n subtract_data[9] = (void *)PyNumber_Subtract;\n multiply_data[7] = (void *)c_prod;\n multiply_data[8] = (void *)c_prod;\n multiply_data[9] = (void *)PyNumber_Multiply;\n divide_data[7] = (void *)c_quot_fast;\n divide_data[8] = (void *)c_quot_fast;\n divide_data[9] = (void *)PyNumber_Divide;\n divide_safe_data[7] = (void *)c_quot;\n divide_safe_data[8] = (void *)c_quot;\n divide_safe_data[9] = (void *)PyNumber_Divide;\n conjugate_data[9] = (void *)\"conjugate\";\n remainder_data[5] = (void *)fmod;\n remainder_data[6] = (void *)fmod;\n remainder_data[7] = (void *)PyNumber_Remainder;\n power_data[5] = (void *)pow;\n power_data[6] = (void *)pow;\n power_data[7] = (void *)c_pow;\n power_data[8] = (void *)c_pow;\n power_data[9] = (void *)PyNumber_Power;\n absolute_data[8] = (void *)PyNumber_Absolute;\n negative_data[8] = (void *)PyNumber_Negative;\n bitwise_and_data[5] = (void *)PyNumber_And;\n bitwise_or_data[5] = (void *)PyNumber_Or;\n bitwise_xor_data[5] = (void *)PyNumber_Xor;\n invert_data[5] = (void *)PyNumber_Invert;\n left_shift_data[5] = (void *)PyNumber_Lshift;\n right_shift_data[5] = (void *)PyNumber_Rshift;\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[7] = (void *)c_quot_fast;\n true_divide_data[8] = (void *)c_quot_fast;\n true_divide_data[9] = (void *)PyNumber_TrueDivide;\n true_divide_functions[7] = fastumath_FF_F_As_DD_D;\n true_divide_functions[8] = fastumath_DD_D;\n true_divide_functions[9] = PyUFunc_OO_O;\n\n floor_divide_data[7] = (void *)c_quot_floor_fast;\n floor_divide_data[8] = (void *)c_quot_floor_fast;\n floor_divide_data[9] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[7] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[8] = fastumath_DD_D;\n floor_divide_functions[9] = PyUFunc_OO_O;\n#endif\n\n add_functions[9] = PyUFunc_OO_O;\n subtract_functions[9] = PyUFunc_OO_O;\n multiply_functions[7] = fastumath_FF_F_As_DD_D;\n multiply_functions[8] = fastumath_DD_D;\n multiply_functions[9] = PyUFunc_OO_O;\n divide_functions[7] = fastumath_FF_F_As_DD_D;\n divide_functions[8] = fastumath_DD_D;\n divide_functions[9] = PyUFunc_OO_O;\n divide_safe_functions[7] = fastumath_FF_F_As_DD_D;\n divide_safe_functions[8] = fastumath_DD_D;\n divide_safe_functions[9] = PyUFunc_OO_O;\n conjugate_functions[9] = PyUFunc_O_O_method;\n remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[6] = PyUFunc_dd_d;\n remainder_functions[7] = PyUFunc_OO_O;\n power_functions[5] = PyUFunc_ff_f_As_dd_d;\n power_functions[6] = PyUFunc_dd_d;\n power_functions[7] = fastumath_FF_F_As_DD_D;\n power_functions[8] = fastumath_DD_D;\n power_functions[9] = PyUFunc_OO_O;\n absolute_functions[8] = PyUFunc_O_O;\n negative_functions[8] = PyUFunc_O_O;\n bitwise_and_functions[5] = PyUFunc_OO_O;\n bitwise_or_functions[5] = PyUFunc_OO_O;\n bitwise_xor_functions[5] = PyUFunc_OO_O;\n invert_functions[5] = PyUFunc_O_O;\n left_shift_functions[5] = PyUFunc_OO_O;\n right_shift_functions[5] = PyUFunc_OO_O;\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, greater_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t9, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };" ], "deleted": [ "static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };" ] } }, { "old_path": "scipy_base/fastumath_unsigned.inc", "new_path": "scipy_base/fastumath_unsigned.inc", "filename": "fastumath_unsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -2765,7 +2765,7 @@ static void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (vo\n static void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n static void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n #endif\n-static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n+static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *) NULL, (void *) NULL };\n static void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n static void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n static void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n", "added_lines": 1, "deleted_lines": 1, "source_code": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex c_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n\t x = a*b;\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *) NULL, (void *) NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_UINT, PyArray_UINT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod;\n multiply_data[10] = (void *)c_prod;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[7] = (void *)fmod;\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow;\n power_data[10] = (void *)c_pow;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = fastumath_FF_F_As_DD_D;\n multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = fastumath_FF_F_As_DD_D;\n divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[9] = (void *)c_quot_fast;\n true_divide_data[10] = (void *)c_quot_fast;\n true_divide_data[11] = (void *)PyNumber_TrueDivide;\n true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n floor_divide_data[9] = (void *)c_quot_floor_fast;\n floor_divide_data[10] = (void *)c_quot_floor_fast;\n floor_divide_data[11] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[9] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[10] = fastumath_DD_D;\n floor_divide_functions[11] = PyUFunc_OO_O;\n#endif\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[7] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[8] = PyUFunc_dd_d;\n remainder_functions[9] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = PyUFunc_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "source_code_before": "/* -*- c -*- */\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n#include \"mconf_lite.h\"\n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath + additions for isnan, isfinite, and isinf\n Also allows comparison operations on complex numbers (just compares the \n real part) and logical operations.\n\n All logical operations return UBYTE arrays.\n\n This version supports unsigned types. \n */\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n#ifndef UINT_BIT\n#define UINT_BIT (CHAR_BIT * sizeof(unsigned int))\n#endif\n\n#ifndef USHORT_BIT\n#define USHORT_BIT (CHAR_BIT * sizeof(unsigned short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.1415926535897931\n#endif\n\n\n#define ABS(x) ((x) < 0 ? -(x) : (x))\n\n/* isnan and isinf and isfinite functions */\nstatic void FLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) ABS(isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((float *)i1)[0]) || isnan((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isnan(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isnan((double)((double *)i1)[0]) || isnan((double)((double *)i1)[1]);\n }\n}\n\n\nstatic void FLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) !(isfinite((double)(*((float *)i1))) || isnan((double)(*((float *)i1))));\n }\n}\n\nstatic void DOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !(isfinite((double)(*((double *)i1))) || isnan((double)(*((double *)i1))));\n }\n}\n\nstatic void CFLOAT_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((float *)i1)[0])) && isfinite((double)(((float *)i1)[1]))) || isnan((double)(((float *)i1)[0])) || isnan((double)(((float *)i1)[1])));\n }\n}\n\nstatic void CDOUBLE_isinf(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op)= (unsigned char) !((isfinite((double)(((double *)i1)[0])) && isfinite((double)(((double *)i1)[1]))) || isnan((double)(((double *)i1)[0])) || isnan((double)(((double *)i1)[1])));\n }\n}\n\n\nstatic void FLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((float *)i1)));\n }\n}\n\nstatic void DOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)(*((double *)i1)));\n }\n}\n\nstatic void CFLOAT_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((float *)i1)[0]) && isfinite((double)((float *)i1)[1]);\n }\n}\n\nstatic void CDOUBLE_isfinite(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0], os=steps[1], n=dimensions[0];\n char *i1=args[0], *op=args[1];\n for (i=0; i < n; i++, i1+=is1, op+=os) {\n\t*((unsigned char *)op) = (unsigned char) isfinite((double)((double *)i1)[0]) && isfinite((double)((double *)i1)[1]);\n }\n}\n\nstatic PyUFuncGenericFunction isnan_functions[] = {FLOAT_isnan, DOUBLE_isnan, CFLOAT_isnan, CDOUBLE_isnan, NULL};\nstatic PyUFuncGenericFunction isinf_functions[] = {FLOAT_isinf, DOUBLE_isinf, CFLOAT_isinf, CDOUBLE_isinf, NULL};\nstatic PyUFuncGenericFunction isfinite_functions[] = {FLOAT_isfinite, DOUBLE_isfinite, CFLOAT_isfinite, CDOUBLE_isfinite, NULL};\n\nstatic char isinf_signatures[] = { PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_UBYTE, };\n\nstatic void * isnan_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isinf_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * isfinite_data[] = {(void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n\n\n\n/* Some functions needed from ufunc object, so that Py_complex's aren't being returned \nbetween code possibly compiled with different compilers.\n*/\n\ntypedef Py_complex ComplexBinaryFunc(Py_complex x, Py_complex y);\ntypedef Py_complex ComplexUnaryFunc(Py_complex x);\n\nstatic void fastumath_F_F_As_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((float *)ip1)[0]; x.imag = ((float *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((float *)op)[0] = (float)x.real;\n\t((float *)op)[1] = (float)x.imag;\n }\n}\n\nstatic void fastumath_D_D(char **args, int *dimensions, int *steps, void *func) {\n int i; Py_complex x;\n char *ip1=args[0], *op=args[1];\n for(i=0; i<*dimensions; i++, ip1+=steps[0], op+=steps[1]) {\n\tx.real = ((double *)ip1)[0]; x.imag = ((double *)ip1)[1];\n\tx = ((ComplexUnaryFunc *)func)(x);\n\t((double *)op)[0] = x.real;\n\t((double *)op)[1] = x.imag;\n }\n}\n\n\nstatic void fastumath_FF_F_As_DD_D(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2];\n char *ip1=args[0], *ip2=args[1], *op=args[2];\n int n=dimensions[0];\n Py_complex x, y;\n\t\n for(i=0; i */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\n/*\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n*/\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\n#if PY_VERSION_HEX >= 0x02020000\nstatic Py_complex c_quot_floor_fast(Py_complex a, Py_complex b)\n{\n /* Not really sure what to do here, but it looks like Python takes the \n floor of the real part and returns that as the answer. So, we will do the same.\n */\n Py_complex r;\n\n r = c_quot_fast(a, b);\n r.imag = 0.0;\n r.real = floor(r.real);\n return r;\n}\n#endif\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void USHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int x;\n for(i=0; i 65535) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned short *)op)=(unsigned short) x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void UINT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n unsigned int a, b, ah, bh, x, y;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) { /* result should fit into bits available. */\n\t x = a*b;\n *((unsigned int *)op)=x;\n continue;\n }\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n /* Otherwise one and only one of ah or bh is non-zero. Make it so a > b (ah >0 and bh=0) */\n\tif (a < b) { \n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n /* Now a = ah */\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^(INT_BIT/2) -- shifted_version won't fit in unsigned int.\n\n Then compute al*bl (this should fit in the allotated space)\n\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1; /* mask off ah so a is now al */\n\tx = a*b; /* al * bl */\n\tx += y << (INT_BIT/2); /* add ah * bl * 2^SHIFT */\n /* This could have caused overflow. One way to know is to check to see if x < al \n Not sure if this get's all cases */\n\tif (x < a) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned int *)op)=x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= 0x02020000\nstatic void UBYTE_floor_divide(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void USHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void UINT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\n\n/* complex numbers are compared by there real parts. */\nstatic void CFLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((float *)i2)[0];\n }\n}\nstatic void CDOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i ((double *)i2)[0];\n }\n}\n\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void USHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void UINT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void CFLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void CDOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\n\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void USHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned short *)i2) ? *((unsigned short *)i1) : *((unsigned short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void UINT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned int *)i2) ? *((unsigned int *)i1) : *((unsigned int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void CFLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n\t((float *)op)[1]=*((float *)i1) > *((float *)i2) ? ((float *)i1)[1] : ((float *)i2)[1];\n }\n}\nstatic void CDOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n\t((double *)op)[1]=*((double *)i1) > *((double *)i2) ? ((double *)i1)[1] : ((double *)i2)[1];\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void USHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void UINT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, USHORT_add, INT_add, UINT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, USHORT_subtract, INT_subtract, UINT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, USHORT_multiply, INT_multiply, UINT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, USHORT_divide, INT_divide, UINT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic PyUFuncGenericFunction floor_divide_functions[] = { UBYTE_floor_divide, SBYTE_floor_divide, SHORT_floor_divide, USHORT_floor_divide, INT_floor_divide, UINT_floor_divide, LONG_floor_divide, FLOAT_floor_divide, DOUBLE_floor_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction true_divide_functions[] = { UBYTE_true_divide, SBYTE_true_divide, SHORT_true_divide, USHORT_true_divide, INT_true_divide, UINT_true_divide, LONG_true_divide, FLOAT_true_divide, DOUBLE_true_divide, NULL, NULL, NULL, };\n#endif\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, USHORT_divide_safe, INT_divide_safe, UINT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, USHORT_conjugate, INT_conjugate, UINT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, USHORT_remainder, INT_remainder, UINT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, USHORT_power, INT_power, UINT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { UBYTE_absolute, SBYTE_absolute, SHORT_absolute, USHORT_absolute, INT_absolute, UINT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { UBYTE_negative, SBYTE_negative, SHORT_negative, USHORT_negative, INT_negative, UINT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, USHORT_greater, INT_greater, UINT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, CFLOAT_greater, CDOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, USHORT_greater_equal, INT_greater_equal, UINT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, CFLOAT_greater_equal, CDOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, USHORT_less, INT_less, UINT_less, LONG_less, FLOAT_less, DOUBLE_less, CFLOAT_less, CDOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, USHORT_less_equal, INT_less_equal, UINT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, CFLOAT_less_equal, CDOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, USHORT_equal, INT_equal, UINT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, USHORT_not_equal, INT_not_equal, UINT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, USHORT_logical_and, INT_logical_and, UINT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, USHORT_logical_or, INT_logical_or, UINT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, USHORT_logical_xor, INT_logical_xor, UINT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, USHORT_logical_not, INT_logical_not, UINT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, USHORT_maximum, INT_maximum, UINT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, USHORT_bitwise_and, INT_bitwise_and, UINT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, USHORT_bitwise_or, INT_bitwise_or, UINT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, USHORT_bitwise_xor, INT_bitwise_xor, UINT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, USHORT_invert, INT_invert, UINT_invert, LONG_invert, NULL, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, USHORT_left_shift, INT_left_shift, UINT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, USHORT_right_shift, INT_right_shift, UINT_right_shift, LONG_right_shift, NULL, };\n\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n\n\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n#if PY_VERSION_HEX >= 0x02020000\nstatic void * floor_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * true_divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\n#endif\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, }; \nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#if PY_VERSION_HEX >= 0x02020000\nstatic char floor_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char true_divide_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_FLOAT, PyArray_SBYTE, PyArray_SBYTE, PyArray_FLOAT, PyArray_SHORT, PyArray_SHORT, PyArray_FLOAT, PyArray_USHORT, PyArray_USHORT, PyArray_FLOAT, PyArray_INT, PyArray_INT, PyArray_DOUBLE, PyArray_UINT, PyArray_UINT, PyArray_DOUBLE, PyArray_LONG, PyArray_LONG, PyArray_DOUBLE, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n#endif\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE, PyArray_OBJECT, PyArray_OBJECT, PyArray_UBYTE,};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_UBYTE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_UBYTE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_UBYTE };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_UBYTE, PyArray_SHORT, PyArray_UBYTE, PyArray_USHORT, PyArray_UBYTE, PyArray_INT, PyArray_UBYTE, PyArray_UINT, PyArray_UBYTE, PyArray_LONG, PyArray_UBYTE, PyArray_FLOAT, PyArray_UBYTE, PyArray_DOUBLE, PyArray_UBYTE, };\nstatic char maximum_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_USHORT, PyArray_USHORT, PyArray_INT, PyArray_INT, PyArray_UINT, PyArray_UINT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[11] =(void *)PyNumber_Add;\n subtract_data[11] = (void *)PyNumber_Subtract;\n multiply_data[9] = (void *)c_prod;\n multiply_data[10] = (void *)c_prod;\n multiply_data[11] = (void *)PyNumber_Multiply;\n divide_data[9] = (void *)c_quot_fast;\n divide_data[10] = (void *)c_quot_fast;\n divide_data[11] = (void *)PyNumber_Divide;\n divide_safe_data[9] = (void *)c_quot;\n divide_safe_data[10] = (void *)c_quot;\n divide_safe_data[11] = (void *)PyNumber_Divide;\n conjugate_data[11] = (void *)\"conjugate\";\n remainder_data[7] = (void *)fmod;\n remainder_data[8] = (void *)fmod;\n remainder_data[9] = (void *)PyNumber_Remainder;\n power_data[7] = (void *)pow;\n power_data[8] = (void *)pow;\n power_data[9] = (void *)c_pow;\n power_data[10] = (void *)c_pow;\n power_data[11] = (void *)PyNumber_Power;\n absolute_data[11] = (void *)PyNumber_Absolute;\n negative_data[11] = (void *)PyNumber_Negative;\n bitwise_and_data[7] = (void *)PyNumber_And;\n bitwise_or_data[7] = (void *)PyNumber_Or;\n bitwise_xor_data[7] = (void *)PyNumber_Xor;\n invert_data[7] = (void *)PyNumber_Invert;\n left_shift_data[7] = (void *)PyNumber_Lshift;\n right_shift_data[7] = (void *)PyNumber_Rshift;\n\n add_functions[11] = PyUFunc_OO_O;\n subtract_functions[11] = PyUFunc_OO_O;\n multiply_functions[9] = fastumath_FF_F_As_DD_D;\n multiply_functions[10] = fastumath_DD_D;\n multiply_functions[11] = PyUFunc_OO_O;\n divide_functions[9] = fastumath_FF_F_As_DD_D;\n divide_functions[10] = fastumath_DD_D;\n divide_functions[11] = PyUFunc_OO_O;\n\n\n#if PY_VERSION_HEX >= 0x02020000\n true_divide_data[9] = (void *)c_quot_fast;\n true_divide_data[10] = (void *)c_quot_fast;\n true_divide_data[11] = (void *)PyNumber_TrueDivide;\n true_divide_functions[9] = fastumath_FF_F_As_DD_D;\n true_divide_functions[10] = fastumath_DD_D;\n true_divide_functions[11] = PyUFunc_OO_O;\n\n floor_divide_data[9] = (void *)c_quot_floor_fast;\n floor_divide_data[10] = (void *)c_quot_floor_fast;\n floor_divide_data[11] = (void *)PyNumber_FloorDivide;\n floor_divide_functions[9] = fastumath_FF_F_As_DD_D;\n floor_divide_functions[10] = fastumath_DD_D;\n floor_divide_functions[11] = PyUFunc_OO_O;\n#endif\n\n conjugate_functions[11] = PyUFunc_O_O_method;\n remainder_functions[7] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[8] = PyUFunc_dd_d;\n remainder_functions[9] = PyUFunc_OO_O;\n power_functions[7] = PyUFunc_ff_f_As_dd_d;\n power_functions[8] = PyUFunc_dd_d;\n power_functions[9] = fastumath_FF_F_As_DD_D;\n power_functions[10] = PyUFunc_DD_D;\n power_functions[11] = PyUFunc_OO_O;\n absolute_functions[11] = PyUFunc_O_O;\n negative_functions[11] = PyUFunc_O_O;\n bitwise_and_functions[7] = PyUFunc_OO_O;\n bitwise_or_functions[7] = PyUFunc_OO_O;\n bitwise_xor_functions[7] = PyUFunc_OO_O;\n invert_functions[7] = PyUFunc_O_O;\n left_shift_functions[7] = PyUFunc_OO_O;\n right_shift_functions[7] = PyUFunc_OO_O;\n\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = fastumath_F_F_As_D_D;\n arccos_functions[3] = fastumath_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n\n f = PyUFunc_FromFuncAndData(isinf_functions, isinf_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isinf\", \n \"isinf(x) returns non-zero if x is infinity.\", 0);\n PyDict_SetItemString(dictionary, \"isinf\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isfinite_functions, isfinite_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isfinite\", \n \"isfinite(x) returns non-zero if x is not infinity or not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isfinite\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(isnan_functions, isnan_data, isinf_signatures, \n 4, 1, 1, PyUFunc_None, \"isnan\", \n \"isnan(x) returns non-zero if x is not a number.\", 0);\n PyDict_SetItemString(dictionary, \"isnan\", f);\n Py_DECREF(f);\n\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 12, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n#if PY_VERSION_HEX >= 0x02020000\n f = PyUFunc_FromFuncAndData(floor_divide_functions, floor_divide_data, floor_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"floor_divide\", \n\t\t\t\t\"Floor divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"floor_divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(true_divide_functions, true_divide_data, true_divide_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"true_divide\", \n\t\t\t\t\"True divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"true_divide\", f);\n Py_DECREF(f);\n#endif\n\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t12, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t12, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t13, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t9, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, maximum_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, maximum_signatures,\n\t\t\t\t11, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t8, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *) NULL, (void *) NULL };" ], "deleted": [ "static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL };" ] } } ] }, { "hash": "888e29fd5dc881626c7375e8ef818b6608a142d6", "msg": "Intel Fortran compiler -module option appears starting at version 7.0", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-08-05T19:11:02+00:00", "author_timezone": 0, "committer_date": "2003-08-05T19:11:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "5708f46edafb549fd2a9f7ccb963e4c772fc3361" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 1, "insertions": 5, "lines": 6, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1150,6 +1150,7 @@ def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n \n \n #http://developer.intel.com/software/products/compilers/f60l/\n+#http://developer.intel.com/software/products/compilers/flin/\n class intel_ia32_fortran_compiler(fortran_compiler_base):\n \n vendor = 'Intel' # Intel(R) Corporation \n@@ -1207,7 +1208,10 @@ def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n \n def build_module_switch(self,module_dirs,temp_dir):\n- res = ' -module '+temp_dir\n+ if self.get_version() and self.version >= '7.0':\n+ res = ' -module '+temp_dir\n+ else:\n+ res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n", "added_lines": 5, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 72, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 100, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 137, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 158, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 199, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 208, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 230, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 237, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 246, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 267, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 280, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 293, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 352, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 390, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 417, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 455, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 489, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 494, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 501, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 510, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 517, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 538, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 583, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 596, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 625, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 631, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 638, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 664, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 677, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 742, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 759, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 793, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 836, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 843, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 866, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 879, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 901, "end_line": 921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 923, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 927, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 930, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 947, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 970, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 996, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1044, "end_line": 1106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1108, "end_line": 1125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1127, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1135, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1160, "end_line": 1189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1191, "end_line": 1205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1207, "end_line": 1208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1210, "end_line": 1219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1228, "end_line": 1231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1239, "end_line": 1260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1262, "end_line": 1264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1266, "end_line": 1267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1281, "end_line": 1309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1315, "end_line": 1316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1329, "end_line": 1360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1362, "end_line": 1363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1371, "end_line": 1395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1397, "end_line": 1400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "self" ], "start_line": 1402, "end_line": 1406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1422, "end_line": 1449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1451, "end_line": 1453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1463, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1490, "end_line": 1492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1494, "end_line": 1495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1499, "end_line": 1507, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 72, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 100, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 137, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 158, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 199, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 208, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 230, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 237, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 246, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 267, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 280, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 293, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 352, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 390, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 417, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 455, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 489, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 494, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 501, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 510, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 517, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 538, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 583, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 596, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 625, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 631, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 638, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 664, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 677, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 742, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 759, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 793, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 836, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 843, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 866, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 879, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 901, "end_line": 921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 923, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 927, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 930, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 947, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 970, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 996, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1044, "end_line": 1106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1108, "end_line": 1125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1127, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1135, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1159, "end_line": 1188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1190, "end_line": 1204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1206, "end_line": 1207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1209, "end_line": 1215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1224, "end_line": 1227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1235, "end_line": 1256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1258, "end_line": 1260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1262, "end_line": 1263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1277, "end_line": 1305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1311, "end_line": 1312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1325, "end_line": 1356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1358, "end_line": 1359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1367, "end_line": 1391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1393, "end_line": 1396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "self" ], "start_line": 1398, "end_line": 1402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1418, "end_line": 1445, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1447, "end_line": 1449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1459, "end_line": 1484, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1486, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1490, "end_line": 1491, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1495, "end_line": 1503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1210, "end_line": 1219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "nloc": 1122, "complexity": 294, "token_count": 6614, "diff_parsed": { "added": [ "#http://developer.intel.com/software/products/compilers/flin/", " if self.get_version() and self.version >= '7.0':", " res = ' -module '+temp_dir", " else:", " res = ''" ], "deleted": [ " res = ' -module '+temp_dir" ] } } ] }, { "hash": "9ec9ed3fd61e10244e65d6c333686b29d0614061", "msg": "Impl. support for Portland Group Fortran compilers", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-08-06T23:19:33+00:00", "author_timezone": 0, "committer_date": "2003-08-06T23:19:33+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "888e29fd5dc881626c7375e8ef818b6608a142d6" ], "project_name": "repo_copy", "project_path": "/tmp/tmpp98avart/repo_copy", "deletions": 4, "insertions": 61, "lines": 65, "files": 1, "dmm_unit_size": 0.3888888888888889, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.16666666666666666, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -48,6 +48,7 @@\n VAST\n F [unsupported]\n Lahey\n+ PG\n \"\"\"\n \n import distutils\n@@ -95,7 +96,7 @@ def run_command(command):\n run_command = commands.getstatusoutput\n \n fcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n- r'|Lahey|F'\n+ r'|Lahey|PG|F'\n \n def show_compilers():\n for compiler_class in all_compilers:\n@@ -458,13 +459,16 @@ def source_and_object_pairs(self,source_files, temp_dir=''):\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n- module_dirs=None, temp_dir=''):\n+ module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n \n switches = switches + ' ' + string.join(pp_opts,' ')\n \n- module_switch = self.build_module_switch(module_dirs,temp_dir)\n+ if ignore_modules:\n+ module_switch = ''\n+ else:\n+ module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n@@ -501,7 +505,8 @@ def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n- source_files, module_dirs, temp_dir)\n+ source_files, module_dirs, temp_dir,\n+ ignore_modules = 1)\n \n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n@@ -1494,6 +1499,56 @@ def get_opt(self):\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n \n+# http://www.pgroup.com\n+class pgroup_fortran_compiler(fortran_compiler_base):\n+\n+ vendor = 'PG' # The Portland Group, Inc \n+ ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n+\n+ def __init__(self, fc=None, f90c=None, verbose=0):\n+ fortran_compiler_base.__init__(self, verbose=verbose)\n+\n+ if fc is None:\n+ fc = 'pgf77'\n+ if f90c is None:\n+ f90c = 'pgf90'\n+\n+ self.f77_compiler = fc\n+ self.f90_compiler = f90c\n+\n+ switches = ' -fpic' # linux only\n+ switches = switches + ' -Minform=inform -Mnosecond_underscore' \n+\n+ self.f77_switches = self.f90_switches = switches\n+ self.f90_fixed_switch = ' -Mfixed'\n+\n+ self.f77_opt = self.f90_opt = self.get_opt()\n+ \n+ debug = ' -g '\n+ self.f77_debug = self.f90_debug = debug\n+\n+ if os.name=='posix':\n+ self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n+ else:\n+ self.ver_cmd = self.f90_compiler+' -V '\n+\n+ def get_opt(self):\n+ return ' -fast '\n+\n+ def get_linker_so(self):\n+ return [self.f90_compiler,\n+ '-shared', # linux only\n+ ]\n+\n+ def build_module_switch(self,module_dirs,temp_dir):\n+ res = ' -module '+temp_dir\n+ if module_dirs:\n+ for mod in module_dirs:\n+ res = res + ' -I' + mod \n+ res += ' -I '+temp_dir\n+ return res\n+\n+\n ##############################################################################\n \n def find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n@@ -1508,6 +1563,7 @@ def find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n \n if sys.platform=='win32':\n all_compilers = [\n+ pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n@@ -1519,6 +1575,7 @@ def find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n ]\n else:\n all_compilers = [\n+ pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n", "added_lines": 61, "deleted_lines": 4, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 138, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 159, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 209, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 268, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 281, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 294, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 353, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 391, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 418, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 449, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 456, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 461, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 493, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 505, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 519, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 522, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 543, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 588, "end_line": 596, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 598, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 601, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 628, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 630, "end_line": 631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 632, "end_line": 633, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 634, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 636, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 643, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 666, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 669, "end_line": 674, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 682, "end_line": 745, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 747, "end_line": 762, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 764, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 798, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 841, "end_line": 846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 848, "end_line": 866, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 871, "end_line": 872, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 884, "end_line": 904, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 906, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 928, "end_line": 930, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 932, "end_line": 933, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 935, "end_line": 945, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 952, "end_line": 973, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 975, "end_line": 993, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1001, "end_line": 1047, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1049, "end_line": 1111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1113, "end_line": 1130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1132, "end_line": 1138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1140, "end_line": 1148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1150, "end_line": 1151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1153, "end_line": 1154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1165, "end_line": 1194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1196, "end_line": 1210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1212, "end_line": 1213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1215, "end_line": 1224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1244, "end_line": 1265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1267, "end_line": 1269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1271, "end_line": 1272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1286, "end_line": 1314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1320, "end_line": 1321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1334, "end_line": 1365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1367, "end_line": 1368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1376, "end_line": 1400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1402, "end_line": 1405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "self" ], "start_line": 1407, "end_line": 1411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1427, "end_line": 1454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1456, "end_line": 1458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1468, "end_line": 1493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1495, "end_line": 1497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1499, "end_line": 1500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 127, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1508, "end_line": 1533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1535, "end_line": 1536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 1538, "end_line": 1541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1543, "end_line": 1549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1554, "end_line": 1562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 72, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 88, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 100, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 137, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 158, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 199, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 208, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 230, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 237, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 246, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 267, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 280, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 293, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 337, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 352, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 390, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 417, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 448, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 455, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 489, "end_line": 492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 494, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 501, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 506, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 510, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 514, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 517, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 538, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 583, "end_line": 591, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 593, "end_line": 594, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 596, "end_line": 621, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 623, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 625, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 627, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 629, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 631, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 638, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 661, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 664, "end_line": 669, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 677, "end_line": 740, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 742, "end_line": 757, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 759, "end_line": 760, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 793, "end_line": 834, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 836, "end_line": 841, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 843, "end_line": 861, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 866, "end_line": 867, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 879, "end_line": 899, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 901, "end_line": 921, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 923, "end_line": 925, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 927, "end_line": 928, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 930, "end_line": 940, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 947, "end_line": 968, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 970, "end_line": 988, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 996, "end_line": 1042, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1044, "end_line": 1106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1108, "end_line": 1125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1127, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1135, "end_line": 1143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1145, "end_line": 1146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1148, "end_line": 1149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1160, "end_line": 1189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1191, "end_line": 1205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1207, "end_line": 1208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1210, "end_line": 1219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1228, "end_line": 1231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1239, "end_line": 1260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1262, "end_line": 1264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1266, "end_line": 1267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1281, "end_line": 1309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1315, "end_line": 1316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1329, "end_line": 1360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1362, "end_line": 1363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1371, "end_line": 1395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1397, "end_line": 1400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "self" ], "start_line": 1402, "end_line": 1406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1422, "end_line": 1449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1451, "end_line": 1453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1463, "end_line": 1488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1490, "end_line": 1492, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1494, "end_line": 1495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1499, "end_line": 1507, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 127, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1508, "end_line": 1533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 1538, "end_line": 1541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 505, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1543, "end_line": 1549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 22, "complexity": 4, "token_count": 160, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir" ], "start_line": 460, "end_line": 485, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1535, "end_line": 1536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 461, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 } ], "nloc": 1164, "complexity": 304, "token_count": 6835, "diff_parsed": { "added": [ " PG", " r'|Lahey|PG|F'", " module_dirs=None, temp_dir='', ignore_modules = 0):", " if ignore_modules:", " module_switch = ''", " else:", " module_switch = self.build_module_switch(module_dirs,temp_dir)", " source_files, module_dirs, temp_dir,", " ignore_modules = 1)", "# http://www.pgroup.com", "class pgroup_fortran_compiler(fortran_compiler_base):", "", " vendor = 'PG' # The Portland Group, Inc", " ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'", "", " def __init__(self, fc=None, f90c=None, verbose=0):", " fortran_compiler_base.__init__(self, verbose=verbose)", "", " if fc is None:", " fc = 'pgf77'", " if f90c is None:", " f90c = 'pgf90'", "", " self.f77_compiler = fc", " self.f90_compiler = f90c", "", " switches = ' -fpic' # linux only", " switches = switches + ' -Minform=inform -Mnosecond_underscore'", "", " self.f77_switches = self.f90_switches = switches", " self.f90_fixed_switch = ' -Mfixed'", "", " self.f77_opt = self.f90_opt = self.get_opt()", "", " debug = ' -g '", " self.f77_debug = self.f90_debug = debug", "", " if os.name=='posix':", " self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '", " else:", " self.ver_cmd = self.f90_compiler+' -V '", "", " def get_opt(self):", " return ' -fast '", "", " def get_linker_so(self):", " return [self.f90_compiler,", " '-shared', # linux only", " ]", "", " def build_module_switch(self,module_dirs,temp_dir):", " res = ' -module '+temp_dir", " if module_dirs:", " for mod in module_dirs:", " res = res + ' -I' + mod", " res += ' -I '+temp_dir", " return res", "", "", " pgroup_fortran_compiler,", " pgroup_fortran_compiler," ], "deleted": [ " r'|Lahey|F'", " module_dirs=None, temp_dir=''):", " module_switch = self.build_module_switch(module_dirs,temp_dir)", " source_files, module_dirs, temp_dir)" ] } } ] } ]