[ { "hash": "f00675afa961d6fe25ede639b4a95b35d2dbecc2", "msg": "Backport to Py<2.3 (__file__ is not defined when __name__ is __main__)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-24T12:13:17+00:00", "author_timezone": 0, "committer_date": "2003-11-24T12:13:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "1aae76e5b0de886b9c7950441e2acdf103fff4ef" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 2, "insertions": 4, "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/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -231,8 +231,10 @@ class SourceGenerator:\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n- caller_dir = os.path.abspath(os.path.dirname(\\\n- sys._getframe(1).f_globals['__file__']))\n+ g = sys._getframe(1).f_globals\n+ fn = g.get('__file__',g.get('__name__'))\n+ if fn=='__main__': fn = sys.argv[0]\n+ caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n", "added_lines": 4, "deleted_lines": 2, "source_code": "import os,sys,string\nimport types\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\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 merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs():\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator:\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n\nclass SourceFilter:\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n", "source_code_before": "import os,sys,string\nimport types\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\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 merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs():\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator:\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n caller_dir = os.path.abspath(os.path.dirname(\\\n sys._getframe(1).f_globals['__file__']))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n\nclass SourceFilter:\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 6, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 44, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 47, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 68, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 77, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 80, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 96, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 108, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 127, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 167, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 176, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 185, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 195, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 212, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 218, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 232, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 245, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 247, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 266, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 270, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 6, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 44, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 47, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 68, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 77, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 80, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 96, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 108, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 127, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 167, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 176, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 185, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 195, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 212, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 218, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 127, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 232, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 243, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 245, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 264, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 232, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 } ], "nloc": 204, "complexity": 67, "token_count": 1570, "diff_parsed": { "added": [ " g = sys._getframe(1).f_globals", " fn = g.get('__file__',g.get('__name__'))", " if fn=='__main__': fn = sys.argv[0]", " caller_dir = os.path.abspath(os.path.dirname(fn))" ], "deleted": [ " caller_dir = os.path.abspath(os.path.dirname(\\", " sys._getframe(1).f_globals['__file__']))" ] } } ] }, { "hash": "965c4ba6338659de155ab472cd84a462399f0466", "msg": "Fixed bug when base is '/'", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-24T12:35:18+00:00", "author_timezone": 0, "committer_date": "2003-11-24T12:35:18+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f00675afa961d6fe25ede639b4a95b35d2dbecc2" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/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/sdist.py", "new_path": "scipy_distutils/command/sdist.py", "filename": "sdist.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -125,7 +125,7 @@ def remove_common_base(files):\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n- results = [string.replace(file,base,'') for file in files]\n+ results = [file[len(base):] for file in files]\n return results\n \n def find_common_base(files):\n", "added_lines": 1, "deleted_lines": 1, "source_code": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\nfrom scipy_distutils import log\n\nimport sys, os\nmod = __import__(__name__)\nsys.path.append(os.path.dirname(mod.__file__))\nimport line_endings\nsys.path = sys.path[:-1]\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n \n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n log.warn(\"no files to distribute -- empty manifest?\")\n else:\n log.info(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n log.warn(\"'%s' not a regular file -- skipping\", file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\n def make_distribution (self):\n \"\"\" Overridden to force a build of zip files to have Windows line \n endings and tar balls to have Unix line endings.\n \n Create the source distribution(s). First, we create the release\n tree with 'make_release_tree()'; then, we create all required\n archive files (according to 'self.formats') from the release tree.\n Finally, we clean up by blowing away the release tree (unless\n 'self.keep_temp' is true). The list of archive files created is\n stored so it can be retrieved later by 'get_archive_files()'.\n \"\"\"\n # Don't warn about missing meta-data here -- should be (and is!)\n # done elsewhere.\n base_dir = self.distribution.get_fullname()\n base_name = os.path.join(self.dist_dir, base_dir)\n files = map(os.path.abspath, self.filelist.files)\n self.make_release_tree(base_dir, files)\n archive_files = [] # remember names of files we create\n for fmt in self.formats: \n self.convert_line_endings(base_dir,fmt)\n file = self.make_archive(base_name, fmt, base_dir=base_dir)\n archive_files.append(file)\n \n self.archive_files = archive_files\n\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n\n def convert_line_endings(self,base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n if fmt == 'gztar':\n line_endings.dos2unix_dir(base_dir)\n elif fmt == 'zip':\n line_endings.unix2dos_dir(base_dir)\n \ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [file[len(base):] for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return ''\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d \n", "source_code_before": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\nfrom scipy_distutils import log\n\nimport sys, os\nmod = __import__(__name__)\nsys.path.append(os.path.dirname(mod.__file__))\nimport line_endings\nsys.path = sys.path[:-1]\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n \n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n log.warn(\"no files to distribute -- empty manifest?\")\n else:\n log.info(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n log.warn(\"'%s' not a regular file -- skipping\", file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\n def make_distribution (self):\n \"\"\" Overridden to force a build of zip files to have Windows line \n endings and tar balls to have Unix line endings.\n \n Create the source distribution(s). First, we create the release\n tree with 'make_release_tree()'; then, we create all required\n archive files (according to 'self.formats') from the release tree.\n Finally, we clean up by blowing away the release tree (unless\n 'self.keep_temp' is true). The list of archive files created is\n stored so it can be retrieved later by 'get_archive_files()'.\n \"\"\"\n # Don't warn about missing meta-data here -- should be (and is!)\n # done elsewhere.\n base_dir = self.distribution.get_fullname()\n base_name = os.path.join(self.dist_dir, base_dir)\n files = map(os.path.abspath, self.filelist.files)\n self.make_release_tree(base_dir, files)\n archive_files = [] # remember names of files we create\n for fmt in self.formats: \n self.convert_line_endings(base_dir,fmt)\n file = self.make_archive(base_name, fmt, base_dir=base_dir)\n archive_files.append(file)\n \n self.archive_files = archive_files\n\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n\n def convert_line_endings(self,base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n if fmt == 'gztar':\n line_endings.dos2unix_dir(base_dir)\n elif fmt == 'zip':\n line_endings.unix2dos_dir(base_dir)\n \ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [string.replace(file,base,'') for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return ''\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d \n", "methods": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 21, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 1 }, { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 13, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 79, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( self , base_dir , fmt )", "filename": "sdist.py", "nloc": 5, "complexity": 3, "token_count": 32, "parameters": [ "self", "base_dir", "fmt" ], "start_line": 107, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 61, "parameters": [ "files" ], "start_line": 118, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 131, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 21, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 1 }, { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 13, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 79, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( self , base_dir , fmt )", "filename": "sdist.py", "nloc": 5, "complexity": 3, "token_count": 32, "parameters": [ "self", "base_dir", "fmt" ], "start_line": 107, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "files" ], "start_line": 118, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 131, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 61, "parameters": [ "files" ], "start_line": 118, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "nloc": 82, "complexity": 25, "token_count": 616, "diff_parsed": { "added": [ " results = [file[len(base):] for file in files]" ], "deleted": [ " results = [string.replace(file,base,'') for file in files]" ] } } ] }, { "hash": "6a8cbdb79fca8504a397ee066f7ec665c339ab7f", "msg": "Setting the name of merged config dicts.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-24T20:28:20+00:00", "author_timezone": 0, "committer_date": "2003-11-24T20:28:20+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "965c4ba6338659de155ab472cd84a462399f0466" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 0, "insertions": 5, "lines": 5, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -175,6 +175,11 @@ def get_frame(level=0):\n \n def merge_config_dicts(config_list):\n result = default_config_dict()\n+ for d in config_list:\n+ name = d.get('name',None)\n+ if name is not None:\n+ result['name'] = name\n+ break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n", "added_lines": 5, "deleted_lines": 0, "source_code": "import os,sys,string\nimport types\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\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 merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n name = d.get('name',None)\n if name is not None:\n result['name'] = name\n break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs():\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator:\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n\nclass SourceFilter:\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n", "source_code_before": "import os,sys,string\nimport types\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\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 merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs():\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator:\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n\nclass SourceFilter:\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 6, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 44, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 47, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 68, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 77, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 80, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 96, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 108, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 127, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 167, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 176, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 190, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 200, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 217, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 223, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 237, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 250, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 252, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 271, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 6, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 44, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 47, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 68, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 77, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 80, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 96, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 108, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 127, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 167, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 8, "complexity": 4, "token_count": 61, "parameters": [ "config_list" ], "start_line": 176, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 185, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 192, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 195, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 212, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 218, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 232, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 245, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 247, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 266, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 270, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 176, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 } ], "nloc": 209, "complexity": 69, "token_count": 1598, "diff_parsed": { "added": [ " for d in config_list:", " name = d.get('name',None)", " if name is not None:", " result['name'] = name", " break" ], "deleted": [] } } ] }, { "hash": "d1906746d2e224ea610985c9b181602e94ef9db6", "msg": "Now one can run 'python /full/path/to/scipy_core/setup.py'", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-24T22:50:40+00:00", "author_timezone": 0, "committer_date": "2003-11-24T22:50:40+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "6a8cbdb79fca8504a397ee066f7ec665c339ab7f" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 26, "insertions": 17, "lines": 43, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "setup.py", "new_path": "setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -18,35 +18,27 @@\n \n bundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n \n-def get_package_config(name,parent_path=None):\n- sys.path.insert(0,name)\n- try:\n- mod = __import__('setup_'+name)\n- config = mod.configuration(parent_path=parent_path)\n- finally:\n- del sys.path[0]\n- return config\n-\n-def get_package_version(name):\n- sys.path.insert(0,name)\n- try:\n- mod = __import__(name+'_version')\n- finally:\n- del sys.path[0]\n- return mod\n-\n def setup_package():\n old_path = os.getcwd()\n- path = get_path(__name__)\n- os.chdir(path)\n- sys.path.insert(0,path)\n+ local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n+ os.chdir(local_path)\n+ sys.path.insert(0, local_path)\n \n try:\n- config = map(lambda x:get_package_config(x,parent_path=path),\n- bundle_packages)\n- config_dict = merge_config_dicts(config)\n+ configs = [{'name':'Scipy_core'}]\n+ versions = []\n+ for n in bundle_packages:\n+ sys.path.insert(0,os.path.join(local_path,n))\n+ try:\n+ mod = __import__('setup_'+n)\n+ configs.append(mod.configuration())\n+ mod = __import__(n+'_version')\n+ versions.append(mod)\n+ finally:\n+ del sys.path[0]\n+ \n+ config_dict = merge_config_dicts(configs)\n \n- versions = map(get_package_version,bundle_packages)\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n@@ -60,8 +52,7 @@ def setup_package():\n \n print 'SciPy Core Version %s' % scipy_core_version\n from scipy_distutils.core import setup\n- setup (name = \"Scipy_core\",\n- version = scipy_core_version,\n+ setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n", "added_lines": 17, "deleted_lines": 26, "source_code": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration())\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n from scipy_distutils.core import setup\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n\ndef get_package_config(name,parent_path=None):\n sys.path.insert(0,name)\n try:\n mod = __import__('setup_'+name)\n config = mod.configuration(parent_path=parent_path)\n finally:\n del sys.path[0]\n return config\n\ndef get_package_version(name):\n sys.path.insert(0,name)\n try:\n mod = __import__(name+'_version')\n finally:\n del sys.path[0]\n return mod\n\ndef setup_package():\n old_path = os.getcwd()\n path = get_path(__name__)\n os.chdir(path)\n sys.path.insert(0,path)\n\n try:\n config = map(lambda x:get_package_config(x,parent_path=path),\n bundle_packages)\n config_dict = merge_config_dicts(config)\n\n versions = map(get_package_version,bundle_packages)\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n from scipy_distutils.core import setup\n setup (name = \"Scipy_core\",\n version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 40, "complexity": 10, "token_count": 310, "parameters": [], "start_line": 21, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_package_config", "long_name": "get_package_config( name , parent_path = None )", "filename": "setup.py", "nloc": 8, "complexity": 2, "token_count": 50, "parameters": [ "name", "parent_path" ], "start_line": 21, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_package_version", "long_name": "get_package_version( name )", "filename": "setup.py", "nloc": 7, "complexity": 2, "token_count": 36, "parameters": [ "name" ], "start_line": 30, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 33, "complexity": 8, "token_count": 244, "parameters": [], "start_line": 38, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_package_version", "long_name": "get_package_version( name )", "filename": "setup.py", "nloc": 7, "complexity": 2, "token_count": 36, "parameters": [ "name" ], "start_line": 30, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( name , parent_path = None )", "filename": "setup.py", "nloc": 8, "complexity": 2, "token_count": 50, "parameters": [ "name", "parent_path" ], "start_line": 21, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 40, "complexity": 10, "token_count": 310, "parameters": [], "start_line": 21, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "nloc": 57, "complexity": 10, "token_count": 347, "diff_parsed": { "added": [ " local_path = os.path.dirname(os.path.abspath(sys.argv[0]))", " os.chdir(local_path)", " sys.path.insert(0, local_path)", " configs = [{'name':'Scipy_core'}]", " versions = []", " for n in bundle_packages:", " sys.path.insert(0,os.path.join(local_path,n))", " try:", " mod = __import__('setup_'+n)", " configs.append(mod.configuration())", " mod = __import__(n+'_version')", " versions.append(mod)", " finally:", " del sys.path[0]", "", " config_dict = merge_config_dicts(configs)", " setup( version = scipy_core_version," ], "deleted": [ "def get_package_config(name,parent_path=None):", " sys.path.insert(0,name)", " try:", " mod = __import__('setup_'+name)", " config = mod.configuration(parent_path=parent_path)", " finally:", " del sys.path[0]", " return config", "", "def get_package_version(name):", " sys.path.insert(0,name)", " try:", " mod = __import__(name+'_version')", " finally:", " del sys.path[0]", " return mod", "", " path = get_path(__name__)", " os.chdir(path)", " sys.path.insert(0,path)", " config = map(lambda x:get_package_config(x,parent_path=path),", " bundle_packages)", " config_dict = merge_config_dicts(config)", " versions = map(get_package_version,bundle_packages)", " setup (name = \"Scipy_core\",", " version = scipy_core_version," ] } } ] }, { "hash": "aba97743ac2c2df2a6a9fb26c955502e6487ce79", "msg": "This fixes curious scipy_distutils.core import error.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-24T23:27:06+00:00", "author_timezone": 0, "committer_date": "2003-11-24T23:27:06+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "d1906746d2e224ea610985c9b181602e94ef9db6" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 3, "insertions": 3, "lines": 6, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/setup_scipy_base.py", "new_path": "scipy_base/setup_scipy_base.py", "filename": "setup_scipy_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,11 +2,11 @@\n \n import os, sys\n from glob import glob\n-from scipy_distutils.core import Extension\n-from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n import shutil\n \n def configuration(parent_package='',parent_path=None):\n+ from scipy_distutils.core import Extension\n+ from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n \n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.core import Extension\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os, sys\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path,default_config_dict,dot_join\nimport shutil\n\ndef configuration(parent_package='',parent_path=None):\n from scipy_distutils.misc_util import get_path,default_config_dict,\\\n dot_join,SourceGenerator\n\n package = 'scipy_base'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n # extra_compile_args -- trying to find something that is binary compatible\n # with msvc for returning Py_complex from functions\n extra_compile_args=[]\n \n # fastumath module\n # scipy_base.fastumath module\n umath_c_sources = ['fastumathmodule.c',\n 'fastumath_unsigned.inc','fastumath_nounsigned.inc']\n umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]\n umath_c = SourceGenerator(func = None,\n target = os.path.join(local_path,'fastumathmodule.c'),\n sources = umath_c_sources)\n sources = [umath_c, os.path.join(local_path,'isnan.c')]\n define_macros = []\n if sys.byteorder == \"little\":\n define_macros.append(('USE_MCONF_LITE_LE',None))\n else:\n define_macros.append(('USE_MCONF_LITE_BE',None))\n ext = Extension(dot_join(package,'fastumath'),sources,\n define_macros = define_macros,\n extra_compile_args=extra_compile_args)\n config['ext_modules'].append(ext)\n \n # _compiled_base module\n sources = ['_compiled_base.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'_compiled_base'),sources)\n config['ext_modules'].append(ext)\n\n return config\n\nif __name__ == '__main__':\n from scipy_base_version import scipy_base_version\n print 'scipy_base Version',scipy_base_version\n if sys.platform == 'win32':\n from scipy_distutils.mingw32_support import *\n from scipy_distutils.core import setup\n setup(version = scipy_base_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy base module\",\n url = \"http://www.scipy.org\",\n license = \"SciPy License (BSD Style)\",\n **configuration()\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 30, "complexity": 4, "token_count": 241, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 4, "token_count": 225, "parameters": [ "parent_package", "parent_path" ], "start_line": 9, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_base.py", "nloc": 30, "complexity": 4, "token_count": 241, "parameters": [ "parent_package", "parent_path" ], "start_line": 7, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "nloc": 47, "complexity": 4, "token_count": 315, "diff_parsed": { "added": [ " from scipy_distutils.core import Extension", " from scipy_distutils.misc_util import get_path,default_config_dict,dot_join" ], "deleted": [ "from scipy_distutils.core import Extension", "from scipy_distutils.misc_util import get_path,default_config_dict,dot_join" ] } }, { "old_path": "setup.py", "new_path": "setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -13,6 +13,7 @@\n import os\n import sys\n \n+from scipy_distutils.core import setup\n from scipy_distutils.misc_util import default_config_dict\n from scipy_distutils.misc_util import get_path, merge_config_dicts\n \n@@ -51,7 +52,6 @@ def setup_package():\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n \n print 'SciPy Core Version %s' % scipy_core_version\n- from scipy_distutils.core import setup\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n", "added_lines": 1, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.core import setup\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration())\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration())\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n from scipy_distutils.core import setup\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 39, "complexity": 10, "token_count": 304, "parameters": [], "start_line": 22, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 40, "complexity": 10, "token_count": 310, "parameters": [], "start_line": 21, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 40, "complexity": 10, "token_count": 310, "parameters": [], "start_line": 21, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 } ], "nloc": 57, "complexity": 10, "token_count": 347, "diff_parsed": { "added": [ "from scipy_distutils.core import setup" ], "deleted": [ " from scipy_distutils.core import setup" ] } } ] }, { "hash": "9a23b0fcafd7e82d0140fbcf18f87caf2f72f086", "msg": "Fixing Py<=2.1 get_platform for Power Mac", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-25T08:28:47+00:00", "author_timezone": 0, "committer_date": "2003-11-25T08:28:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "aba97743ac2c2df2a6a9fb26c955502e6487ce79" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 0, "insertions": 5, "lines": 5, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,11 @@\n import os,sys,string\n import types\n \n+if sys.version[:3]<='2.1':\n+ from distutils import util\n+ util_get_platform = util.get_platform\n+ util.get_platform = lambda : util_get_platform().replace(' ','_')\n+\n # Hooks for colored terminal output.\n # See also http://www.livinglogic.de/Python/ansistyle\n def terminal_has_colors():\n", "added_lines": 5, "deleted_lines": 0, "source_code": "import os,sys,string\nimport types\n\nif sys.version[:3]<='2.1':\n from distutils import util\n util_get_platform = util.get_platform\n util.get_platform = lambda : util_get_platform().replace(' ','_')\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\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 merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n name = d.get('name',None)\n if name is not None:\n result['name'] = name\n break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs():\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator:\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n\nclass SourceFilter:\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n", "source_code_before": "import os,sys,string\nimport types\n\n# Hooks for colored terminal output.\n# See also http://www.livinglogic.de/Python/ansistyle\ndef terminal_has_colors():\n if not hasattr(sys.stdout,'isatty') or not sys.stdout.isatty(): \n return 0\n try:\n import curses\n curses.setupterm()\n return (curses.tigetnum(\"colors\") >= 0\n and curses.tigetnum(\"pairs\") >= 0\n and ((curses.tigetstr(\"setf\") is not None \n and curses.tigetstr(\"setb\") is not None) \n or (curses.tigetstr(\"setaf\") is not None\n and curses.tigetstr(\"setab\") is not None)\n or curses.tigetstr(\"scp\") is not None))\n except: pass\n return 0\n\nif terminal_has_colors():\n def red_text(s): return '\\x1b[31m%s\\x1b[0m'%s\n def green_text(s): return '\\x1b[32m%s\\x1b[0m'%s\n def yellow_text(s): return '\\x1b[33m%s\\x1b[0m'%s\n def blue_text(s): return '\\x1b[34m%s\\x1b[0m'%s\n def cyan_text(s): return '\\x1b[35m%s\\x1b[0m'%s\nelse:\n def red_text(s): return s\n def green_text(s): return s\n def yellow_text(s): return s\n def cyan_text(s): return s\n def blue_text(s): return s\n\nclass PostponedException:\n \"\"\"Postpone exception until an attempt is made to use a resource.\"\"\"\n #Example usage:\n # try: import foo\n # except ImportError: foo = PostponedException()\n __all__ = []\n def __init__(self):\n self._info = sys.exc_info()[:2]\n self.__doc__ = '%s: %s' % tuple(self._info)\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n\ndef get_path(mod_name,parent_path=None):\n \"\"\" This function makes sure installation is done from the\n correct directory no matter if it is installed from the\n command line or from another package or run_setup function.\n \n \"\"\"\n if mod_name == '__main__':\n d = os.path.abspath('.')\n elif mod_name == '__builtin__':\n #builtin if/then added by Pearu for use in core.run_setup. \n d = os.path.dirname(os.path.abspath(sys.argv[0]))\n else:\n mod = __import__(mod_name)\n file = mod.__file__\n d = os.path.dirname(os.path.abspath(file))\n if parent_path is not None:\n pd = os.path.abspath(parent_path)\n if pd==d[:len(pd)]:\n d = d[len(pd)+1:]\n return d\n \ndef add_local_to_path(mod_name):\n local_path = get_path(mod_name)\n sys.path.insert(0,local_path)\n\ndef add_grandparent_to_path(mod_name):\n local_path = get_path(mod_name)\n gp_dir = os.path.split(local_path)[0]\n sys.path.insert(0,gp_dir)\n\ndef restore_path():\n del sys.path[0]\n\ndef append_package_dir_to_path(package_name): \n \"\"\" Search for a directory with package_name and append it to PYTHONPATH\n \n The local directory is searched first and then the parent directory.\n \"\"\"\n # first see if it is in the current path\n # then try parent. If it isn't found, fail silently\n # and let the import error occur.\n \n # not an easy way to clean up after this...\n import os,sys\n if os.path.exists(package_name):\n sys.path.append(package_name)\n elif os.path.exists(os.path.join('..',package_name)):\n sys.path.append(os.path.join('..',package_name))\n\ndef get_package_config(package_name):\n \"\"\" grab the configuration info from the setup_xxx.py file\n in a package directory. The package directory is searched\n from the current directory, so setting the path to the\n setup.py file directory of the file calling this is usually\n needed to get search the path correct.\n \"\"\"\n append_package_dir_to_path(package_name)\n mod = __import__('setup_'+package_name)\n config = mod.configuration()\n return config\n\ndef package_config(primary,dependencies=[]):\n \"\"\" Create a configuration dictionary ready for setup.py from\n a list of primary and dependent package names. Each\n package listed must have a directory with the same name\n in the current or parent working directory. Further, it\n should have a setup_xxx.py module within that directory that\n has a configuration() function in it. \n \"\"\"\n config = []\n config.extend([get_package_config(x) for x in primary])\n config.extend([get_package_config(x) for x in dependencies]) \n config_dict = merge_config_dicts(config)\n return config_dict\n \nlist_keys = ['packages', 'ext_modules', 'data_files',\n 'include_dirs', 'libraries', 'fortran_libraries',\n 'headers']\ndict_keys = ['package_dir']\n\ndef default_config_dict(name = None, parent_name = None):\n \"\"\" Return a configuration dictionary for usage in\n configuration() function defined in file setup_.py.\n \"\"\"\n d={}\n for key in list_keys: d[key] = []\n for key in dict_keys: d[key] = {}\n\n full_name = dot_join(parent_name,name)\n\n if full_name:\n # XXX: The following assumes that default_config_dict is called\n # only from setup_.configuration().\n # Todo: implement check for this assumption.\n frame = get_frame(1)\n caller_name = eval('__name__',frame.f_globals,frame.f_locals)\n local_path = get_path(caller_name)\n test_path = os.path.join(local_path,'tests')\n if 0 and name and parent_name is None:\n # Useful for local builds\n d['version'] = get_version(path=local_path)\n if os.path.exists(os.path.join(local_path,'__init__.py')):\n d['packages'].append(full_name)\n d['package_dir'][full_name] = local_path\n if os.path.exists(test_path):\n d['packages'].append(dot_join(full_name,'tests'))\n d['package_dir'][dot_join(full_name,'tests')] = test_path\n d['name'] = full_name\n if 0 and not parent_name:\n # Include scipy_distutils to local distributions\n for p in ['.','..']:\n dir_name = os.path.abspath(os.path.join(local_path,\n p,'scipy_distutils'))\n if os.path.exists(dir_name):\n d['packages'].append('scipy_distutils')\n d['packages'].append('scipy_distutils.command')\n d['package_dir']['scipy_distutils'] = dir_name\n break\n return d\n\ndef get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\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 merge_config_dicts(config_list):\n result = default_config_dict()\n for d in config_list:\n name = d.get('name',None)\n if name is not None:\n result['name'] = name\n break\n for d in config_list:\n for key in list_keys:\n result[key].extend(d.get(key,[]))\n for key in dict_keys:\n result[key].update(d.get(key,{}))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef dot_join(*args):\n return string.join(filter(None,args),'.')\n\ndef fortran_library_item(lib_name,\n sources,\n **attrs\n ):\n \"\"\" Helper function for creating fortran_libraries items. \"\"\"\n build_info = {'sources':sources}\n known_attrs = ['module_files','module_dirs',\n 'libraries','library_dirs']\n for key,value in attrs.items():\n if key not in known_attrs:\n raise TypeError,\\\n \"fortran_library_item() got an unexpected keyword \"\\\n \"argument '%s'\" % key\n build_info[key] = value\n \n return (lib_name,build_info)\n\ndef get_environ_include_dirs():\n includes = []\n if os.environ.has_key('PYTHONINCLUDE'):\n includes = os.environ['PYTHONINCLUDE'].split(os.pathsep)\n return includes\n\ndef get_build_temp():\n from distutils.util import get_platform\n plat_specifier = \".%s-%s\" % (get_platform(), sys.version[0:3])\n return os.path.join('build','temp'+plat_specifier)\n\nclass SourceGenerator:\n \"\"\" SourceGenerator\n func - creates target, arguments are (target,sources)+args\n sources - target source files\n args - extra arguments to func\n\n If func is None then target must exist and it is touched whenever\n sources are newer.\n \"\"\"\n def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target) and func is not None:\n g = sys._getframe(1).f_globals\n fn = g.get('__file__',g.get('__name__'))\n if fn=='__main__': fn = sys.argv[0]\n caller_dir = os.path.abspath(os.path.dirname(fn))\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n target_dir = caller_dir[len(prefix)+1:]\n target = os.path.join(get_build_temp(),target_dir,target)\n self.func = func\n self.target = target\n self.sources = sources\n self.args = args\n def __str__(self):\n return str(self.target)\n def generate(self):\n from distutils import dep_util,dir_util\n if dep_util.newer_group(self.sources,self.target):\n print 'Running generate',self.target\n dir_util.mkpath(os.path.dirname(self.target),verbose=1)\n if self.func is None:\n # Touch target\n os.utime(self.target,None)\n else:\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n\nclass SourceFilter:\n \"\"\" SourceFilter\n func - implements criteria to filter sources\n sources - source files\n args - extra arguments to func\n \"\"\"\n def __init__(self,func,sources,*args):\n self.func = func\n self.sources = sources\n self.args = args\n def filter(self):\n return self.func(self.sources,*self.args)\n", "methods": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 11, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 46, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 49, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 52, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 77, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 82, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 85, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 101, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 113, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 132, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 172, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 181, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 195, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 202, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 205, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 222, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 228, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 242, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 255, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 257, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 276, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "terminal_has_colors", "long_name": "terminal_has_colors( )", "filename": "misc_util.py", "nloc": 15, "complexity": 10, "token_count": 116, "parameters": [], "start_line": 6, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 41, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "name" ], "start_line": 44, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_path", "long_name": "get_path( mod_name , parent_path = None )", "filename": "misc_util.py", "nloc": 14, "complexity": 5, "token_count": 124, "parameters": [ "mod_name", "parent_path" ], "start_line": 47, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "add_local_to_path", "long_name": "add_local_to_path( mod_name )", "filename": "misc_util.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "mod_name" ], "start_line": 68, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "add_grandparent_to_path", "long_name": "add_grandparent_to_path( mod_name )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "mod_name" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 77, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "append_package_dir_to_path", "long_name": "append_package_dir_to_path( package_name )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 64, "parameters": [ "package_name" ], "start_line": 80, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "get_package_config", "long_name": "get_package_config( package_name )", "filename": "misc_util.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "package_name" ], "start_line": 96, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "package_config", "long_name": "package_config( primary , dependencies = [ ] )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 53, "parameters": [ "primary", "dependencies" ], "start_line": 108, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "default_config_dict", "long_name": "default_config_dict( name = None , parent_name = None )", "filename": "misc_util.py", "nloc": 29, "complexity": 13, "token_count": 266, "parameters": [ "name", "parent_name" ], "start_line": 127, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "get_frame", "long_name": "get_frame( level = 0 )", "filename": "misc_util.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 167, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "merge_config_dicts", "long_name": "merge_config_dicts( config_list )", "filename": "misc_util.py", "nloc": 13, "complexity": 6, "token_count": 89, "parameters": [ "config_list" ], "start_line": 176, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "misc_util.py", "nloc": 6, "complexity": 3, "token_count": 44, "parameters": [ "d", "kws" ], "start_line": 190, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "dot_join", "long_name": "dot_join( * args )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "args" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "fortran_library_item", "long_name": "fortran_library_item( lib_name , sources , ** attrs )", "filename": "misc_util.py", "nloc": 14, "complexity": 3, "token_count": 67, "parameters": [ "lib_name", "sources", "attrs" ], "start_line": 200, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "get_environ_include_dirs", "long_name": "get_environ_include_dirs( )", "filename": "misc_util.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [], "start_line": 217, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "get_build_temp", "long_name": "get_build_temp( )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [], "start_line": 223, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 13, "complexity": 4, "token_count": 154, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 237, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 250, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 252, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , sources , * args )", "filename": "misc_util.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "self", "func", "sources", "args" ], "start_line": 271, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "filter", "long_name": "filter( self )", "filename": "misc_util.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [], "nloc": 213, "complexity": 69, "token_count": 1634, "diff_parsed": { "added": [ "if sys.version[:3]<='2.1':", " from distutils import util", " util_get_platform = util.get_platform", " util.get_platform = lambda : util_get_platform().replace(' ','_')", "" ], "deleted": [] } } ] }, { "hash": "c4f81c2baba836f4ac1fcca69d348f3ad3415dbe", "msg": "Fixed problems in arraymap having to do with zero-dimensional support. Fixed corresponding problems with distributions.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-11-25T23:39:51+00:00", "author_timezone": 0, "committer_date": "2003-11-25T23:39:51+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "9a23b0fcafd7e82d0140fbcf18f87caf2f72f086" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 15, "insertions": 22, "lines": 37, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/_compiled_base.c", "new_path": "scipy_base/_compiled_base.c", "filename": "_compiled_base.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -239,7 +239,7 @@ static int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays\n }\n if (PyArray_SIZE(ain)==0) {\n cleanup_arrays(inputarrays,i);\n- PyErr_SetString(PyExc_ValueError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n+ PyErr_SetString(PyExc_IndexError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n return -1;\n }\n if (ain->nd > maxrank) maxrank = ain->nd;\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n\n\nstatic char doc_base_unique[] = \"Return the unique elements of a 1-D sequence.\";\n\nstatic PyObject *base_unique(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns a 1-D array containing the unique elements of a 1-D sequence.\n */\n\n void *new_mem=NULL;\n PyArrayObject *ainput=NULL, *aoutput=NULL;\n int asize, abytes, new;\n int copied=0, nd;\n int instride=0, elsize, k, j, dims[1];\n char *ip, *op; /* Current memory buffer */\n char *op2;\n \n static char *kwlist[] = {\"input\", NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!\", kwlist, &PyArray_Type, &ainput)) \n return NULL;\n \n if (ainput->nd > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n Py_DECREF(avals);\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=nd-1; i > 0; --i) {\n indx += (rem_indx % inshape[i]) * instrides[i];\n rem_indx /= inshape[i];\n }\n indx += rem_indx * instrides[0];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Decrement the reference count of all objects in **arrays. */\nstatic void cleanup_arrays(PyArrayObject **arrays, int number)\n{\n int k;\n for (k=0; k < number; k++)\n Py_XDECREF((PyObject *)arrays[k]);\n return;\n}\n\n/* All rank-0 arrays are converted to rank-1 arrays */\n/* The number of dimensions of each array with rank less than\n the rank of the array with the most dimensions is increased by \n prepending with a dimenson length of one so that all arrays have\n the same rank. */\n/* Dimensions are checked and unmatched dimensions triggers an error */\n/* Strides for dimensions whose real length is one is set to zero but the dimension\n length is set to the maximum dimensions for the collection of inputs */\nstatic int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays, int nin)\n{\n int i, k;\n int maxrank=1;\n int *maxdims;\n PyObject *inputobj;\n PyArrayObject *ain, *tmparray;\n\n /* Convert nested sequences to arrays or just increase reference count\n if already an array */\n for (i=0; i < nin; i++) {\n ain = NULL;\n inputobj = PyTuple_GET_ITEM(inputs,i);\n ain = (PyArrayObject *)PyArray_FromObject(inputobj,PyArray_ObjectType(inputobj,0),0,0);\n if (NULL == ain) {\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if (PyArray_SIZE(ain)==0) {\n cleanup_arrays(inputarrays,i);\n PyErr_SetString(PyExc_IndexError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n return -1;\n }\n if (ain->nd > maxrank) maxrank = ain->nd;\n if (ain->nd == 0) { /* turn into 1-d array */\n /* convert to rank-1 array */\n if ((ain->dimensions = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if ((ain->strides = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n free(ain->dimensions);\n return -1;\n }\n ain->nd = 1;\n ain->dimensions[0] = 1;\n ain->strides[0] = ain->descr->elsize;\n }\n inputarrays[i] = ain;\n }\n\n maxdims = (int*)malloc(2*sizeof(int)*maxrank);\n if (NULL == maxdims) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n\n\n /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */\n /* We want to replace the header information without copying the data. \n Keeping the reference count correct can be tricky.\n We want to make a new array object with a different header and decrease the \n reference count of the old one without deallocating the data section */\n for (i=0; i < nin; i++) {\n ain = inputarrays[i];\n\n /* Initialize all dimensions to 1 */\n /* Change array shape */\n for (k=0; k < maxrank; k++) \n maxdims[k] = 1; \n for (k=maxrank-ain->nd; k< maxrank; k++) \n maxdims[k] = ain->dimensions[k-maxrank+ain->nd];\n\n tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);\n if (NULL == tmparray) {\n free(maxdims);\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);\n tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */\n inputarrays[i] = tmparray; /* tmparray is new array */\n }\n\n /* Find dimension length for the output arrays (maximum length for each\n dimension) */\n for (k=0; k < maxrank; k++) { \n maxdims[k] = 1;\n for (i=0; i < nin; i++) \n if (inputarrays[i]->dimensions[k] > maxdims[k])\n\tmaxdims[k] = inputarrays[i]->dimensions[k];\n }\n\n /* Now set all lengths for input array dimensions to maxdims \n and make strides equal to zero for arrays whose\n real length is 1 for a particular dimension\n */\n\n for (i=0; idimensions[k]) {\n\tain->strides[k] = 0;\n\tain->dimensions[k] = maxdims[k];\n }\n else if (ain->dimensions[k] != maxdims[k]) {\n\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");\n\tcleanup_arrays(inputarrays,nin);\n\tfree(maxdims);\n\treturn -1;\n }\n }\n }\n\n free(maxdims);\n return 0;\n\n}\n\nstatic int type_from_object(PyObject *obj)\n{\n if (PyArray_Check(obj))\n return ((PyArrayObject *)obj)->descr->type_num;\n if (PyComplex_Check(obj)) return PyArray_CDOUBLE;\n if (PyFloat_Check(obj)) return PyArray_DOUBLE;\n if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");\n return -1;\n}\n\nstatic int type_from_char(char typechar)\n{\n switch(typechar) {\n case 'c': return PyArray_CHAR;\n case 'b': return PyArray_UBYTE;\n case '1': return PyArray_SBYTE;\n case 's': return PyArray_SHORT;\n case 'i': return PyArray_INT;\n#ifdef PyArray_UNSIGNED_TYPES\n case 'w': return PyArray_USHORT;\n case 'u': return PyArray_UINT;\n#endif\n case 'l': return PyArray_LONG;\n case 'f': return PyArray_FLOAT;\n case 'd': return PyArray_DOUBLE;\n case 'F': return PyArray_CFLOAT;\n case 'D': return PyArray_CDOUBLE;\n default:\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");\n return -1;\n }\n}\n\n\n\n/* This sets up the output arrays by calling the function with arguments \n the first element of each input arrays. If otypes is NULL, the\n returned value type is used to establish the type of the output\n arrays, otherwise the characters in otypes determine the\n output types */\nstatic int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)\n{\n PyObject *arglist, *result;\n PyObject *tmpobject;\n PyArrayObject *tmparr;\n int i, nout;\n int nd, *dimensions, type_num;\n\n nd = inarr[0]->nd;\n dimensions = inarr[0]->dimensions;\n\n if ((numtypes == 0) || (otypes == NULL)) { \n /* Call function to get number of outputs */\n\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n return -1;\n }\n /* Construct input argument by creating a tuple with an element\n from each input array (cast to an appropriate Python Object) */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Get first data point */\n tmpobject = tmparr->descr->getitem((void *)tmparr->data);\n if (NULL == tmpobject) {\n\tPy_DECREF(arglist);\n\treturn -1;\n }\n PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */\n } \n /* Call Python Function */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n return -1;\n }\n\n Py_DECREF(arglist);\n\n /* If result is a tuple, create output_arrays according \n to output. */\n if (PyTuple_Check(result)) {\n nout = PyTuple_GET_SIZE(result);\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL == *outarr) {\n\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n /* Create nout output arrays */\n for (i=0; i < nout; i++) {\n\t/* Determine type */\n\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n\t/* Create output array */\n\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n\tif (NULL == (*outarr)[i]) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n }\n }\n else { /* Only a single output result */\n nout = 1;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n if ((type_num = type_from_object(result))==-1) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[0]) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n }\n Py_DECREF(result);\n }\n\n else { /* Character output types entered */\n nout = numtypes;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n return -1;\n }\n /* Create Output arrays */\n for (i=0; i < nout; i++) {\n /* Get type */\n if ((type_num = type_from_char(otypes[i]))==-1) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n /* Create array */\n (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[i]) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n } \n } \n return nout;\n}\n\n\n/* Corresponding dimensions are assumed to match, check before calling. */\n/* No rank-0 arrays (make them rank-1 arrays) */\n\n/* This replicates the standard Ufunc broadcasting rule that if the\n dimension length is one, incrementing does not occur for that dimension. \n\n This is currently done by setting the stride in that dimension to\n zero during input array setup.\n\n The purpose of this function is to perform a for loop over arbitrary\n discontiguous N-D arrays, call the Python function for each set of \n corresponding elements and place the results in the output_array.\n*/ \n#define INCREMENT(ret_ind, nd, max_ind) \\\n{ \\\n int k; \\\n k = (nd) - 1; \\\n if (++(ret_ind)[k] >= (max_ind)[k]) { \\\n while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\\n (ret_ind)[k--] = 0; \\\n if (k >= 0) (ret_ind)[k]++; \\\n else (ret_ind)[0] = (max_ind)[0]; \\\n } \\\n}\n\n#define CALCINDEX(indx, nd_index, strides, ndim) \\\n{ \\\n int i; \\\n \\\n indx = 0; \\\n for (i=0; i < (ndim); i++) \\\n indx += (nd_index)[i]*(strides)[i]; \\\n} \n\nstatic int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)\n{\n int i, loop_index;\n int *nd_index, indx_in, indx_out;\n PyArrayObject *in, *out, *tmparr;\n PyObject *result, *tmpobj, *arglist;\n\n in = inarr[0]; /* For any shape information needed */\n out = outarr[0];\n /* Allocate the N-D index initalized to zero. */\n nd_index = (int *)calloc(in->nd,sizeof(int));\n if (NULL == nd_index) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");\n return -1;\n }\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n free(nd_index);\n return -1;\n }\n\n loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */\n\n while(loop_index--) { \n /* Create input argument list with current element from the input\n arrays \n */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Find linear index into this input array */\n CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);\n /* Get object at this index */\n tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));\n if (NULL == tmpobj) {\n\tPy_DECREF(arglist);\n\tfree(nd_index);\n\treturn -1;\n }\n /* This steals reference of tmpobj */\n PyTuple_SET_ITEM(arglist, i, tmpobj); \n }\n /* Call Python Function for this set of inputs */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n free(nd_index);\n return -1;\n } \n\n /* Find index into (all) output arrays */\n CALCINDEX(indx_out,nd_index,out->strides,out->nd);\n\n /* Copy the results to the output arrays */\n if (1==nout) {\n if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {\n\tfree(nd_index);\n\tPy_DECREF(arglist);\n\tPy_DECREF(result);\n\treturn -1;\n }\n }\n else if (PyTuple_Check(result)) {\n for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {\n\t free(nd_index);\n\t Py_DECREF(arglist);\n\t Py_DECREF(result);\n return -1;\n\t}\n }\n }\n else { \n PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");\n free(nd_index);\n Py_DECREF(arglist);\n Py_DECREF(result);\n return -1;\n }\n\n /* Increment the index counter */\n INCREMENT(nd_index,in->nd,in->dimensions);\n Py_DECREF(result);\n\n }\n Py_DECREF(arglist);\n free(nd_index);\n return 0;\n} \n\nstatic PyObject *build_output(PyArrayObject **outarr,int nout)\n{\n int i;\n PyObject *out;\n\n if (1==nout) return PyArray_Return(outarr[0]);\n if ((out=PyTuple_New(nout))==NULL) return NULL;\n for (i=0; ind > 1) {\n PyErr_SetString(PyExc_ValueError, \"Input array must be < 1 dimensional\");\n return NULL;\n }\n asize = PyArray_SIZE(ainput);\n elsize = ainput->descr->elsize;\n abytes = asize * elsize;\n nd = ainput->nd;\n if (nd > 0) {\n instride = ainput->strides[0];\n }\n\n new_mem = (void *)PyMem_Malloc((size_t) abytes);\n if (new_mem == NULL) {\n return PyErr_NoMemory();\n }\n \n ip = ainput->data;\n op = new_mem;\n for (k=0; k < asize; k++,ip+=instride) {\n new = 1; /* Assume it is new */\n op2 = new_mem;\n for (j=0; j < copied; j++,op2+=elsize) {\n if (memcmp(op2,ip,elsize) == 0) { /* Is a match found? */\n new = 0;\n break;\n }\n }\n /* No match found, copy this one over */\n if (new) {\n memcpy(op,ip,elsize);\n copied += 1;\n op += elsize; /* Get ready to put next match */\n }\n }\n\n dims[0] = copied;\n /* Make output array */\n if ((aoutput = (PyArrayObject *)PyArray_FromDims(nd, \n dims, ainput->descr->type_num))==NULL) goto fail;\n\n memcpy(aoutput->data,new_mem,elsize*copied);\n /* Reallocate memory to new-size */\n PyMem_Free(new_mem);\n return PyArray_Return(aoutput); \n \n fail:\n if (new_mem != NULL) PyMem_Free(new_mem);\n Py_XDECREF(aoutput);\n return NULL;\n}\n\n\nstatic char doc_base_insert[] = \"Insert vals sequenctially into equivalent 1-d positions indicated by mask.\";\n\nstatic PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n{\n /* Returns input array with values inserted sequentially into places \n indicated by the mask\n */\n\n PyObject *mask=NULL, *vals=NULL;\n PyArrayObject *ainput=NULL, *amask=NULL, *avals=NULL, *avalscast=NULL, *tmp=NULL;\n int numvals, totmask, sameshape;\n char *input_data, *mptr, *vptr, *zero;\n int melsize, delsize, copied, nd;\n int *instrides, *inshape;\n int mindx, rem_indx, indx, i, k, objarray;\n \n static char *kwlist[] = {\"input\",\"mask\",\"vals\",NULL};\n\n if (!PyArg_ParseTupleAndKeywords(args, kwdict, \"O!OO\", kwlist, &PyArray_Type, &ainput, &mask, &vals))\n return NULL;\n\n /* Fixed problem with OBJECT ARRAYS\n if (ainput->descr->type_num == PyArray_OBJECT) {\n PyErr_SetString(PyExc_ValueError, \"Not currently supported for Object arrays.\");\n return NULL;\n }\n */\n\n amask = (PyArrayObject *)PyArray_ContiguousFromObject(mask, PyArray_NOTYPE, 0, 0);\n if (amask == NULL) return NULL;\n /* Cast an object array */\n if (amask->descr->type_num == PyArray_OBJECT) {\n tmp = (PyArrayObject *)PyArray_Cast(amask, PyArray_LONG);\n if (tmp == NULL) goto fail;\n Py_DECREF(amask);\n amask = tmp;\n }\n\n sameshape = 1;\n if (amask->nd == ainput->nd) {\n for (k=0; k < amask->nd; k++) \n if (amask->dimensions[k] != ainput->dimensions[k])\n sameshape = 0;\n }\n else { /* Test to see if amask is 1d */\n if (amask->nd != 1) sameshape = 0;\n else if ((PyArray_SIZE(ainput)) != PyArray_SIZE(amask)) sameshape = 0;\n }\n if (!sameshape) {\n PyErr_SetString(PyExc_ValueError, \"Mask array must be 1D or same shape as input array.\");\n goto fail;\n }\n\n avals = (PyArrayObject *)PyArray_FromObject(vals, PyArray_NOTYPE, 0, 1);\n if (avals == NULL) goto fail;\n avalscast = (PyArrayObject *)PyArray_Cast(avals, ainput->descr->type_num);\n if (avalscast == NULL) goto fail;\n Py_DECREF(avals);\n\n numvals = PyArray_SIZE(avalscast);\n nd = ainput->nd;\n input_data = ainput->data;\n mptr = amask->data;\n melsize = amask->descr->elsize;\n vptr = avalscast->data;\n delsize = avalscast->descr->elsize;\n zero = amask->descr->zero;\n objarray = (ainput->descr->type_num == PyArray_OBJECT);\n \n /* Handle zero-dimensional case separately */\n if (nd == 0) {\n if (memcmp(mptr,zero,melsize) != 0) {\n /* Copy value element over to input array */\n memcpy(input_data,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n }\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n }\n\n /* Walk through mask array, when non-zero is encountered\n copy next value in the vals array to the input array.\n If we get through the value array, repeat it as necessary. \n */\n totmask = PyArray_SIZE(amask);\n copied = 0;\n instrides = ainput->strides;\n inshape = ainput->dimensions;\n for (mindx = 0; mindx < totmask; mindx++) { \n if (memcmp(mptr,zero,melsize) != 0) { \n /* compute indx into input array \n */\n rem_indx = mindx;\n indx = 0;\n for(i=nd-1; i > 0; --i) {\n indx += (rem_indx % inshape[i]) * instrides[i];\n rem_indx /= inshape[i];\n }\n indx += rem_indx * instrides[0];\n /* fprintf(stderr, \"mindx = %d, indx=%d\\n\", mindx, indx); */\n /* Copy value element over to input array */\n memcpy(input_data+indx,vptr,delsize);\n if (objarray) Py_INCREF(*((PyObject **)vptr));\n vptr += delsize;\n copied += 1;\n /* If we move past value data. Reset */\n if (copied >= numvals) vptr = avalscast->data;\n }\n mptr += melsize;\n }\n\n Py_DECREF(amask);\n Py_DECREF(avalscast);\n Py_INCREF(Py_None);\n return Py_None;\n \n fail:\n Py_XDECREF(amask);\n Py_XDECREF(avals);\n Py_XDECREF(avalscast);\n return NULL;\n}\n\n\n/* Decrement the reference count of all objects in **arrays. */\nstatic void cleanup_arrays(PyArrayObject **arrays, int number)\n{\n int k;\n for (k=0; k < number; k++)\n Py_XDECREF((PyObject *)arrays[k]);\n return;\n}\n\n/* All rank-0 arrays are converted to rank-1 arrays */\n/* The number of dimensions of each array with rank less than\n the rank of the array with the most dimensions is increased by \n prepending with a dimenson length of one so that all arrays have\n the same rank. */\n/* Dimensions are checked and unmatched dimensions triggers an error */\n/* Strides for dimensions whose real length is one is set to zero but the dimension\n length is set to the maximum dimensions for the collection of inputs */\nstatic int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays, int nin)\n{\n int i, k;\n int maxrank=1;\n int *maxdims;\n PyObject *inputobj;\n PyArrayObject *ain, *tmparray;\n\n /* Convert nested sequences to arrays or just increase reference count\n if already an array */\n for (i=0; i < nin; i++) {\n ain = NULL;\n inputobj = PyTuple_GET_ITEM(inputs,i);\n ain = (PyArrayObject *)PyArray_FromObject(inputobj,PyArray_ObjectType(inputobj,0),0,0);\n if (NULL == ain) {\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if (PyArray_SIZE(ain)==0) {\n cleanup_arrays(inputarrays,i);\n PyErr_SetString(PyExc_ValueError,\"arraymap: Input arrays of zero-dimensions not supported.\");\n return -1;\n }\n if (ain->nd > maxrank) maxrank = ain->nd;\n if (ain->nd == 0) { /* turn into 1-d array */\n /* convert to rank-1 array */\n if ((ain->dimensions = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n return -1;\n }\n if ((ain->strides = (int *)malloc(sizeof(int))) == NULL) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,i);\n free(ain->dimensions);\n return -1;\n }\n ain->nd = 1;\n ain->dimensions[0] = 1;\n ain->strides[0] = ain->descr->elsize;\n }\n inputarrays[i] = ain;\n }\n\n maxdims = (int*)malloc(2*sizeof(int)*maxrank);\n if (NULL == maxdims) {\n PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n\n\n /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */\n /* We want to replace the header information without copying the data. \n Keeping the reference count correct can be tricky.\n We want to make a new array object with a different header and decrease the \n reference count of the old one without deallocating the data section */\n for (i=0; i < nin; i++) {\n ain = inputarrays[i];\n\n /* Initialize all dimensions to 1 */\n /* Change array shape */\n for (k=0; k < maxrank; k++) \n maxdims[k] = 1; \n for (k=maxrank-ain->nd; k< maxrank; k++) \n maxdims[k] = ain->dimensions[k-maxrank+ain->nd];\n\n tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);\n if (NULL == tmparray) {\n free(maxdims);\n cleanup_arrays(inputarrays,nin);\n return -1;\n }\n memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);\n tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */\n inputarrays[i] = tmparray; /* tmparray is new array */\n }\n\n /* Find dimension length for the output arrays (maximum length for each\n dimension) */\n for (k=0; k < maxrank; k++) { \n maxdims[k] = 1;\n for (i=0; i < nin; i++) \n if (inputarrays[i]->dimensions[k] > maxdims[k])\n\tmaxdims[k] = inputarrays[i]->dimensions[k];\n }\n\n /* Now set all lengths for input array dimensions to maxdims \n and make strides equal to zero for arrays whose\n real length is 1 for a particular dimension\n */\n\n for (i=0; idimensions[k]) {\n\tain->strides[k] = 0;\n\tain->dimensions[k] = maxdims[k];\n }\n else if (ain->dimensions[k] != maxdims[k]) {\n\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");\n\tcleanup_arrays(inputarrays,nin);\n\tfree(maxdims);\n\treturn -1;\n }\n }\n }\n\n free(maxdims);\n return 0;\n\n}\n\nstatic int type_from_object(PyObject *obj)\n{\n if (PyArray_Check(obj))\n return ((PyArrayObject *)obj)->descr->type_num;\n if (PyComplex_Check(obj)) return PyArray_CDOUBLE;\n if (PyFloat_Check(obj)) return PyArray_DOUBLE;\n if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");\n return -1;\n}\n\nstatic int type_from_char(char typechar)\n{\n switch(typechar) {\n case 'c': return PyArray_CHAR;\n case 'b': return PyArray_UBYTE;\n case '1': return PyArray_SBYTE;\n case 's': return PyArray_SHORT;\n case 'i': return PyArray_INT;\n#ifdef PyArray_UNSIGNED_TYPES\n case 'w': return PyArray_USHORT;\n case 'u': return PyArray_UINT;\n#endif\n case 'l': return PyArray_LONG;\n case 'f': return PyArray_FLOAT;\n case 'd': return PyArray_DOUBLE;\n case 'F': return PyArray_CFLOAT;\n case 'D': return PyArray_CDOUBLE;\n default:\n PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");\n return -1;\n }\n}\n\n\n\n/* This sets up the output arrays by calling the function with arguments \n the first element of each input arrays. If otypes is NULL, the\n returned value type is used to establish the type of the output\n arrays, otherwise the characters in otypes determine the\n output types */\nstatic int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)\n{\n PyObject *arglist, *result;\n PyObject *tmpobject;\n PyArrayObject *tmparr;\n int i, nout;\n int nd, *dimensions, type_num;\n\n nd = inarr[0]->nd;\n dimensions = inarr[0]->dimensions;\n\n if ((numtypes == 0) || (otypes == NULL)) { \n /* Call function to get number of outputs */\n\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n return -1;\n }\n /* Construct input argument by creating a tuple with an element\n from each input array (cast to an appropriate Python Object) */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Get first data point */\n tmpobject = tmparr->descr->getitem((void *)tmparr->data);\n if (NULL == tmpobject) {\n\tPy_DECREF(arglist);\n\treturn -1;\n }\n PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */\n } \n /* Call Python Function */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n return -1;\n }\n\n Py_DECREF(arglist);\n\n /* If result is a tuple, create output_arrays according \n to output. */\n if (PyTuple_Check(result)) {\n nout = PyTuple_GET_SIZE(result);\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL == *outarr) {\n\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n /* Create nout output arrays */\n for (i=0; i < nout; i++) {\n\t/* Determine type */\n\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n\t/* Create output array */\n\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n\tif (NULL == (*outarr)[i]) {\n\t cleanup_arrays(*outarr,i);\n\t Py_DECREF(result);\n\t free(*outarr);\n\t return -1;\n\t}\n }\n }\n else { /* Only a single output result */\n nout = 1;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n\tPy_DECREF(result);\n\treturn -1;\n }\n if ((type_num = type_from_object(result))==-1) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[0]) {\n\tPy_DECREF(result);\n\tfree(*outarr);\n\treturn -1;\n }\n }\n Py_DECREF(result);\n }\n\n else { /* Character output types entered */\n nout = numtypes;\n *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));\n if (NULL==*outarr) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");\n return -1;\n }\n /* Create Output arrays */\n for (i=0; i < nout; i++) {\n /* Get type */\n if ((type_num = type_from_char(otypes[i]))==-1) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n /* Create array */\n (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);\n if (NULL == (*outarr)[i]) {\n\tcleanup_arrays(*outarr,i);\n\tfree(*outarr);\n\treturn -1;\n }\n } \n } \n return nout;\n}\n\n\n/* Corresponding dimensions are assumed to match, check before calling. */\n/* No rank-0 arrays (make them rank-1 arrays) */\n\n/* This replicates the standard Ufunc broadcasting rule that if the\n dimension length is one, incrementing does not occur for that dimension. \n\n This is currently done by setting the stride in that dimension to\n zero during input array setup.\n\n The purpose of this function is to perform a for loop over arbitrary\n discontiguous N-D arrays, call the Python function for each set of \n corresponding elements and place the results in the output_array.\n*/ \n#define INCREMENT(ret_ind, nd, max_ind) \\\n{ \\\n int k; \\\n k = (nd) - 1; \\\n if (++(ret_ind)[k] >= (max_ind)[k]) { \\\n while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\\n (ret_ind)[k--] = 0; \\\n if (k >= 0) (ret_ind)[k]++; \\\n else (ret_ind)[0] = (max_ind)[0]; \\\n } \\\n}\n\n#define CALCINDEX(indx, nd_index, strides, ndim) \\\n{ \\\n int i; \\\n \\\n indx = 0; \\\n for (i=0; i < (ndim); i++) \\\n indx += (nd_index)[i]*(strides)[i]; \\\n} \n\nstatic int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)\n{\n int i, loop_index;\n int *nd_index, indx_in, indx_out;\n PyArrayObject *in, *out, *tmparr;\n PyObject *result, *tmpobj, *arglist;\n\n in = inarr[0]; /* For any shape information needed */\n out = outarr[0];\n /* Allocate the N-D index initalized to zero. */\n nd_index = (int *)calloc(in->nd,sizeof(int));\n if (NULL == nd_index) {\n PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");\n return -1;\n }\n /* Build argument list */\n if ((arglist = PyTuple_New(nin)) == NULL) {\n free(nd_index);\n return -1;\n }\n\n loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */\n\n while(loop_index--) { \n /* Create input argument list with current element from the input\n arrays \n */\n for (i=0; i < nin; i++) {\n tmparr = inarr[i];\n /* Find linear index into this input array */\n CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);\n /* Get object at this index */\n tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));\n if (NULL == tmpobj) {\n\tPy_DECREF(arglist);\n\tfree(nd_index);\n\treturn -1;\n }\n /* This steals reference of tmpobj */\n PyTuple_SET_ITEM(arglist, i, tmpobj); \n }\n /* Call Python Function for this set of inputs */\n if ((result=PyEval_CallObject(func, arglist))==NULL) {\n Py_DECREF(arglist);\n free(nd_index);\n return -1;\n } \n\n /* Find index into (all) output arrays */\n CALCINDEX(indx_out,nd_index,out->strides,out->nd);\n\n /* Copy the results to the output arrays */\n if (1==nout) {\n if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {\n\tfree(nd_index);\n\tPy_DECREF(arglist);\n\tPy_DECREF(result);\n\treturn -1;\n }\n }\n else if (PyTuple_Check(result)) {\n for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {\n\t free(nd_index);\n\t Py_DECREF(arglist);\n\t Py_DECREF(result);\n return -1;\n\t}\n }\n }\n else { \n PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");\n free(nd_index);\n Py_DECREF(arglist);\n Py_DECREF(result);\n return -1;\n }\n\n /* Increment the index counter */\n INCREMENT(nd_index,in->nd,in->dimensions);\n Py_DECREF(result);\n\n }\n Py_DECREF(arglist);\n free(nd_index);\n return 0;\n} \n\nstatic PyObject *build_output(PyArrayObject **outarr,int nout)\n{\n int i;\n PyObject *out;\n\n if (1==nout) return PyArray_Return(outarr[0]);\n if ((out=PyTuple_New(nout))==NULL) return NULL;\n for (i=0; i 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Genearlized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n try:\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n except IndexError:\n return self.zerocall(*args)\n\n def zerocall(self,*args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n # get it from self.otypes if possible\n # otherwise evaluate function at 0.9\n N = len(self.otypes)\n if N==1:\n return zeros((0,),'d')\n elif N !=0:\n return (zeros((0,),'d'),)*N\n newargs = []\n args = atleast_1d(args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(0.9)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n try:\n res = self.thefunc(*newargs)\n except:\n raise ValueError, \"Zerocall is failing. \"\\\n \"Try using otypes in vectorize.\"\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import ravel, asarray, nonzero, array, choose, ones, zeros, sometrue, alltrue\nfrom type_check import ScalarType\nfrom shape_base import squeeze, atleast_1d\nfrom fastumath import PINF as inf\nfrom fastumath import *\nimport _compiled_base\n\n__all__ = ['round','any','all','logspace','linspace','fix','mod',\n 'select','trim_zeros','amax','amin','ptp','cumsum',\n 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite']\n\nround = Numeric.around\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if not all(isfinite(x)):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\ndef any(x):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return sometrue(ravel(x))\n\n\ndef all(x):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return alltrue(ravel(x))\n\n# Need this to change array type for low precision values\ndef sum(x,axis=0): # could change default axis here\n x = asarray(x)\n if x.typecode() in ['1','s','b','w']:\n x = x.astype('l')\n return Numeric.sum(x,axis)\n \n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n return Numeric.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = Numeric.asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n\ndef mod(x,y):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n return x - y*Numeric.floor(x*1.0/y)\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice matrices (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\n# Basic operations\ndef amax(m,axis=-1):\n \"\"\"Returns the maximum of m along dimension axis. \n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return maximum.reduce(m,axis)\n\ndef amin(m,axis=-1):\n \"\"\"Returns the minimum of m along dimension axis.\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else: \n m = asarray(m)\n return minimum.reduce(m,axis)\n\n# Actually from Basis, but it fits in so naturally here...\n\ndef ptp(m,axis=-1):\n \"\"\"Returns the maximum - minimum along the the given dimension\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return amax(m,axis)-amin(m,axis)\n\ndef cumsum(m,axis=-1):\n \"\"\"Returns the cumulative sum of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return add.accumulate(m,axis)\n\ndef prod(m,axis=-1):\n \"\"\"Returns the product of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return multiply.reduce(m,axis)\n\ndef cumprod(m,axis=-1):\n \"\"\"Returns the cumulative product of the elments along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return multiply.accumulate(m,axis)\n\ndef diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n x = asarray(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Genearlized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n for arg in args:\n try:\n n = len(arg)\n if (n==0):\n return self.zerocall(args)\n except (AttributeError, TypeError):\n pass\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n\n def zerocall(self,args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n newargs = []\n args = atleast_1d(*args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(1.1)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n res = self.thefunc(*newargs)\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "methods": [ { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 19, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 27, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 33, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 46, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 61, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "x" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "x", "y" ], "start_line": 86, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 94, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 143, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 153, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "m", "axis" ], "start_line": 165, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumsum", "long_name": "cumsum( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 185, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 195, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 11, "complexity": 2, "token_count": 110, "parameters": [ "x", "n", "axis" ], "start_line": 205, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 71, "parameters": [ "z", "deg" ], "start_line": 220, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 235, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 256, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "a" ], "start_line": 252, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 12, "complexity": 9, "token_count": 87, "parameters": [ "filt", "trim" ], "start_line": 265, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 286, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 294, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 306, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 313, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 45, "parameters": [ "x", "axis" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 333, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 355, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 399, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 415, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 421, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 } ], "methods_before": [ { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 19, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 27, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 33, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 46, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 61, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "x" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "x", "y" ], "start_line": 86, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 94, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 143, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 153, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "m", "axis" ], "start_line": 165, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumsum", "long_name": "cumsum( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 185, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 195, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 11, "complexity": 2, "token_count": 110, "parameters": [ "x", "n", "axis" ], "start_line": 205, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 71, "parameters": [ "z", "deg" ], "start_line": 220, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 235, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 256, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "a" ], "start_line": 252, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 12, "complexity": 9, "token_count": 87, "parameters": [ "filt", "trim" ], "start_line": 265, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 286, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 294, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 306, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 313, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 45, "parameters": [ "x", "axis" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 333, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 355, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 399, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 9, "complexity": 4, "token_count": 59, "parameters": [ "self", "args" ], "start_line": 415, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , args )", "filename": "function_base.py", "nloc": 14, "complexity": 4, "token_count": 102, "parameters": [ "self", "args" ], "start_line": 425, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 421, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 415, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , args )", "filename": "function_base.py", "nloc": 14, "complexity": 4, "token_count": 102, "parameters": [ "self", "args" ], "start_line": 425, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 292, "complexity": 82, "token_count": 2131, "diff_parsed": { "added": [ "from type_check import ScalarType, isscalar", " try:", " return squeeze(arraymap(self.thefunc,args,self.otypes))", " except IndexError:", " return self.zerocall(*args)", "", " def zerocall(self,*args):", " # get it from self.otypes if possible", " # otherwise evaluate function at 0.9", " N = len(self.otypes)", " if N==1:", " return zeros((0,),'d')", " elif N !=0:", " return (zeros((0,),'d'),)*N", " args = atleast_1d(args)", " newargs.append(0.9)", " try:", " res = self.thefunc(*newargs)", " except:", " raise ValueError, \"Zerocall is failing. \"\\", " \"Try using otypes in vectorize.\"" ], "deleted": [ "from type_check import ScalarType", " for arg in args:", " try:", " n = len(arg)", " if (n==0):", " return self.zerocall(args)", " except (AttributeError, TypeError):", " pass", " return squeeze(arraymap(self.thefunc,args,self.otypes))", "", " def zerocall(self,args):", " args = atleast_1d(*args)", " newargs.append(1.1)", " res = self.thefunc(*newargs)" ] } } ] }, { "hash": "0c183d5a528b87f6deeb6e54c4321dabc8d02df0", "msg": "When running tests locally, use the script instead of installed test_yyy module.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-27T09:03:16+00:00", "author_timezone": 0, "committer_date": "2003-11-27T09:03:16+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c4f81c2baba836f4ac1fcca69d348f3ad3415dbe" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 0, "insertions": 9, "lines": 9, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -181,10 +181,19 @@ def _get_method_names(self,clsobj,level):\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n+\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n \n+ local_test_dir = os.path.join(os.getcwd(),'tests')\n+ local_test_file = os.path.join(local_test_dir,\n+ 'test_'+short_module_name+'.py')\n+ if os.path.basename(os.path.dirname(local_test_dir)) \\\n+ == os.path.basename(os.path.dirname(test_dir)) \\\n+ and os.path.isfile(local_test_file):\n+ test_file = local_test_file\n+\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n", "added_lines": 9, "deleted_lines": 0, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in dir(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name,\n f, test_file,('.py', 'r', 1))\n f.close()\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = equal(x,y)\n assert alltrue(ravel(reduced)),\\\n msg + ':\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = equal(around(abs(x-y),decimal),0)\n assert alltrue(ravel(reduced)),\\\n msg + ':\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "source_code_before": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in dir(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name,\n f, test_file,('.py', 'r', 1))\n f.close()\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = equal(x,y)\n assert alltrue(ravel(reduced)),\\\n msg + ':\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = equal(around(abs(x-y),decimal),0)\n assert alltrue(ravel(reduced)),\\\n msg + ':\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "methods": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 18, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 50, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 67, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 71, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 83, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 109, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 150, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 159, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 47, "complexity": 11, "token_count": 378, "parameters": [ "self", "module", "level" ], "start_line": 181, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 235, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 248, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 273, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 299, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 307, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 329, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 368, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 405, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 414, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 452, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 482, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 514, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 531, "end_line": 545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 548, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 12, "complexity": 2, "token_count": 92, "parameters": [ "x", "y", "err_msg" ], "start_line": 579, "end_line": 590, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 15, "complexity": 2, "token_count": 113, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 593, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 610, "end_line": 619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 621, "end_line": 631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 18, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 50, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 67, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 71, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 83, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 109, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 150, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 159, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 40, "complexity": 9, "token_count": 299, "parameters": [ "self", "module", "level" ], "start_line": 181, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 226, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 239, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 264, "end_line": 286, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 290, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 298, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 320, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 359, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 396, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 405, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 443, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 473, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 505, "end_line": 519, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 522, "end_line": 536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 539, "end_line": 566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 12, "complexity": 2, "token_count": 92, "parameters": [ "x", "y", "err_msg" ], "start_line": 570, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 15, "complexity": 2, "token_count": 113, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 584, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 601, "end_line": 610, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 612, "end_line": 622, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 47, "complexity": 11, "token_count": 378, "parameters": [ "self", "module", "level" ], "start_line": 181, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 } ], "nloc": 438, "complexity": 102, "token_count": 3059, "diff_parsed": { "added": [ "", " local_test_dir = os.path.join(os.getcwd(),'tests')", " local_test_file = os.path.join(local_test_dir,", " 'test_'+short_module_name+'.py')", " if os.path.basename(os.path.dirname(local_test_dir)) \\", " == os.path.basename(os.path.dirname(test_dir)) \\", " and os.path.isfile(local_test_file):", " test_file = local_test_file", "" ], "deleted": [] } } ] }, { "hash": "34a3c3caa98cb1709a75eecf4059daa455004a6c", "msg": "Backport mingw support to older distutils link command that does not have target_lang argument.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-04T09:26:16+00:00", "author_timezone": 0, "committer_date": "2003-12-04T09:26:16+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0c183d5a528b87f6deeb6e54c4321dabc8d02df0" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 28, "insertions": 17, "lines": 45, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.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": "@@ -118,36 +118,25 @@ def link(self,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n+ args = (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+ target_lang)\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- target_lang)\n+ func = distutils.cygwinccompiler.CygwinCCompiler.link\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- target_lang)\n+ func = UnixCCompiler.link\n+ func(*args[:func.im_func.func_code.co_argcount])\n \n def object_filenames (self,\n source_filenames,\n", "added_lines": 17, "deleted_lines": 28, "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 # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \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 export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (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 target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\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 distutils.ccompiler._default_compilers\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", "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 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 # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \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 export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\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 target_lang)\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 target_lang)\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\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 distutils.ccompiler._default_compilers\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", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 141, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 189, "end_line": 197, "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": 199, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 44, "complexity": 2, "token_count": 120, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 152, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 200, "end_line": 208, "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": 210, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 2 } ], "nloc": 149, "complexity": 23, "token_count": 874, "diff_parsed": { "added": [ " args = (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,", " target_lang)", " func = distutils.cygwinccompiler.CygwinCCompiler.link", " func = UnixCCompiler.link", " func(*args[:func.im_func.func_code.co_argcount])" ], "deleted": [ " 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,", " target_lang)", " 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,", " target_lang)" ] } } ] }, { "hash": "15a8c04d488e7fb362307165b2f98bba3a8a298b", "msg": "Show parts of arrays if assert_array_*equal fails", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-04T11:08:48+00:00", "author_timezone": 0, "committer_date": "2003-12-04T11:08:48+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "34a3c3caa98cb1709a75eecf4059daa455004a6c" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 7, "insertions": 24, "lines": 31, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -9,7 +9,8 @@\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n- from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray\n+ from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n+ less_equal,array2string\n import scipy_base.fastumath as math\n except ImportError:\n pass\n@@ -582,9 +583,17 @@ def assert_array_equal(x,y,err_msg=''):\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n- reduced = equal(x,y)\n- assert alltrue(ravel(reduced)),\\\n- msg + ':\\n\\t' + err_msg\n+ reduced = ravel(equal(x,y))\n+ cond = alltrue(reduced)\n+ if not cond:\n+ s1 = array2string(x,precision=16)\n+ s2 = array2string(y,precision=16)\n+ if len(s1)>120: s1 = s1[:120] + '...'\n+ if len(s2)>120: s2 = s2[:120] + '...'\n+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n+ msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n+ assert cond,\\\n+ msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n@@ -597,9 +606,17 @@ def assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n- reduced = equal(around(abs(x-y),decimal),0)\n- assert alltrue(ravel(reduced)),\\\n- msg + ':\\n\\t' + err_msg\n+ reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n+ cond = alltrue(reduced)\n+ if not cond:\n+ s1 = array2string(x,precision=decimal+1)\n+ s2 = array2string(y,precision=decimal+1)\n+ if len(s1)>120: s1 = s1[:120] + '...'\n+ if len(s2)>120: s2 = s2[:120] + '...'\n+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n+ msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n+ assert cond,\\\n+ msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n", "added_lines": 24, "deleted_lines": 7, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in dir(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name,\n f, test_file,('.py', 'r', 1))\n f.close()\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "source_code_before": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in dir(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name,\n f, test_file,('.py', 'r', 1))\n f.close()\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = equal(x,y)\n assert alltrue(ravel(reduced)),\\\n msg + ':\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = equal(around(abs(x-y),decimal),0)\n assert alltrue(ravel(reduced)),\\\n msg + ':\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "methods": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 19, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 51, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 110, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 160, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 47, "complexity": 11, "token_count": 378, "parameters": [ "self", "module", "level" ], "start_line": 182, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 236, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 249, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 274, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 300, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 308, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 330, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 369, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 406, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 415, "end_line": 450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 453, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 483, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 515, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 532, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 549, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 580, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 602, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 627, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 638, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 18, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 50, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 67, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 71, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 83, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 109, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 150, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 159, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 47, "complexity": 11, "token_count": 378, "parameters": [ "self", "module", "level" ], "start_line": 181, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 235, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 248, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 273, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 299, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 307, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 329, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 368, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 405, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 414, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 452, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 482, "end_line": 504, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 514, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 531, "end_line": 545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 548, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 12, "complexity": 2, "token_count": 92, "parameters": [ "x", "y", "err_msg" ], "start_line": 579, "end_line": 590, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 15, "complexity": 2, "token_count": 113, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 593, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 610, "end_line": 619, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 621, "end_line": 631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 602, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 580, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "nloc": 455, "complexity": 108, "token_count": 3274, "diff_parsed": { "added": [ " from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\", " less_equal,array2string", " reduced = ravel(equal(x,y))", " cond = alltrue(reduced)", " if not cond:", " s1 = array2string(x,precision=16)", " s2 = array2string(y,precision=16)", " if len(s1)>120: s1 = s1[:120] + '...'", " if len(s2)>120: s2 = s2[:120] + '...'", " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", " assert cond,\\", " msg + '\\n\\t' + err_msg", " reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))", " cond = alltrue(reduced)", " if not cond:", " s1 = array2string(x,precision=decimal+1)", " s2 = array2string(y,precision=decimal+1)", " if len(s1)>120: s1 = s1[:120] + '...'", " if len(s2)>120: s2 = s2[:120] + '...'", " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", " assert cond,\\", " msg + '\\n\\t' + err_msg" ], "deleted": [ " from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray", " reduced = equal(x,y)", " assert alltrue(ravel(reduced)),\\", " msg + ':\\n\\t' + err_msg", " reduced = equal(around(abs(x-y),decimal),0)", " assert alltrue(ravel(reduced)),\\", " msg + ':\\n\\t' + err_msg" ] } } ] }, { "hash": "81d8c691f1da9cd488ab381e85218c42c42d3ba6", "msg": "Workaround for Python 2.1 .pyc file generator bug (float constants are truncated, e.g. 1.0066800127055 becomes 1.00668001271 in a .pyc file)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-04T11:38:58+00:00", "author_timezone": 0, "committer_date": "2003-12-04T11:38:58+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "15a8c04d488e7fb362307165b2f98bba3a8a298b" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 2, "insertions": 10, "lines": 12, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -201,11 +201,19 @@ def _get_module_tests(self,module,level):\n return []\n \n try:\n+ if sys.version[:3]=='2.1':\n+ # Workaround for Python 2.1 .pyc file generator bug\n+ import random\n+ pref = '-nopyc'+`random.randint(1,100)`\n+ else:\n+ pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n- module.__name__+'.test_'+short_module_name,\n- f, test_file,('.py', 'r', 1))\n+ module.__name__+'.test_'+short_module_name+pref,\n+ f, test_file+pref,('.py', 'r', 1))\n f.close()\n+ if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n+ os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n", "added_lines": 10, "deleted_lines": 2, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in dir(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "source_code_before": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in dir(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name,\n f, test_file,('.py', 'r', 1))\n f.close()\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "methods": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 19, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 51, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 110, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 160, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 54, "complexity": 14, "token_count": 448, "parameters": [ "self", "module", "level" ], "start_line": 182, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 244, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 257, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 282, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 308, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 316, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 338, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 377, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 414, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 423, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 461, "end_line": 488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 491, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 523, "end_line": 537, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 540, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 557, "end_line": 584, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 588, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 610, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 635, "end_line": 644, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 646, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 19, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 51, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 110, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 160, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 47, "complexity": 11, "token_count": 378, "parameters": [ "self", "module", "level" ], "start_line": 182, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 236, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 249, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 274, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 300, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 308, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 330, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 369, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 406, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 415, "end_line": 450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 453, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 483, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 515, "end_line": 529, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 532, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 549, "end_line": 576, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 580, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 602, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 627, "end_line": 636, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 638, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 54, "complexity": 14, "token_count": 448, "parameters": [ "self", "module", "level" ], "start_line": 182, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 } ], "nloc": 462, "complexity": 111, "token_count": 3344, "diff_parsed": { "added": [ " if sys.version[:3]=='2.1':", " # Workaround for Python 2.1 .pyc file generator bug", " import random", " pref = '-nopyc'+`random.randint(1,100)`", " else:", " pref = ''", " module.__name__+'.test_'+short_module_name+pref,", " f, test_file+pref,('.py', 'r', 1))", " if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):", " os.remove(test_file+pref+'c')" ], "deleted": [ " module.__name__+'.test_'+short_module_name,", " f, test_file,('.py', 'r', 1))" ] } } ] }, { "hash": "2f11b19ef8c2a4aa488f0ebf6fbb315ba3b6e3eb", "msg": "Updated scipy complex divide so that 1j/0.0 returns infj instead of nan+infj", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-12-10T16:19:02+00:00", "author_timezone": 0, "committer_date": "2003-12-10T16:19:02+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "81d8c691f1da9cd488ab381e85218c42c42d3ba6" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 20, "insertions": 10, "lines": 30, "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": "@@ -313,16 +313,11 @@ static Py_complex c_quot_fast(Py_complex a, Py_complex b)\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+ r.real = a.real / b.real;\n+ r.imag = a.imag / b.imag;\n+ if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n+ else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n+ return r;\n }\n \n if (abs_breal >= abs_bimag) {\n", "added_lines": 5, "deleted_lines": 10, "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 r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n return 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, (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": [ " r.real = a.real / b.real;", " r.imag = a.imag / b.imag;", " if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}", " else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}", " return r;" ], "deleted": [ "\tr.real = a.real / b.real;", "\tr.imag = a.imag / b.imag;", "/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */", "/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */", "/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */", "", "/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */", "/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */", "/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */", "\treturn r;" ] } }, { "old_path": "scipy_base/fastumath_unsigned.inc", "new_path": "scipy_base/fastumath_unsigned.inc", "filename": "fastumath_unsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -324,16 +324,11 @@ static Py_complex c_quot_fast(Py_complex a, Py_complex b)\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+ r.real = a.real / b.real;\n+ r.imag = a.imag / b.imag;\n+ if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n+ else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n+ return r;\n }\n if (abs_breal >= abs_bimag) {\n \t/* divide tops and bottom by b.real */\n", "added_lines": 5, "deleted_lines": 10, "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 r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n return 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, CFLOAT_maximum, CDOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_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, 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, CFLOAT_maximum, CDOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_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, 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", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ " r.real = a.real / b.real;", " r.imag = a.imag / b.imag;", " if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}", " else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}", " return r;" ], "deleted": [ "\tr.real = a.real / b.real;", "\tr.imag = a.imag / b.imag;", "/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */", "/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */", "/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */", "", "/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */", "/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */", "/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */", "\treturn r;" ] } } ] }, { "hash": "7f5e051feea78f8c72bc8d8597ecc406afb0cf22", "msg": "Using faster implementation of Numeric.asarray.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-13T13:42:10+00:00", "author_timezone": 0, "committer_date": "2003-12-13T13:42:10+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "2f11b19ef8c2a4aa488f0ebf6fbb315ba3b6e3eb" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 42, "insertions": 59, "lines": 101, "files": 7, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_base/function_base.py", "new_path": "scipy_base/function_base.py", "filename": "function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,8 +1,9 @@\n \n import types\n import Numeric\n-from Numeric import ravel, asarray, nonzero, array, choose, ones, zeros, sometrue, alltrue\n-from type_check import ScalarType, isscalar\n+from Numeric import ravel, nonzero, array, choose, ones, zeros, \\\n+ sometrue, alltrue\n+from type_check import ScalarType, isscalar, asarray\n from shape_base import squeeze, atleast_1d\n from fastumath import PINF as inf\n from fastumath import *\n@@ -79,7 +80,7 @@ def linspace(start,stop,num=50,endpoint=1,retstep=0):\n def fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n \n@@ -319,21 +320,21 @@ def insert(arr, mask, vals):\n def nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n- x = Numeric.asarray(x).copy()\n+ x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n \n def nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n- x = Numeric.asarray(x).copy()\n+ x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n \n def nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n- x = Numeric.asarray(x).copy()\n+ x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n", "added_lines": 7, "deleted_lines": 6, "source_code": "\nimport types\nimport Numeric\nfrom Numeric import ravel, nonzero, array, choose, ones, zeros, \\\n sometrue, alltrue\nfrom type_check import ScalarType, isscalar, asarray\nfrom shape_base import squeeze, atleast_1d\nfrom fastumath import PINF as inf\nfrom fastumath import *\nimport _compiled_base\n\n__all__ = ['round','any','all','logspace','linspace','fix','mod',\n 'select','trim_zeros','amax','amin','ptp','cumsum',\n 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite']\n\nround = Numeric.around\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if not all(isfinite(x)):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\ndef any(x):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return sometrue(ravel(x))\n\n\ndef all(x):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return alltrue(ravel(x))\n\n# Need this to change array type for low precision values\ndef sum(x,axis=0): # could change default axis here\n x = asarray(x)\n if x.typecode() in ['1','s','b','w']:\n x = x.astype('l')\n return Numeric.sum(x,axis)\n \n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n return Numeric.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n\ndef mod(x,y):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n return x - y*Numeric.floor(x*1.0/y)\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice matrices (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\n# Basic operations\ndef amax(m,axis=-1):\n \"\"\"Returns the maximum of m along dimension axis. \n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return maximum.reduce(m,axis)\n\ndef amin(m,axis=-1):\n \"\"\"Returns the minimum of m along dimension axis.\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else: \n m = asarray(m)\n return minimum.reduce(m,axis)\n\n# Actually from Basis, but it fits in so naturally here...\n\ndef ptp(m,axis=-1):\n \"\"\"Returns the maximum - minimum along the the given dimension\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return amax(m,axis)-amin(m,axis)\n\ndef cumsum(m,axis=-1):\n \"\"\"Returns the cumulative sum of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return add.accumulate(m,axis)\n\ndef prod(m,axis=-1):\n \"\"\"Returns the product of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return multiply.reduce(m,axis)\n\ndef cumprod(m,axis=-1):\n \"\"\"Returns the cumulative product of the elments along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return multiply.accumulate(m,axis)\n\ndef diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n x = asarray(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Genearlized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n try:\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n except IndexError:\n return self.zerocall(*args)\n\n def zerocall(self,*args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n # get it from self.otypes if possible\n # otherwise evaluate function at 0.9\n N = len(self.otypes)\n if N==1:\n return zeros((0,),'d')\n elif N !=0:\n return (zeros((0,),'d'),)*N\n newargs = []\n args = atleast_1d(args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(0.9)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n try:\n res = self.thefunc(*newargs)\n except:\n raise ValueError, \"Zerocall is failing. \"\\\n \"Try using otypes in vectorize.\"\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import ravel, asarray, nonzero, array, choose, ones, zeros, sometrue, alltrue\nfrom type_check import ScalarType, isscalar\nfrom shape_base import squeeze, atleast_1d\nfrom fastumath import PINF as inf\nfrom fastumath import *\nimport _compiled_base\n\n__all__ = ['round','any','all','logspace','linspace','fix','mod',\n 'select','trim_zeros','amax','amin','ptp','cumsum',\n 'prod','cumprod','diff','angle','unwrap','sort_complex',\n 'disp','unique','extract','insert','nansum','nanmax','nanargmax',\n 'nanargmin','nanmin','sum','vectorize','asarray_chkfinite']\n\nround = Numeric.around\n\ndef asarray_chkfinite(x):\n \"\"\"Like asarray except it checks to be sure no NaNs or Infs are present.\n \"\"\"\n x = asarray(x)\n if not all(isfinite(x)):\n raise ValueError, \"Array must not contain infs or nans.\"\n return x \n\ndef any(x):\n \"\"\"Return true if any elements of x are true: sometrue(ravel(x))\n \"\"\"\n return sometrue(ravel(x))\n\n\ndef all(x):\n \"\"\"Return true if all elements of x are true: alltrue(ravel(x))\n \"\"\"\n return alltrue(ravel(x))\n\n# Need this to change array type for low precision values\ndef sum(x,axis=0): # could change default axis here\n x = asarray(x)\n if x.typecode() in ['1','s','b','w']:\n x = x.astype('l')\n return Numeric.sum(x,axis)\n \n\ndef logspace(start,stop,num=50,endpoint=1):\n \"\"\" Evenly spaced samples on a logarithmic scale.\n\n Return num evenly spaced samples from 10**start to 10**stop. If\n endpoint=1 then last sample is 10**stop.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start\n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n return Numeric.power(10.0,y)\n\ndef linspace(start,stop,num=50,endpoint=1,retstep=0):\n \"\"\" Evenly spaced samples.\n \n Return num evenly spaced samples from start to stop. If endpoint=1 then\n last sample is stop. If retstep is 1 then return the step value used.\n \"\"\"\n if num <= 0: return array([])\n if endpoint:\n step = (stop-start)/float((num-1))\n y = Numeric.arange(0,num) * step + start \n else:\n step = (stop-start)/float(num)\n y = Numeric.arange(0,num) * step + start\n if retstep:\n return y, step\n else:\n return y\n\ndef fix(x):\n \"\"\" Round x to nearest integer towards zero.\n \"\"\"\n x = Numeric.asarray(x)\n y = Numeric.floor(x)\n return Numeric.where(x<0,y+1,y)\n\ndef mod(x,y):\n \"\"\" x - y*floor(x/y)\n \n For numeric arrays, x % y has the same sign as x while\n mod(x,y) has the same sign as y.\n \"\"\"\n return x - y*Numeric.floor(x*1.0/y)\n\ndef select(condlist, choicelist, default=0):\n \"\"\" Returns an array comprised from different elements of choicelist\n depending on the list of conditions.\n\n condlist is a list of condition arrays containing ones or zeros\n \n choicelist is a list of choice matrices (of the \"same\" size as the\n arrays in condlist). The result array has the \"same\" size as the\n arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist\n must be of length N. The elements of the choicelist can then be\n represented as [v0,...,vN-1]. The default choice if none of the\n conditions are met is given as the default argument. \n \n The conditions are tested in order and the first one statisfied is\n used to select the choice. In other words, the elements of the\n output array are found from the following tree (notice the order of\n the conditions matters):\n \n if c0: v0\n elif c1: v1\n elif c2: v2\n ...\n elif cN-1: vN-1\n else: default\n \n Note, that one of the condition arrays must be large enough to handle\n the largest array in the choice list.\n \"\"\"\n n = len(condlist)\n n2 = len(choicelist)\n if n2 != n:\n raise ValueError, \"List of cases, must be same length as the list of conditions.\"\n choicelist.insert(0,default) \n S = 0\n pfac = 1\n for k in range(1,n+1):\n S += k * pfac * asarray(condlist[k-1])\n if k < n:\n pfac *= (1-asarray(condlist[k-1]))\n # handle special case of a 1-element condition but\n # a multi-element choice\n if type(S) in ScalarType or max(asarray(S).shape)==1:\n pfac = asarray(1)\n for k in range(n2+1):\n pfac = pfac + asarray(choicelist[k]) \n S = S*ones(asarray(pfac).shape)\n return choose(S, tuple(choicelist))\n\n# Basic operations\ndef amax(m,axis=-1):\n \"\"\"Returns the maximum of m along dimension axis. \n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return maximum.reduce(m,axis)\n\ndef amin(m,axis=-1):\n \"\"\"Returns the minimum of m along dimension axis.\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else: \n m = asarray(m)\n return minimum.reduce(m,axis)\n\n# Actually from Basis, but it fits in so naturally here...\n\ndef ptp(m,axis=-1):\n \"\"\"Returns the maximum - minimum along the the given dimension\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return amax(m,axis)-amin(m,axis)\n\ndef cumsum(m,axis=-1):\n \"\"\"Returns the cumulative sum of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return add.accumulate(m,axis)\n\ndef prod(m,axis=-1):\n \"\"\"Returns the product of the elements along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return multiply.reduce(m,axis)\n\ndef cumprod(m,axis=-1):\n \"\"\"Returns the cumulative product of the elments along the given axis\n \"\"\"\n if axis is None:\n m = ravel(m)\n axis = 0\n else:\n m = asarray(m)\n return multiply.accumulate(m,axis)\n\ndef diff(x, n=1,axis=-1):\n \"\"\"Calculates the nth order, discrete difference along given axis.\n \"\"\"\n x = asarray(x)\n nd = len(x.shape)\n slice1 = [slice(None)]*nd\n slice2 = [slice(None)]*nd\n slice1[axis] = slice(1,None)\n slice2[axis] = slice(None,-1)\n if n > 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n Numeric.putmask(ph_correct,abs(dd)>> import scipy\n >>> a = array((0,0,0,1,2,3,2,1,0))\n >>> scipy.trim_zeros(a)\n array([1, 2, 3, 2, 1])\n \"\"\"\n first = 0\n if 'f' in trim or 'F' in trim:\n for i in filt:\n if i != 0.: break\n else: first = first + 1\n last = len(filt)\n if 'b' in trim or 'B' in trim:\n for i in filt[::-1]:\n if i != 0.: break\n else: last = last - 1\n return filt[first:last]\n\ndef unique(inseq):\n \"\"\"Returns unique items in 1-dimensional sequence.\n \"\"\"\n set = {}\n for item in inseq:\n set[item] = None\n return asarray(set.keys())\n\ndef where(condition,x=None,y=None):\n \"\"\"If x and y are both None, then return the (1-d equivalent) indices\n where condition is true. Otherwise, return an array shaped like\n condition with elements of x and y in the places where condition is\n true or false respectively.\n \"\"\"\n if (x is None) and (y is None):\n # Needs work for multidimensional arrays\n return nonzero(ravel(condition))\n else:\n return choose(not_equal(condition, 0), (y,x))\n \ndef extract(condition, arr):\n \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)\n\n Equivalent of compress(ravel(condition), ravel(arr))\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(condition)))\n\ndef insert(arr, mask, vals):\n \"\"\"Similar to putmask arr[mask] = vals but 1d array vals has the\n same number of elements as the non-zero values of mask. Inverse of extract.\n \"\"\"\n return _compiled_base._insert(arr, mask, vals)\n\ndef nansum(x,axis=-1):\n \"\"\"Sum the array over the given axis treating nans as missing values.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),0)\n return Numeric.sum(x,axis)\n\ndef nanmin(x,axis=-1):\n \"\"\"Find the minimium over the given axis ignoring nans.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return amin(x,axis)\n\ndef nanargmin(x,axis=-1):\n \"\"\"Find the indices of the minimium over the given axis ignoring nans.\n \"\"\"\n x = Numeric.asarray(x).copy()\n Numeric.putmask(x,isnan(x),inf)\n return argmin(x,axis)\n \n\ndef nanmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return amax(x,axis)\n\ndef nanargmax(x,axis=-1):\n \"\"\"Find the maximum over the given axis ignoring nans.\n \"\"\"\n x = asarray(x).copy()\n Numeric.putmask(x,isnan(x),-inf)\n return argmax(x,axis)\n\ndef disp(mesg, device=None, linefeed=1):\n \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.\n \"\"\"\n if device is None:\n import sys\n device = sys.stdout\n if linefeed:\n device.write('%s\\n' % mesg)\n else:\n device.write('%s' % mesg)\n device.flush()\n return\n\nfrom _compiled_base import arraymap\nclass vectorize:\n \"\"\"\n vectorize(somefunction) Genearlized Function class.\n\n Description:\n \n Define a vectorized function which takes nested sequence\n objects or Numeric arrays as inputs and returns a\n Numeric array as output, evaluating the function over successive\n tuples of the input arrays like the python map function except it uses\n the broadcasting rules of Numeric Python.\n\n Input:\n\n somefunction -- a Python function or method\n\n Example:\n\n def myfunc(a,b):\n if a > b:\n return a-b\n else\n return a+b\n\n vfunc = vectorize(myfunc)\n\n >>> vfunc([1,2,3,4],2)\n array([3,4,1,2])\n\n \"\"\"\n def __init__(self,pyfunc,otypes=None,doc=None):\n if not callable(pyfunc) or type(pyfunc) is types.ClassType:\n raise TypeError, \"Object is not a callable Python object.\"\n self.thefunc = pyfunc\n if doc is None:\n self.__doc__ = pyfunc.__doc__\n else:\n self.__doc__ = doc\n if otypes is None:\n self.otypes=''\n else:\n if isinstance(otypes,types.StringType):\n self.otypes=otypes\n else:\n raise ValueError, \"Output types must be a string.\"\n\n def __call__(self,*args):\n try:\n return squeeze(arraymap(self.thefunc,args,self.otypes))\n except IndexError:\n return self.zerocall(*args)\n\n def zerocall(self,*args):\n # one of the args was a zeros array\n # return zeros for each output\n # first --- find number of outputs\n # get it from self.otypes if possible\n # otherwise evaluate function at 0.9\n N = len(self.otypes)\n if N==1:\n return zeros((0,),'d')\n elif N !=0:\n return (zeros((0,),'d'),)*N\n newargs = []\n args = atleast_1d(args)\n for arg in args:\n if arg.typecode() != 'O':\n newargs.append(0.9)\n else:\n newargs.append(arg[0])\n newargs = tuple(newargs)\n try:\n res = self.thefunc(*newargs)\n except:\n raise ValueError, \"Zerocall is failing. \"\\\n \"Try using otypes in vectorize.\"\n if isscalar(res):\n return zeros((0,),'d')\n else:\n return (zeros((0,),'d'),)*len(res)\n\n", "methods": [ { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 20, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 28, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 34, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 40, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 47, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 62, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "x" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "x", "y" ], "start_line": 87, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 95, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 144, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 154, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "m", "axis" ], "start_line": 166, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumsum", "long_name": "cumsum( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 176, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 186, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 196, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 11, "complexity": 2, "token_count": 110, "parameters": [ "x", "n", "axis" ], "start_line": 206, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 71, "parameters": [ "z", "deg" ], "start_line": 221, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 236, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 257, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "a" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 12, "complexity": 9, "token_count": 87, "parameters": [ "filt", "trim" ], "start_line": 266, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 287, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 295, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 307, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 314, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 320, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 327, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 342, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 349, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 356, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 400, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 416, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 422, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 } ], "methods_before": [ { "name": "asarray_chkfinite", "long_name": "asarray_chkfinite( x )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "x" ], "start_line": 19, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "any", "long_name": "any( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 27, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "all", "long_name": "all( x )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "x" ], "start_line": 33, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logspace", "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", "filename": "function_base.py", "nloc": 9, "complexity": 3, "token_count": 99, "parameters": [ "start", "stop", "num", "endpoint" ], "start_line": 46, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "linspace", "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", "filename": "function_base.py", "nloc": 12, "complexity": 4, "token_count": 103, "parameters": [ "start", "stop", "num", "endpoint", "retstep" ], "start_line": 61, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "x" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "mod", "long_name": "mod( x , y )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "x", "y" ], "start_line": 86, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "select", "long_name": "select( condlist , choicelist , default = 0 )", "filename": "function_base.py", "nloc": 18, "complexity": 7, "token_count": 165, "parameters": [ "condlist", "choicelist", "default" ], "start_line": 94, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 0 }, { "name": "amax", "long_name": "amax( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 143, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "amin", "long_name": "amin( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 153, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ptp", "long_name": "ptp( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "m", "axis" ], "start_line": 165, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumsum", "long_name": "cumsum( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "prod", "long_name": "prod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 185, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "cumprod", "long_name": "cumprod( m , axis = - 1 )", "filename": "function_base.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [ "m", "axis" ], "start_line": 195, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "diff", "long_name": "diff( x , n = 1 , axis = - 1 )", "filename": "function_base.py", "nloc": 11, "complexity": 2, "token_count": 110, "parameters": [ "x", "n", "axis" ], "start_line": 205, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "angle", "long_name": "angle( z , deg = 0 )", "filename": "function_base.py", "nloc": 13, "complexity": 3, "token_count": 71, "parameters": [ "z", "deg" ], "start_line": 220, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "unwrap", "long_name": "unwrap( p , discont = pi , axis = - 1 )", "filename": "function_base.py", "nloc": 13, "complexity": 1, "token_count": 150, "parameters": [ "p", "discont", "axis" ], "start_line": 235, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "sort_complex.complex_cmp", "long_name": "sort_complex.complex_cmp( x , y )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 38, "parameters": [ "x", "y" ], "start_line": 256, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "sort_complex", "long_name": "sort_complex( a )", "filename": "function_base.py", "nloc": 6, "complexity": 1, "token_count": 44, "parameters": [ "a" ], "start_line": 252, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "trim_zeros", "long_name": "trim_zeros( filt , trim = 'fb' )", "filename": "function_base.py", "nloc": 12, "complexity": 9, "token_count": 87, "parameters": [ "filt", "trim" ], "start_line": 265, "end_line": 284, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "unique", "long_name": "unique( inseq )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "inseq" ], "start_line": 286, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "where", "long_name": "where( condition , x = None , y = None )", "filename": "function_base.py", "nloc": 5, "complexity": 3, "token_count": 53, "parameters": [ "condition", "x", "y" ], "start_line": 294, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( condition , arr )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "condition", "arr" ], "start_line": 306, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "insert", "long_name": "insert( arr , mask , vals )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "arr", "mask", "vals" ], "start_line": 313, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 45, "parameters": [ "x", "axis" ], "start_line": 319, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 326, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 333, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmax", "long_name": "nanmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 341, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanargmax", "long_name": "nanargmax( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "x", "axis" ], "start_line": 348, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "disp", "long_name": "disp( mesg , device = None , linefeed = 1 )", "filename": "function_base.py", "nloc": 10, "complexity": 3, "token_count": 53, "parameters": [ "mesg", "device", "linefeed" ], "start_line": 355, "end_line": 366, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "function_base.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 399, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 37, "parameters": [ "self", "args" ], "start_line": 415, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , * args )", "filename": "function_base.py", "nloc": 23, "complexity": 7, "token_count": 155, "parameters": [ "self", "args" ], "start_line": 421, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "nanargmin", "long_name": "nanargmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 334, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nansum", "long_name": "nansum( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "x", "axis" ], "start_line": 320, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "fix", "long_name": "fix( x )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 35, "parameters": [ "x" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "nanmin", "long_name": "nanmin( x , axis = - 1 )", "filename": "function_base.py", "nloc": 4, "complexity": 1, "token_count": 41, "parameters": [ "x", "axis" ], "start_line": 327, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "nloc": 293, "complexity": 82, "token_count": 2124, "diff_parsed": { "added": [ "from Numeric import ravel, nonzero, array, choose, ones, zeros, \\", " sometrue, alltrue", "from type_check import ScalarType, isscalar, asarray", " x = asarray(x)", " x = asarray(x).copy()", " x = asarray(x).copy()", " x = asarray(x).copy()" ], "deleted": [ "from Numeric import ravel, asarray, nonzero, array, choose, ones, zeros, sometrue, alltrue", "from type_check import ScalarType, isscalar", " x = Numeric.asarray(x)", " x = Numeric.asarray(x).copy()", " x = Numeric.asarray(x).copy()", " x = Numeric.asarray(x).copy()" ] } }, { "old_path": "scipy_base/index_tricks.py", "new_path": "scipy_base/index_tricks.py", "filename": "index_tricks.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,7 +2,7 @@\n import Numeric\n __all__ = ['mgrid','ogrid','r_','c_','index_exp']\n \n-from type_check import ScalarType\n+from type_check import ScalarType, asarray\n import function_base\n import matrix_base\n \n@@ -143,7 +143,7 @@ def __getitem__(self,key):\n newobj = function_base.linspace(start, stop, num=size,\n endpoint=endpoint)\n elif type(key[k]) in ScalarType:\n- newobj = Numeric.asarray([key[k]])\n+ newobj = asarray([key[k]])\n else:\n newobj = key[k]\n objs.append(newobj)\n", "added_lines": 2, "deleted_lines": 2, "source_code": "import types\nimport Numeric\n__all__ = ['mgrid','ogrid','r_','c_','index_exp']\n\nfrom type_check import ScalarType, asarray\nimport function_base\nimport matrix_base\n\nclass nd_grid:\n \"\"\" Construct a \"meshgrid\" in N-dimensions.\n\n grid = nd_grid() creates an instance which will return a mesh-grid\n when indexed. The dimension and number of the output arrays are equal\n to the number of indexing dimensions. If the step length is not a\n complex number, then the stop is not inclusive.\n \n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the\n integer part of it's magnitude is interpreted as specifying the\n number of points to create between the start and stop values, where\n the stop value IS INCLUSIVE.\n\n If instantiated with an argument of 1, the mesh-grid is open or not\n fleshed out so that only one-dimension of each returned argument is\n greater than 1\n \n Example:\n \n >>> mgrid = nd_grid()\n >>> mgrid[0:5,0:5]\n array([[[0, 0, 0, 0, 0],\n [1, 1, 1, 1, 1],\n [2, 2, 2, 2, 2],\n [3, 3, 3, 3, 3],\n [4, 4, 4, 4, 4]],\n [[0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4]]])\n >>> mgrid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n\n >>> ogrid = nd_grid(1)\n >>> ogrid[0:5,0:5]\n [array([[0],[1],[2],[3],[4]]), array([[0, 1, 2, 3, 4]])] \n \"\"\"\n def __init__(self, sparse=0):\n self.sparse = sparse\n def __getitem__(self,key):\n try:\n\t size = []\n typecode = Numeric.Int\n\t for k in range(len(key)):\n\t step = key[k].step\n start = key[k].start\n if start is None: start = 0\n if step is None:\n step = 1\n if type(step) is type(1j):\n size.append(int(abs(step)))\n typecode = Numeric.Float\n else:\n size.append(int((key[k].stop - start)/(step*1.0)))\n if isinstance(step,types.FloatType) or \\\n isinstance(start, types.FloatType) or \\\n isinstance(key[k].stop, types.FloatType):\n typecode = Numeric.Float\n if self.sparse:\n nn = map(lambda x,t: Numeric.arange(x,typecode=t),size,(typecode,)*len(size))\n else:\n nn = Numeric.indices(size,typecode)\n\t for k in range(len(size)):\n step = key[k].step\n if step is None:\n step = 1\n if type(step) is type(1j):\n step = int(abs(step))\n step = (key[k].stop - key[k].start)/float(step-1)\n nn[k] = (nn[k]*step+key[k].start)\n if self.sparse:\n slobj = [Numeric.NewAxis]*len(size)\n for k in range(len(size)):\n slobj[k] = slice(None,None)\n nn[k] = nn[k][slobj]\n slobj[k] = Numeric.NewAxis\n\t return nn\n except (IndexError, TypeError):\n step = key.step\n stop = key.stop\n start = key.start\n if start is None: start = 0\n if type(step) is type(1j):\n step = abs(step)\n length = int(step)\n step = (key.stop-start)/float(step-1)\n stop = key.stop+step\n return Numeric.arange(0,length,1,Numeric.Float)*step + start\n else:\n return Numeric.arange(start, stop, step)\n\t \n def __getslice__(self,i,j):\n return Numeric.arange(i,j)\n\n def __len__(self):\n return 0\n\nmgrid = nd_grid()\nogrid = nd_grid(1)\n\nimport sys\nclass concatenator:\n \"\"\" Translates slice objects to concatenation along an axis.\n \"\"\"\n def __init__(self, axis=0):\n self.axis = axis\n def __getitem__(self,key):\n if isinstance(key,types.StringType):\n frame = sys._getframe().f_back\n return array(matrix_base.bmat(key,frame.f_globals,frame.f_locals))\n if type(key) is not types.TupleType:\n key = (key,)\n objs = []\n for k in range(len(key)):\n if type(key[k]) is types.SliceType:\n typecode = Numeric.Int\n\t step = key[k].step\n start = key[k].start\n stop = key[k].stop\n if start is None: start = 0\n if step is None:\n step = 1\n if type(step) is type(1j):\n size = int(abs(step))\n typecode = Numeric.Float\n endpoint = 1\n else:\n size = int((stop - start)/(step*1.0))\n endpoint = 0\n if isinstance(step,types.FloatType) or \\\n isinstance(start, types.FloatType) or \\\n isinstance(stop, types.FloatType):\n typecode = Numeric.Float\n newobj = function_base.linspace(start, stop, num=size,\n endpoint=endpoint)\n elif type(key[k]) in ScalarType:\n newobj = asarray([key[k]])\n else:\n newobj = key[k]\n objs.append(newobj)\n return Numeric.concatenate(tuple(objs),axis=self.axis)\n \n def __getslice__(self,i,j):\n return Numeric.arange(i,j)\n\n def __len__(self):\n return 0\n\nr_=concatenator(0)\nc_=concatenator(-1)\n\n# A nicer way to build up index tuples for arrays.\n#\n# You can do all this with slice() plus a few special objects,\n# but there's a lot to remember. This version is simpler because\n# it uses the standard array indexing syntax.\n#\n# Written by Konrad Hinsen \n# last revision: 1999-7-23\n#\n# Cosmetic changes by T. Oliphant 2001\n#\n#\n# This module provides a convenient method for constructing\n# array indices algorithmically. It provides one importable object,\n# 'index_expression'.\n#\n# For any index combination, including slicing and axis insertion,\n# 'a[indices]' is the same as 'a[index_expression[indices]]' for any\n# array 'a'. However, 'index_expression[indices]' can be used anywhere\n# in Python code and returns a tuple of slice objects that can be\n# used in the construction of complex index expressions.\n\nclass _index_expression_class:\n import sys\n maxint = sys.maxint\n\n def __getitem__(self, item):\n if type(item) != type(()):\n return (item,)\n else:\n return item\n\n def __len__(self):\n return self.maxint\n\n def __getslice__(self, start, stop):\n if stop == self.maxint:\n stop = None\n return self[start:stop:None]\n\nindex_exp = _index_expression_class()\n\n# End contribution from Konrad.\n\n", "source_code_before": "import types\nimport Numeric\n__all__ = ['mgrid','ogrid','r_','c_','index_exp']\n\nfrom type_check import ScalarType\nimport function_base\nimport matrix_base\n\nclass nd_grid:\n \"\"\" Construct a \"meshgrid\" in N-dimensions.\n\n grid = nd_grid() creates an instance which will return a mesh-grid\n when indexed. The dimension and number of the output arrays are equal\n to the number of indexing dimensions. If the step length is not a\n complex number, then the stop is not inclusive.\n \n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the\n integer part of it's magnitude is interpreted as specifying the\n number of points to create between the start and stop values, where\n the stop value IS INCLUSIVE.\n\n If instantiated with an argument of 1, the mesh-grid is open or not\n fleshed out so that only one-dimension of each returned argument is\n greater than 1\n \n Example:\n \n >>> mgrid = nd_grid()\n >>> mgrid[0:5,0:5]\n array([[[0, 0, 0, 0, 0],\n [1, 1, 1, 1, 1],\n [2, 2, 2, 2, 2],\n [3, 3, 3, 3, 3],\n [4, 4, 4, 4, 4]],\n [[0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4],\n [0, 1, 2, 3, 4]]])\n >>> mgrid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n\n >>> ogrid = nd_grid(1)\n >>> ogrid[0:5,0:5]\n [array([[0],[1],[2],[3],[4]]), array([[0, 1, 2, 3, 4]])] \n \"\"\"\n def __init__(self, sparse=0):\n self.sparse = sparse\n def __getitem__(self,key):\n try:\n\t size = []\n typecode = Numeric.Int\n\t for k in range(len(key)):\n\t step = key[k].step\n start = key[k].start\n if start is None: start = 0\n if step is None:\n step = 1\n if type(step) is type(1j):\n size.append(int(abs(step)))\n typecode = Numeric.Float\n else:\n size.append(int((key[k].stop - start)/(step*1.0)))\n if isinstance(step,types.FloatType) or \\\n isinstance(start, types.FloatType) or \\\n isinstance(key[k].stop, types.FloatType):\n typecode = Numeric.Float\n if self.sparse:\n nn = map(lambda x,t: Numeric.arange(x,typecode=t),size,(typecode,)*len(size))\n else:\n nn = Numeric.indices(size,typecode)\n\t for k in range(len(size)):\n step = key[k].step\n if step is None:\n step = 1\n if type(step) is type(1j):\n step = int(abs(step))\n step = (key[k].stop - key[k].start)/float(step-1)\n nn[k] = (nn[k]*step+key[k].start)\n if self.sparse:\n slobj = [Numeric.NewAxis]*len(size)\n for k in range(len(size)):\n slobj[k] = slice(None,None)\n nn[k] = nn[k][slobj]\n slobj[k] = Numeric.NewAxis\n\t return nn\n except (IndexError, TypeError):\n step = key.step\n stop = key.stop\n start = key.start\n if start is None: start = 0\n if type(step) is type(1j):\n step = abs(step)\n length = int(step)\n step = (key.stop-start)/float(step-1)\n stop = key.stop+step\n return Numeric.arange(0,length,1,Numeric.Float)*step + start\n else:\n return Numeric.arange(start, stop, step)\n\t \n def __getslice__(self,i,j):\n return Numeric.arange(i,j)\n\n def __len__(self):\n return 0\n\nmgrid = nd_grid()\nogrid = nd_grid(1)\n\nimport sys\nclass concatenator:\n \"\"\" Translates slice objects to concatenation along an axis.\n \"\"\"\n def __init__(self, axis=0):\n self.axis = axis\n def __getitem__(self,key):\n if isinstance(key,types.StringType):\n frame = sys._getframe().f_back\n return array(matrix_base.bmat(key,frame.f_globals,frame.f_locals))\n if type(key) is not types.TupleType:\n key = (key,)\n objs = []\n for k in range(len(key)):\n if type(key[k]) is types.SliceType:\n typecode = Numeric.Int\n\t step = key[k].step\n start = key[k].start\n stop = key[k].stop\n if start is None: start = 0\n if step is None:\n step = 1\n if type(step) is type(1j):\n size = int(abs(step))\n typecode = Numeric.Float\n endpoint = 1\n else:\n size = int((stop - start)/(step*1.0))\n endpoint = 0\n if isinstance(step,types.FloatType) or \\\n isinstance(start, types.FloatType) or \\\n isinstance(stop, types.FloatType):\n typecode = Numeric.Float\n newobj = function_base.linspace(start, stop, num=size,\n endpoint=endpoint)\n elif type(key[k]) in ScalarType:\n newobj = Numeric.asarray([key[k]])\n else:\n newobj = key[k]\n objs.append(newobj)\n return Numeric.concatenate(tuple(objs),axis=self.axis)\n \n def __getslice__(self,i,j):\n return Numeric.arange(i,j)\n\n def __len__(self):\n return 0\n\nr_=concatenator(0)\nc_=concatenator(-1)\n\n# A nicer way to build up index tuples for arrays.\n#\n# You can do all this with slice() plus a few special objects,\n# but there's a lot to remember. This version is simpler because\n# it uses the standard array indexing syntax.\n#\n# Written by Konrad Hinsen \n# last revision: 1999-7-23\n#\n# Cosmetic changes by T. Oliphant 2001\n#\n#\n# This module provides a convenient method for constructing\n# array indices algorithmically. It provides one importable object,\n# 'index_expression'.\n#\n# For any index combination, including slicing and axis insertion,\n# 'a[indices]' is the same as 'a[index_expression[indices]]' for any\n# array 'a'. However, 'index_expression[indices]' can be used anywhere\n# in Python code and returns a tuple of slice objects that can be\n# used in the construction of complex index expressions.\n\nclass _index_expression_class:\n import sys\n maxint = sys.maxint\n\n def __getitem__(self, item):\n if type(item) != type(()):\n return (item,)\n else:\n return item\n\n def __len__(self):\n return self.maxint\n\n def __getslice__(self, start, stop):\n if stop == self.maxint:\n stop = None\n return self[start:stop:None]\n\nindex_exp = _index_expression_class()\n\n# End contribution from Konrad.\n\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , sparse = 0 )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "sparse" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "index_tricks.py", "nloc": 51, "complexity": 17, "token_count": 466, "parameters": [ "self", "key" ], "start_line": 49, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , i , j )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "i", "j" ], "start_line": 101, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 104, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , axis = 0 )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "axis" ], "start_line": 114, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "index_tricks.py", "nloc": 35, "complexity": 12, "token_count": 290, "parameters": [ "self", "key" ], "start_line": 116, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , i , j )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "i", "j" ], "start_line": 152, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , item )", "filename": "index_tricks.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "self", "item" ], "start_line": 187, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 193, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , start , stop )", "filename": "index_tricks.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self", "start", "stop" ], "start_line": 196, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , sparse = 0 )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "sparse" ], "start_line": 47, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "index_tricks.py", "nloc": 51, "complexity": 17, "token_count": 466, "parameters": [ "self", "key" ], "start_line": 49, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , i , j )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "i", "j" ], "start_line": 101, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 104, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , axis = 0 )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self", "axis" ], "start_line": 114, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "index_tricks.py", "nloc": 35, "complexity": 12, "token_count": 292, "parameters": [ "self", "key" ], "start_line": 116, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , i , j )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "i", "j" ], "start_line": 152, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 155, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , item )", "filename": "index_tricks.py", "nloc": 5, "complexity": 2, "token_count": 28, "parameters": [ "self", "item" ], "start_line": 187, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "index_tricks.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 193, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , start , stop )", "filename": "index_tricks.py", "nloc": 4, "complexity": 2, "token_count": 28, "parameters": [ "self", "start", "stop" ], "start_line": 196, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "index_tricks.py", "nloc": 35, "complexity": 12, "token_count": 290, "parameters": [ "self", "key" ], "start_line": 116, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 } ], "nloc": 165, "complexity": 40, "token_count": 986, "diff_parsed": { "added": [ "from type_check import ScalarType, asarray", " newobj = asarray([key[k]])" ], "deleted": [ "from type_check import ScalarType", " newobj = Numeric.asarray([key[k]])" ] } }, { "old_path": "scipy_base/matrix_base.py", "new_path": "scipy_base/matrix_base.py", "filename": "matrix_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,6 +5,7 @@\n __all__ = ['diag','eye','fliplr','flipud','rot90','bmat']\n \n from Numeric import *\n+from type_check import asarray\n import Matrix\n \n def fliplr(m):\n", "added_lines": 1, "deleted_lines": 0, "source_code": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','rot90','bmat']\n\nfrom Numeric import *\nfrom type_check import asarray\nimport Matrix\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\ndef _from_string(str,gdict,ldict):\n rows = str.split(';')\n rowtup = []\n for row in rows:\n trow = row.split(',')\n coltup = []\n for col in trow:\n col = col.strip()\n try:\n thismat = gdict[col]\n except KeyError:\n try:\n thismat = ldict[col]\n except KeyError:\n raise KeyError, \"%s not found\" % (col,)\n \n coltup.append(thismat)\n rowtup.append(concatenate(coltup,axis=-1))\n return concatenate(rowtup,axis=0)\n\nimport sys\ndef bmat(obj,gdict=None,ldict=None):\n \"\"\"Build a matrix object from string, nested sequence, or array.\n\n Ex: F = bmat('A, B; C, D') \n F = bmat([[A,B],[C,D]])\n F = bmat(r_[c_[A,B],c_[C,D]])\n\n all produce the same Matrix Object [ A B ]\n [ C D ]\n \n if A, B, C, and D are appropriately shaped 2-d arrays.\n \"\"\"\n if isinstance(obj, types.StringType):\n if gdict is None:\n # get previous frame\n frame = sys._getframe().f_back\n glob_dict = frame.f_globals\n loc_dict = frame.f_locals\n else:\n glob_dict = gdict\n loc_dict = ldict\n \n return Matrix.Matrix(_from_string(obj, glob_dict, loc_dict))\n \n if isinstance(obj, (types.TupleType, types.ListType)):\n # [[A,B],[C,D]]\n arr_rows = []\n for row in obj:\n if isinstance(row, ArrayType): # not 2-d\n return Matrix.Matrix(concatenate(obj,axis=-1))\n else:\n arr_rows.append(concatenate(row,axis=-1))\n return Matrix.Matrix(concatenate(arr_rows,axis=0))\n if isinstance(obj, ArrayType):\n return Matrix.Matrix(obj)\n\n", "source_code_before": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','rot90','bmat']\n\nfrom Numeric import *\nimport Matrix\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\ndef _from_string(str,gdict,ldict):\n rows = str.split(';')\n rowtup = []\n for row in rows:\n trow = row.split(',')\n coltup = []\n for col in trow:\n col = col.strip()\n try:\n thismat = gdict[col]\n except KeyError:\n try:\n thismat = ldict[col]\n except KeyError:\n raise KeyError, \"%s not found\" % (col,)\n \n coltup.append(thismat)\n rowtup.append(concatenate(coltup,axis=-1))\n return concatenate(rowtup,axis=0)\n\nimport sys\ndef bmat(obj,gdict=None,ldict=None):\n \"\"\"Build a matrix object from string, nested sequence, or array.\n\n Ex: F = bmat('A, B; C, D') \n F = bmat([[A,B],[C,D]])\n F = bmat(r_[c_[A,B],c_[C,D]])\n\n all produce the same Matrix Object [ A B ]\n [ C D ]\n \n if A, B, C, and D are appropriately shaped 2-d arrays.\n \"\"\"\n if isinstance(obj, types.StringType):\n if gdict is None:\n # get previous frame\n frame = sys._getframe().f_back\n glob_dict = frame.f_globals\n loc_dict = frame.f_locals\n else:\n glob_dict = gdict\n loc_dict = ldict\n \n return Matrix.Matrix(_from_string(obj, glob_dict, loc_dict))\n \n if isinstance(obj, (types.TupleType, types.ListType)):\n # [[A,B],[C,D]]\n arr_rows = []\n for row in obj:\n if isinstance(row, ArrayType): # not 2-d\n return Matrix.Matrix(concatenate(obj,axis=-1))\n else:\n arr_rows.append(concatenate(row,axis=-1))\n return Matrix.Matrix(concatenate(arr_rows,axis=0))\n if isinstance(obj, ArrayType):\n return Matrix.Matrix(obj)\n\n", "methods": [ { "name": "fliplr", "long_name": "fliplr( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "m" ], "start_line": 11, "end_line": 18, "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": 20, "end_line": 27, "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": 31, "end_line": 42, "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": 44, "end_line": 56, "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": 58, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_from_string", "long_name": "_from_string( str , gdict , ldict )", "filename": "matrix_base.py", "nloc": 18, "complexity": 5, "token_count": 110, "parameters": [ "str", "gdict", "ldict" ], "start_line": 80, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "bmat", "long_name": "bmat( obj , gdict = None , ldict = None )", "filename": "matrix_base.py", "nloc": 20, "complexity": 7, "token_count": 163, "parameters": [ "obj", "gdict", "ldict" ], "start_line": 101, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 10, "end_line": 17, "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": 19, "end_line": 26, "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": 30, "end_line": 41, "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": 43, "end_line": 55, "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": 57, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_from_string", "long_name": "_from_string( str , gdict , ldict )", "filename": "matrix_base.py", "nloc": 18, "complexity": 5, "token_count": 110, "parameters": [ "str", "gdict", "ldict" ], "start_line": 79, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 0 }, { "name": "bmat", "long_name": "bmat( obj , gdict = None , ldict = None )", "filename": "matrix_base.py", "nloc": 20, "complexity": 7, "token_count": 163, "parameters": [ "obj", "gdict", "ldict" ], "start_line": 100, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 92, "complexity": 32, "token_count": 700, "diff_parsed": { "added": [ "from type_check import asarray" ], "deleted": [] } }, { "old_path": "scipy_base/polynomial.py", "new_path": "scipy_base/polynomial.py", "filename": "polynomial.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,7 +2,7 @@\n from Numeric import *\n from scimath import *\n \n-from type_check import isscalar\n+from type_check import isscalar, asarray\n from matrix_base import diag\n from shape_base import hstack, atleast_1d\n from function_base import trim_zeros, sort_complex\n@@ -130,7 +130,7 @@ def polyint(p,m=1,k=None):\n return p\n else:\n truepoly = isinstance(p,poly1d)\n- p = Numeric.asarray(p)\n+ p = 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@@ -144,7 +144,7 @@ def polyder(p,m=1):\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n- p = Numeric.asarray(p)\n+ p = asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n@@ -169,11 +169,11 @@ def polyval(p,x):\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n \"\"\"\n- p = Numeric.asarray(p)\n+ p = asarray(p)\n if isinstance(x,poly1d):\n y = 0\n else:\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n@@ -321,9 +321,9 @@ def __init__(self, c_or_r, r=0):\n \n def __array__(self,t=None):\n if t:\n- return Numeric.asarray(self.coeffs,t)\n+ return asarray(self.coeffs,t)\n else:\n- return Numeric.asarray(self.coeffs)\n+ return asarray(self.coeffs)\n \n def __coerce__(self,other):\n return None\n", "added_lines": 7, "deleted_lines": 7, "source_code": "import Numeric\nfrom Numeric import *\nfrom scimath import *\n\nfrom type_check import isscalar, asarray\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 = 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 = 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 polynomial p at x. If x is a polynomial then composition.\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 can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n \"\"\"\n p = asarray(p)\n if isinstance(x,poly1d):\n y = 0\n else:\n x = asarray(x)\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 asarray(self.coeffs,t)\n else:\n return asarray(self.coeffs)\n\n def __coerce__(self,other):\n return None\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(self.coeffs * other)\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 other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\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 other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\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 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 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 polynomial p at x. If x is a polynomial then composition.\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 can be a sequence and p(x) will be returned for all elements of x.\n or x can be another polynomial and the composite polynomial p(x) will be\n returned.\n \"\"\"\n p = Numeric.asarray(p)\n if isinstance(x,poly1d):\n y = 0\n else:\n x = Numeric.asarray(x)\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 __coerce__(self,other):\n return None\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(self.coeffs * other)\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 other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\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 other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\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 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": 190, "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": 97, "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": 10, "complexity": 3, "token_count": 72, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "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": 182, "end_line": 198, "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": 200, "end_line": 216, "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": 219, "end_line": 226, "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": 228, "end_line": 237, "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": 239, "end_line": 258, "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": 262, "end_line": 286, "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": 306, "end_line": 320, "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": 30, "parameters": [ "self", "t" ], "start_line": 322, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__coerce__", "long_name": "__coerce__( self , other )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "other" ], "start_line": 328, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 331, "end_line": 334, "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": 336, "end_line": 337, "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": 339, "end_line": 380, "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": 383, "end_line": 384, "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": 386, "end_line": 391, "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": 393, "end_line": 398, "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": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 400, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 404, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "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": 408, "end_line": 414, "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": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 416, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 420, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "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": 424, "end_line": 429, "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": 431, "end_line": 436, "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": 438, "end_line": 439, "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": 9, "complexity": 4, "token_count": 58, "parameters": [ "self", "key" ], "start_line": 441, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 451, "end_line": 457, "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": 459, "end_line": 469, "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": 471, "end_line": 472, "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": 474, "end_line": 475, "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": 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": 10, "complexity": 3, "token_count": 76, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "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": 182, "end_line": 198, "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": 200, "end_line": 216, "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": 219, "end_line": 226, "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": 228, "end_line": 237, "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": 239, "end_line": 258, "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": 262, "end_line": 286, "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": 306, "end_line": 320, "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": 322, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__coerce__", "long_name": "__coerce__( self , other )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "other" ], "start_line": 328, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 331, "end_line": 334, "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": 336, "end_line": 337, "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": 339, "end_line": 380, "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": 383, "end_line": 384, "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": 386, "end_line": 391, "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": 393, "end_line": 398, "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": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 400, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 404, "end_line": 406, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "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": 408, "end_line": 414, "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": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 416, "end_line": 418, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "other" ], "start_line": 420, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "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": 424, "end_line": 429, "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": 431, "end_line": 436, "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": 438, "end_line": 439, "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": 9, "complexity": 4, "token_count": 58, "parameters": [ "self", "key" ], "start_line": 441, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 451, "end_line": 457, "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": 459, "end_line": 469, "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": 471, "end_line": 472, "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": 474, "end_line": 475, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "__array__", "long_name": "__array__( self , t = None )", "filename": "polynomial.py", "nloc": 5, "complexity": 2, "token_count": 30, "parameters": [ "self", "t" ], "start_line": 322, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "polyder", "long_name": "polyder( p , m = 1 )", "filename": "polynomial.py", "nloc": 15, "complexity": 4, "token_count": 97, "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": "polyint", "long_name": "polyint( p , m = 1 , k = None )", "filename": "polynomial.py", "nloc": 24, "complexity": 8, "token_count": 190, "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": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 10, "complexity": 3, "token_count": 72, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 } ], "nloc": 370, "complexity": 117, "token_count": 2654, "diff_parsed": { "added": [ "from type_check import isscalar, asarray", " p = asarray(p)", " p = asarray(p)", " p = asarray(p)", " x = asarray(x)", " return asarray(self.coeffs,t)", " return asarray(self.coeffs)" ], "deleted": [ "from type_check import isscalar", " p = Numeric.asarray(p)", " p = Numeric.asarray(p)", " p = Numeric.asarray(p)", " x = Numeric.asarray(x)", " return Numeric.asarray(self.coeffs,t)", " return Numeric.asarray(self.coeffs)" ] } }, { "old_path": "scipy_base/scimath.py", "new_path": "scipy_base/scimath.py", "filename": "scimath.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,7 +8,7 @@\n \n import Numeric\n \n-from type_check import isreal\n+from type_check import isreal, asarray\n from function_base import any\n import fastumath\n from fastumath import *\n@@ -23,19 +23,19 @@ def _tocomplex(arr):\n return arr.astype('D')\n \n def sqrt(x):\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n \n def log(x):\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n \n def log10(x):\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n@@ -43,7 +43,7 @@ def log10(x):\n def logn(n,x):\n \"\"\" Take log base n of x.\n \"\"\"\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n@@ -53,32 +53,32 @@ def logn(n,x):\n def log2(x):\n \"\"\" Take log base 2 of x.\n \"\"\"\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)/fastumath.log(2)\n \n \n def power(x, p):\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \n def arccos(x):\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n \n def arcsin(x):\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n \n def arctanh(x):\n- x = Numeric.asarray(x)\n+ x = asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n", "added_lines": 10, "deleted_lines": 10, "source_code": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions\nwhose output is different than the input in certain domains of the input.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos',\n 'arcsin', 'arctanh']\n\nimport Numeric\n\nfrom type_check import isreal, asarray\nfrom function_base import any\nimport fastumath\nfrom fastumath import *\n\n__all__.extend([key for key in dir(fastumath) \\\n if key[0]!='_' and key not in __all__])\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1','w']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,x):\n \"\"\" Take log base n of x.\n \"\"\"\n x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(x)/fastumath.log(n)\n\ndef log2(x):\n \"\"\" Take log base 2 of x.\n \"\"\"\n x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)/fastumath.log(2)\n\n\ndef power(x, p):\n x = asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n", "source_code_before": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions\nwhose output is different than the input in certain domains of the input.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos',\n 'arcsin', 'arctanh']\n\nimport Numeric\n\nfrom type_check import isreal\nfrom function_base import any\nimport fastumath\nfrom fastumath import *\n\n__all__.extend([key for key in dir(fastumath) \\\n if key[0]!='_' and key not in __all__])\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1','w']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,x):\n \"\"\" Take log base n of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(x)/fastumath.log(n)\n\ndef log2(x):\n \"\"\" Take log base 2 of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n", "methods": [ { "name": "_tocomplex", "long_name": "_tocomplex( arr )", "filename": "scimath.py", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "arr" ], "start_line": 19, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sqrt", "long_name": "sqrt( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 37, "parameters": [ "x" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "log", "long_name": "log( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 37, "parameters": [ "x" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "log10", "long_name": "log10( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 37, "parameters": [ "x" ], "start_line": 37, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logn", "long_name": "logn( n , x )", "filename": "scimath.py", "nloc": 7, "complexity": 5, "token_count": 65, "parameters": [ "n", "x" ], "start_line": 43, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "log2", "long_name": "log2( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "x" ], "start_line": 53, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "power", "long_name": "power( x , p )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 41, "parameters": [ "x", "p" ], "start_line": 62, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "arccos", "long_name": "arccos( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 40, "parameters": [ "x" ], "start_line": 68, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "arcsin", "long_name": "arcsin( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 40, "parameters": [ "x" ], "start_line": 74, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "arctanh", "long_name": "arctanh( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 40, "parameters": [ "x" ], "start_line": 80, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "_tocomplex", "long_name": "_tocomplex( arr )", "filename": "scimath.py", "nloc": 5, "complexity": 2, "token_count": 40, "parameters": [ "arr" ], "start_line": 19, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sqrt", "long_name": "sqrt( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "x" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "log", "long_name": "log( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "x" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "log10", "long_name": "log10( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "x" ], "start_line": 37, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logn", "long_name": "logn( n , x )", "filename": "scimath.py", "nloc": 7, "complexity": 5, "token_count": 67, "parameters": [ "n", "x" ], "start_line": 43, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "log2", "long_name": "log2( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 47, "parameters": [ "x" ], "start_line": 53, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "power", "long_name": "power( x , p )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "x", "p" ], "start_line": 62, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "arccos", "long_name": "arccos( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 42, "parameters": [ "x" ], "start_line": 68, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "arcsin", "long_name": "arcsin( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 42, "parameters": [ "x" ], "start_line": 74, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "arctanh", "long_name": "arctanh( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 42, "parameters": [ "x" ], "start_line": 80, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "arccos", "long_name": "arccos( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 40, "parameters": [ "x" ], "start_line": 68, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "power", "long_name": "power( x , p )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 41, "parameters": [ "x", "p" ], "start_line": 62, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "log2", "long_name": "log2( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 45, "parameters": [ "x" ], "start_line": 53, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "arcsin", "long_name": "arcsin( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 40, "parameters": [ "x" ], "start_line": 74, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "arctanh", "long_name": "arctanh( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 40, "parameters": [ "x" ], "start_line": 80, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "log10", "long_name": "log10( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 37, "parameters": [ "x" ], "start_line": 37, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "log", "long_name": "log( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 37, "parameters": [ "x" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "sqrt", "long_name": "sqrt( x )", "filename": "scimath.py", "nloc": 5, "complexity": 3, "token_count": 37, "parameters": [ "x" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "logn", "long_name": "logn( n , x )", "filename": "scimath.py", "nloc": 7, "complexity": 5, "token_count": 65, "parameters": [ "n", "x" ], "start_line": 43, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "nloc": 65, "complexity": 31, "token_count": 500, "diff_parsed": { "added": [ "from type_check import isreal, asarray", " x = asarray(x)", " x = asarray(x)", " x = asarray(x)", " x = asarray(x)", " x = asarray(x)", " x = asarray(x)", " x = asarray(x)", " x = asarray(x)", " x = asarray(x)" ], "deleted": [ "from type_check import isreal", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)", " x = Numeric.asarray(x)" ] } }, { "old_path": "scipy_base/shape_base.py", "new_path": "scipy_base/shape_base.py", "filename": "shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n import Numeric\n from Numeric import *\n-from type_check import isscalar\n+from type_check import isscalar, asarray\n \n __all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n", "added_lines": 1, "deleted_lines": 1, "source_code": "import Numeric\nfrom Numeric import *\nfrom type_check import isscalar, asarray\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n nd = Numeric.rank(arr)\n if axis < 0: axis += nd\n if (axis >= nd):\n raise ValueError, \"axis must be less than the rank; \"+\\\n \"axis=%d, rank=%d.\" % (axis,)\n ind = [0]*(nd-1)\n dims = Numeric.shape(arr)\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = take(shape(arr),indlist)\n put(i,indlist,ind)\n res = func1d(arr[i],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).typecode())\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n put(i,indlist,ind)\n res = func1d(arr[i],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).typecode())\n outarr[i] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n put(i,indlist,ind)\n res = func1d(arr[i],*args)\n outarr[i] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function over multiple axes, keeping the same shape\n for the resulting array.\n \"\"\"\n val = asarray(a)\n N = len(val.shape)\n if not type(axes) in SequenceType:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n val = expand_dims(func(*args),axis)\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n a.shape = shape[:axis] + (1,) + shape[axis:]\n return a\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n a = asarray(a)\n b = asarray(a.shape)\n val = reshape (a, tuple (compress (not_equal (b, 1), b)))\n return val\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0: \n result = Numeric.array([ary[0]])\n else:\n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0: \n ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,map(atleast_2d,tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "source_code_before": "import Numeric\nfrom Numeric import *\nfrom type_check import isscalar\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze','apply_over_axes','expand_dims',\n 'apply_along_axis']\n\ndef apply_along_axis(func1d,axis,arr,*args):\n \"\"\" Execute func1d(arr[i],*args) where func1d takes 1-D arrays\n and arr is an N-d array. i varies so as to apply the function\n along the given axis for each 1-d subarray in arr.\n \"\"\"\n nd = Numeric.rank(arr)\n if axis < 0: axis += nd\n if (axis >= nd):\n raise ValueError, \"axis must be less than the rank; \"+\\\n \"axis=%d, rank=%d.\" % (axis,)\n ind = [0]*(nd-1)\n dims = Numeric.shape(arr)\n i = zeros(nd,'O')\n indlist = range(nd)\n indlist.remove(axis)\n i[axis] = slice(None,None)\n outshape = take(shape(arr),indlist)\n put(i,indlist,ind)\n res = func1d(arr[i],*args)\n # if res is a number, then we have a smaller output array\n if isscalar(res):\n outarr = zeros(outshape,asarray(res).typecode())\n outarr[ind] = res\n Ntot = product(outshape)\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= outshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n put(i,indlist,ind)\n res = func1d(arr[i],*args)\n outarr[ind] = res\n k += 1\n return outarr\n else:\n Ntot = product(outshape)\n holdshape = outshape\n outshape = list(shape(arr))\n outshape[axis] = len(res)\n outarr = zeros(outshape,asarray(res).typecode())\n outarr[i] = res\n k = 1\n while k < Ntot:\n # increment the index\n ind[-1] += 1\n n = -1\n while (ind[n] >= holdshape[n]) and (n > (1-nd)):\n ind[n-1] += 1\n ind[n] = 0\n n -= 1\n put(i,indlist,ind)\n res = func1d(arr[i],*args)\n outarr[i] = res\n k += 1\n return outarr\n \n \ndef apply_over_axes(func, a, axes):\n \"\"\"Apply a function over multiple axes, keeping the same shape\n for the resulting array.\n \"\"\"\n val = asarray(a)\n N = len(val.shape)\n if not type(axes) in SequenceType:\n axes = (axes,)\n for axis in axes:\n if axis < 0: axis = N + axis\n args = (val, axis)\n val = expand_dims(func(*args),axis)\n return val\n\ndef expand_dims(a, axis):\n \"\"\"Expand the shape of a by including NewAxis before given axis.\n \"\"\"\n a = asarray(a)\n shape = a.shape\n if axis < 0:\n axis = axis + len(shape) + 1\n a.shape = shape[:axis] + (1,) + shape[axis:]\n return a\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n a = asarray(a)\n b = asarray(a.shape)\n val = reshape (a, tuple (compress (not_equal (b, 1), b)))\n return val\n\ndef atleast_1d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n *arys -- arrays to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0: \n result = Numeric.array([ary[0]])\n else:\n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\ndef atleast_2d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n arys -- arrays to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0: \n ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n \ndef atleast_3d(*arys):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n arys -- arrays to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n res = []\n for ary in arys:\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n res.append(result)\n if len(res) == 1:\n return res[0]\n else:\n return res\n\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,map(atleast_2d,tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n", "methods": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 52, "complexity": 10, "token_count": 392, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 10, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 10, "complexity": 4, "token_count": 75, "parameters": [ "func", "a", "axes" ], "start_line": 71, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 85, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "a" ], "start_line": 95, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 13, "complexity": 4, "token_count": 73, "parameters": [ "arys" ], "start_line": 102, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 91, "parameters": [ "arys" ], "start_line": 127, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 113, "parameters": [ "arys" ], "start_line": 154, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 187, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 218, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 245, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 268, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 297, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 190, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 305, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 369, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 412, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 454, "end_line": 494, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 496, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "methods_before": [ { "name": "apply_along_axis", "long_name": "apply_along_axis( func1d , axis , arr , * args )", "filename": "shape_base.py", "nloc": 52, "complexity": 10, "token_count": 392, "parameters": [ "func1d", "axis", "arr", "args" ], "start_line": 10, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "apply_over_axes", "long_name": "apply_over_axes( func , a , axes )", "filename": "shape_base.py", "nloc": 10, "complexity": 4, "token_count": 75, "parameters": [ "func", "a", "axes" ], "start_line": 71, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "expand_dims", "long_name": "expand_dims( a , axis )", "filename": "shape_base.py", "nloc": 7, "complexity": 2, "token_count": 56, "parameters": [ "a", "axis" ], "start_line": 85, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "squeeze", "long_name": "squeeze( a )", "filename": "shape_base.py", "nloc": 6, "complexity": 1, "token_count": 43, "parameters": [ "a" ], "start_line": 95, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "atleast_1d", "long_name": "atleast_1d( * arys )", "filename": "shape_base.py", "nloc": 13, "complexity": 4, "token_count": 73, "parameters": [ "arys" ], "start_line": 102, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 0 }, { "name": "atleast_2d", "long_name": "atleast_2d( * arys )", "filename": "shape_base.py", "nloc": 15, "complexity": 5, "token_count": 91, "parameters": [ "arys" ], "start_line": 127, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "atleast_3d", "long_name": "atleast_3d( * arys )", "filename": "shape_base.py", "nloc": 17, "complexity": 6, "token_count": 113, "parameters": [ "arys" ], "start_line": 154, "end_line": 184, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "vstack", "long_name": "vstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 187, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "hstack", "long_name": "hstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 218, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "column_stack", "long_name": "column_stack( tup )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "tup" ], "start_line": 245, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "dstack", "long_name": "dstack( tup )", "filename": "shape_base.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "tup" ], "start_line": 268, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "_replace_zero_by_x_arrays", "long_name": "_replace_zero_by_x_arrays( sub_arys )", "filename": "shape_base.py", "nloc": 7, "complexity": 4, "token_count": 81, "parameters": [ "sub_arys" ], "start_line": 297, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "array_split", "long_name": "array_split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 24, "complexity": 5, "token_count": 190, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 305, "end_line": 367, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 0 }, { "name": "split", "long_name": "split( ary , indices_or_sections , axis = 0 )", "filename": "shape_base.py", "nloc": 9, "complexity": 3, "token_count": 53, "parameters": [ "ary", "indices_or_sections", "axis" ], "start_line": 369, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "hsplit", "long_name": "hsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 7, "complexity": 3, "token_count": 55, "parameters": [ "ary", "indices_or_sections" ], "start_line": 412, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "vsplit", "long_name": "vsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 454, "end_line": 494, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "dsplit", "long_name": "dsplit( ary , indices_or_sections )", "filename": "shape_base.py", "nloc": 4, "complexity": 2, "token_count": 34, "parameters": [ "ary", "indices_or_sections" ], "start_line": 496, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 191, "complexity": 55, "token_count": 1444, "diff_parsed": { "added": [ "from type_check import isscalar, asarray" ], "deleted": [ "from type_check import isscalar" ] } }, { "old_path": "scipy_base/type_check.py", "new_path": "scipy_base/type_check.py", "filename": "type_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,12 +2,27 @@\n import types\n import Numeric\n from fastumath import isinf, isnan, isfinite\n-from Numeric import asarray, ArrayType, array\n+from Numeric import ArrayType, array, multiarray\n \n __all__ = ['ScalarType','iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',\n 'isreal','nan_to_num','real','real_if_close',\n- 'typename','cast','common_type','typecodes']\n+ 'typename','cast','common_type','typecodes', 'asarray']\n+\n+def asarray(a, typecode=None, savespace=None):\n+ \"\"\"asarray(a,typecode=None, savespace=0) returns a as a NumPy array.\n+ Unlike array(), no copy is performed if a is already an array.\n+ \"\"\"\n+ if type(a) is ArrayType:\n+ if typecode is None or typecode == a.typecode():\n+ if savespace is None or a.spacesaver()==savespace:\n+ return a\n+ else:\n+ r = a.astype(typecode)\n+ if not (savespace is None or a.spacesaver()==savespace):\n+ r.savespace(savespace)\n+ return r\n+ return multiarray.array(a,typecode,copy=0,savespace=savespace or 0)\n \n ScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n \n@@ -19,22 +34,22 @@\n except AttributeError:\n Char = 'c'\n \n-toChar = lambda x: Numeric.asarray(x).astype(Char)\n-toInt8 = lambda x: Numeric.asarray(x).astype(Numeric.Int8)# or use variable names such as Byte\n-toUInt8 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt8)\n+toChar = lambda x: asarray(x).astype(Char)\n+toInt8 = lambda x: asarray(x).astype(Numeric.Int8)# or use variable names such as Byte\n+toUInt8 = lambda x: asarray(x).astype(Numeric.UnsignedInt8)\n _unsigned = 0\n if hasattr(Numeric,'UnsignedInt16'):\n- toUInt16 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt16)\n- toUInt32 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt32)\n+ toUInt16 = lambda x: asarray(x).astype(Numeric.UnsignedInt16)\n+ toUInt32 = lambda x: asarray(x).astype(Numeric.UnsignedInt32)\n _unsigned = 1\n \n-toInt16 = lambda x: Numeric.asarray(x).astype(Numeric.Int16)\n-toInt32 = lambda x: Numeric.asarray(x).astype(Numeric.Int32)\n-toInt = lambda x: Numeric.asarray(x).astype(Numeric.Int)\n-toFloat32 = lambda x: Numeric.asarray(x).astype(Numeric.Float32)\n-toFloat64 = lambda x: Numeric.asarray(x).astype(Numeric.Float64)\n-toComplex32 = lambda x: Numeric.asarray(x).astype(Numeric.Complex32)\n-toComplex64 = lambda x: Numeric.asarray(x).astype(Numeric.Complex64)\n+toInt16 = lambda x: asarray(x).astype(Numeric.Int16)\n+toInt32 = lambda x: asarray(x).astype(Numeric.Int32)\n+toInt = lambda x: asarray(x).astype(Numeric.Int)\n+toFloat32 = lambda x: asarray(x).astype(Numeric.Float32)\n+toFloat64 = lambda x: asarray(x).astype(Numeric.Float64)\n+toComplex32 = lambda x: asarray(x).astype(Numeric.Complex32)\n+toComplex64 = lambda x: asarray(x).astype(Numeric.Complex64)\n \n # This is for pre Numeric 21.x compatiblity. Adding it is harmless.\n if not hasattr(Numeric,'Character'):\n@@ -140,7 +155,7 @@ def nan_to_num(x):\n if t in [types.ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n- x = Numeric.asarray(x)\n+ x = asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n@@ -152,7 +167,7 @@ def nan_to_num(x):\n #-----------------------------------------------------------------------------\n \n def real_if_close(a,tol=1e-13):\n- a = Numeric.asarray(a)\n+ a = asarray(a)\n if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n", "added_lines": 31, "deleted_lines": 16, "source_code": "\nimport types\nimport Numeric\nfrom fastumath import isinf, isnan, isfinite\nfrom Numeric import ArrayType, array, multiarray\n\n__all__ = ['ScalarType','iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',\n 'isreal','nan_to_num','real','real_if_close',\n 'typename','cast','common_type','typecodes', 'asarray']\n\ndef asarray(a, typecode=None, savespace=None):\n \"\"\"asarray(a,typecode=None, savespace=0) returns a as a NumPy array.\n Unlike array(), no copy is performed if a is already an array.\n \"\"\"\n if type(a) is ArrayType:\n if typecode is None or typecode == a.typecode():\n if savespace is None or a.spacesaver()==savespace:\n return a\n else:\n r = a.astype(typecode)\n if not (savespace is None or a.spacesaver()==savespace):\n r.savespace(savespace)\n return r\n return multiarray.array(a,typecode,copy=0,savespace=savespace or 0)\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\ntypecodes = Numeric.typecodes\ntypecodes['AllInteger'] = '1silbwu'\n\ntry:\n Char = Numeric.Character\nexcept AttributeError:\n Char = 'c'\n\ntoChar = lambda x: asarray(x).astype(Char)\ntoInt8 = lambda x: asarray(x).astype(Numeric.Int8)# or use variable names such as Byte\ntoUInt8 = lambda x: asarray(x).astype(Numeric.UnsignedInt8)\n_unsigned = 0\nif hasattr(Numeric,'UnsignedInt16'):\n toUInt16 = lambda x: asarray(x).astype(Numeric.UnsignedInt16)\n toUInt32 = lambda x: asarray(x).astype(Numeric.UnsignedInt32)\n _unsigned = 1\n \ntoInt16 = lambda x: asarray(x).astype(Numeric.Int16)\ntoInt32 = lambda x: asarray(x).astype(Numeric.Int32)\ntoInt = lambda x: asarray(x).astype(Numeric.Int)\ntoFloat32 = lambda x: asarray(x).astype(Numeric.Float32)\ntoFloat64 = lambda x: asarray(x).astype(Numeric.Float64)\ntoComplex32 = lambda x: asarray(x).astype(Numeric.Complex32)\ntoComplex64 = lambda x: asarray(x).astype(Numeric.Complex64)\n\n# This is for pre Numeric 21.x compatiblity. Adding it is harmless.\nif not hasattr(Numeric,'Character'):\n Numeric.Character = 'c'\n \ncast = {Numeric.Character: toChar,\n Numeric.UnsignedInt8: toUInt8,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\nif _unsigned:\n cast[Numeric.UnsignedInt16] = toUInt16\n cast[Numeric.UnsignedInt32] = toUInt32\n \n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef real(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.real\n else:\n return aval\n\ndef imag(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.imag\n else:\n return array(0,aval.typecode())*aval\n\ndef iscomplex(x):\n return imag(x) != Numeric.zeros(asarray(x).shape)\n\ndef isreal(x):\n return imag(x) == Numeric.zeros(asarray(x).shape)\n\ndef iscomplexobj(x):\n return asarray(x).typecode() in ['F', 'D']\n\ndef isrealobj(x):\n return not asarray(x).typecode() in ['F', 'D']\n\n#-----------------------------------------------------------------------------\n\n##def isnan(val):\n## # fast, but apparently not portable (according to notes by Tim Peters)\n## #return val != val\n## # very slow -- should really use cephes methods or *something* different\n## import ieee_754\n## vals = ravel(val)\n## if array_iscomplex(vals):\n## r = array(map(ieee_754.isnan,real(vals))) \n## i = array(map(ieee_754.isnan,imag(vals)))\n## results = Numeric.logical_or(r,i)\n## else: \n## results = array(map(ieee_754.isnan,vals))\n## if isscalar(val):\n## results = results[0]\n## return results\n\ndef isposinf(val):\n return isinf(val) & (val > 0)\n \ndef isneginf(val):\n return isinf(val) & (val < 0)\n \n##def isinf(val):\n## return Numeric.logical_or(isposinf(val),isneginf(val))\n\n##def isfinite(val):\n## vals = asarray(val)\n## if iscomplexobj(vals):\n## r = isfinite(real(vals))\n## i = isfinite(imag(vals))\n## results = Numeric.logical_and(r,i)\n## else: \n## fin = Numeric.logical_not(isinf(val))\n## an = Numeric.logical_not(isnan(val))\n## results = Numeric.logical_and(fin,an)\n## return results \n\ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> limits.double_max\n # -Inf -> limits.double_min\n # complex not handled currently\n import limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [types.ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,limits.double_min, 0., limits.double_max))\n return y\n\n#-----------------------------------------------------------------------------\n\ndef real_if_close(a,tol=1e-13):\n a = asarray(a)\n if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n\n\n#-----------------------------------------------------------------------------\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'w' : 'unsigned short',\n 'i' : 'integer',\n 'u' : 'unsigned integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\n#-----------------------------------------------------------------------------\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", "source_code_before": "\nimport types\nimport Numeric\nfrom fastumath import isinf, isnan, isfinite\nfrom Numeric import asarray, ArrayType, array\n\n__all__ = ['ScalarType','iscomplexobj','isrealobj','imag','iscomplex',\n 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',\n 'isreal','nan_to_num','real','real_if_close',\n 'typename','cast','common_type','typecodes']\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\ntypecodes = Numeric.typecodes\ntypecodes['AllInteger'] = '1silbwu'\n\ntry:\n Char = Numeric.Character\nexcept AttributeError:\n Char = 'c'\n\ntoChar = lambda x: Numeric.asarray(x).astype(Char)\ntoInt8 = lambda x: Numeric.asarray(x).astype(Numeric.Int8)# or use variable names such as Byte\ntoUInt8 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt8)\n_unsigned = 0\nif hasattr(Numeric,'UnsignedInt16'):\n toUInt16 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt16)\n toUInt32 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt32)\n _unsigned = 1\n \ntoInt16 = lambda x: Numeric.asarray(x).astype(Numeric.Int16)\ntoInt32 = lambda x: Numeric.asarray(x).astype(Numeric.Int32)\ntoInt = lambda x: Numeric.asarray(x).astype(Numeric.Int)\ntoFloat32 = lambda x: Numeric.asarray(x).astype(Numeric.Float32)\ntoFloat64 = lambda x: Numeric.asarray(x).astype(Numeric.Float64)\ntoComplex32 = lambda x: Numeric.asarray(x).astype(Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.asarray(x).astype(Numeric.Complex64)\n\n# This is for pre Numeric 21.x compatiblity. Adding it is harmless.\nif not hasattr(Numeric,'Character'):\n Numeric.Character = 'c'\n \ncast = {Numeric.Character: toChar,\n Numeric.UnsignedInt8: toUInt8,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\nif _unsigned:\n cast[Numeric.UnsignedInt16] = toUInt16\n cast[Numeric.UnsignedInt32] = toUInt32\n \n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef real(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.real\n else:\n return aval\n\ndef imag(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.imag\n else:\n return array(0,aval.typecode())*aval\n\ndef iscomplex(x):\n return imag(x) != Numeric.zeros(asarray(x).shape)\n\ndef isreal(x):\n return imag(x) == Numeric.zeros(asarray(x).shape)\n\ndef iscomplexobj(x):\n return asarray(x).typecode() in ['F', 'D']\n\ndef isrealobj(x):\n return not asarray(x).typecode() in ['F', 'D']\n\n#-----------------------------------------------------------------------------\n\n##def isnan(val):\n## # fast, but apparently not portable (according to notes by Tim Peters)\n## #return val != val\n## # very slow -- should really use cephes methods or *something* different\n## import ieee_754\n## vals = ravel(val)\n## if array_iscomplex(vals):\n## r = array(map(ieee_754.isnan,real(vals))) \n## i = array(map(ieee_754.isnan,imag(vals)))\n## results = Numeric.logical_or(r,i)\n## else: \n## results = array(map(ieee_754.isnan,vals))\n## if isscalar(val):\n## results = results[0]\n## return results\n\ndef isposinf(val):\n return isinf(val) & (val > 0)\n \ndef isneginf(val):\n return isinf(val) & (val < 0)\n \n##def isinf(val):\n## return Numeric.logical_or(isposinf(val),isneginf(val))\n\n##def isfinite(val):\n## vals = asarray(val)\n## if iscomplexobj(vals):\n## r = isfinite(real(vals))\n## i = isfinite(imag(vals))\n## results = Numeric.logical_and(r,i)\n## else: \n## fin = Numeric.logical_not(isinf(val))\n## an = Numeric.logical_not(isnan(val))\n## results = Numeric.logical_and(fin,an)\n## return results \n\ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> limits.double_max\n # -Inf -> limits.double_min\n # complex not handled currently\n import limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [types.ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = Numeric.asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,limits.double_min, 0., limits.double_max))\n return y\n\n#-----------------------------------------------------------------------------\n\ndef real_if_close(a,tol=1e-13):\n a = Numeric.asarray(a)\n if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n\n\n#-----------------------------------------------------------------------------\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'w' : 'unsigned short',\n 'i' : 'integer',\n 'u' : 'unsigned integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\n#-----------------------------------------------------------------------------\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", "methods": [ { "name": "asarray", "long_name": "asarray( a , typecode = None , savespace = None )", "filename": "type_check.py", "nloc": 11, "complexity": 9, "token_count": 103, "parameters": [ "a", "typecode", "savespace" ], "start_line": 12, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "isscalar", "long_name": "isscalar( num )", "filename": "type_check.py", "nloc": 4, "complexity": 3, "token_count": 37, "parameters": [ "num" ], "start_line": 74, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "real", "long_name": "real( val )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 32, "parameters": [ "val" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "imag", "long_name": "imag( val )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "val" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iscomplex", "long_name": "iscomplex( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "x" ], "start_line": 93, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isreal", "long_name": "isreal( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "x" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplexobj", "long_name": "iscomplexobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "x" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isrealobj", "long_name": "isrealobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "x" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isposinf", "long_name": "isposinf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isneginf", "long_name": "isneginf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 126, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 17, "complexity": 3, "token_count": 117, "parameters": [ "x" ], "start_line": 144, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "real_if_close", "long_name": "real_if_close( a , tol = 1e - 13 )", "filename": "type_check.py", "nloc": 5, "complexity": 3, "token_count": 52, "parameters": [ "a", "tol" ], "start_line": 169, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "typename", "long_name": "typename( char )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "char" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "common_type", "long_name": "common_type( * arrays )", "filename": "type_check.py", "nloc": 8, "complexity": 2, "token_count": 54, "parameters": [ "arrays" ], "start_line": 204, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "isscalar", "long_name": "isscalar( num )", "filename": "type_check.py", "nloc": 4, "complexity": 3, "token_count": 37, "parameters": [ "num" ], "start_line": 59, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "real", "long_name": "real( val )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 32, "parameters": [ "val" ], "start_line": 64, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "imag", "long_name": "imag( val )", "filename": "type_check.py", "nloc": 6, "complexity": 2, "token_count": 43, "parameters": [ "val" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "iscomplex", "long_name": "iscomplex( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "x" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isreal", "long_name": "isreal( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "x" ], "start_line": 81, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "iscomplexobj", "long_name": "iscomplexobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "x" ], "start_line": 84, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isrealobj", "long_name": "isrealobj( x )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "x" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isposinf", "long_name": "isposinf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 108, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "isneginf", "long_name": "isneginf( val )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 111, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 17, "complexity": 3, "token_count": 119, "parameters": [ "x" ], "start_line": 129, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "real_if_close", "long_name": "real_if_close( a , tol = 1e - 13 )", "filename": "type_check.py", "nloc": 5, "complexity": 3, "token_count": 54, "parameters": [ "a", "tol" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "typename", "long_name": "typename( char )", "filename": "type_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "char" ], "start_line": 178, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "common_type", "long_name": "common_type( * arrays )", "filename": "type_check.py", "nloc": 8, "complexity": 2, "token_count": 54, "parameters": [ "arrays" ], "start_line": 189, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "asarray", "long_name": "asarray( a , typecode = None , savespace = None )", "filename": "type_check.py", "nloc": 11, "complexity": 9, "token_count": 103, "parameters": [ "a", "typecode", "savespace" ], "start_line": 12, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "real_if_close", "long_name": "real_if_close( a , tol = 1e - 13 )", "filename": "type_check.py", "nloc": 5, "complexity": 3, "token_count": 52, "parameters": [ "a", "tol" ], "start_line": 169, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "nan_to_num", "long_name": "nan_to_num( x )", "filename": "type_check.py", "nloc": 17, "complexity": 3, "token_count": 117, "parameters": [ "x" ], "start_line": 144, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "nloc": 138, "complexity": 31, "token_count": 1131, "diff_parsed": { "added": [ "from Numeric import ArrayType, array, multiarray", " 'typename','cast','common_type','typecodes', 'asarray']", "", "def asarray(a, typecode=None, savespace=None):", " \"\"\"asarray(a,typecode=None, savespace=0) returns a as a NumPy array.", " Unlike array(), no copy is performed if a is already an array.", " \"\"\"", " if type(a) is ArrayType:", " if typecode is None or typecode == a.typecode():", " if savespace is None or a.spacesaver()==savespace:", " return a", " else:", " r = a.astype(typecode)", " if not (savespace is None or a.spacesaver()==savespace):", " r.savespace(savespace)", " return r", " return multiarray.array(a,typecode,copy=0,savespace=savespace or 0)", "toChar = lambda x: asarray(x).astype(Char)", "toInt8 = lambda x: asarray(x).astype(Numeric.Int8)# or use variable names such as Byte", "toUInt8 = lambda x: asarray(x).astype(Numeric.UnsignedInt8)", " toUInt16 = lambda x: asarray(x).astype(Numeric.UnsignedInt16)", " toUInt32 = lambda x: asarray(x).astype(Numeric.UnsignedInt32)", "toInt16 = lambda x: asarray(x).astype(Numeric.Int16)", "toInt32 = lambda x: asarray(x).astype(Numeric.Int32)", "toInt = lambda x: asarray(x).astype(Numeric.Int)", "toFloat32 = lambda x: asarray(x).astype(Numeric.Float32)", "toFloat64 = lambda x: asarray(x).astype(Numeric.Float64)", "toComplex32 = lambda x: asarray(x).astype(Numeric.Complex32)", "toComplex64 = lambda x: asarray(x).astype(Numeric.Complex64)", " x = asarray(x)", " a = asarray(a)" ], "deleted": [ "from Numeric import asarray, ArrayType, array", " 'typename','cast','common_type','typecodes']", "toChar = lambda x: Numeric.asarray(x).astype(Char)", "toInt8 = lambda x: Numeric.asarray(x).astype(Numeric.Int8)# or use variable names such as Byte", "toUInt8 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt8)", " toUInt16 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt16)", " toUInt32 = lambda x: Numeric.asarray(x).astype(Numeric.UnsignedInt32)", "toInt16 = lambda x: Numeric.asarray(x).astype(Numeric.Int16)", "toInt32 = lambda x: Numeric.asarray(x).astype(Numeric.Int32)", "toInt = lambda x: Numeric.asarray(x).astype(Numeric.Int)", "toFloat32 = lambda x: Numeric.asarray(x).astype(Numeric.Float32)", "toFloat64 = lambda x: Numeric.asarray(x).astype(Numeric.Float64)", "toComplex32 = lambda x: Numeric.asarray(x).astype(Numeric.Complex32)", "toComplex64 = lambda x: Numeric.asarray(x).astype(Numeric.Complex64)", " x = Numeric.asarray(x)", " a = Numeric.asarray(a)" ] } } ] }, { "hash": "8ae8ab27ad2911433e3b2462a7ceadfd50a14e13", "msg": "Updated scipy complex divide to follow Matlab's convention: 0j/0 is nan, 1j/0 is nan+infj, 1/0 is inf. This fixes linalg.eig for various combinations of singular matrix arguments.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-13T14:52:16+00:00", "author_timezone": 0, "committer_date": "2003-12-13T14:52:16+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7f5e051feea78f8c72bc8d8597ecc406afb0cf22" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 4, "insertions": 12, "lines": 16, "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": "@@ -315,8 +315,12 @@ static Py_complex c_quot_fast(Py_complex a, Py_complex b)\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n- if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n- else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n+\t/* Using matlab's convention (x+0j is x):\n+\t (0+0j)/0 -> nan+0j\n+\t (0+xj)/0 -> nan+sign(x)*infj\n+\t (x+0j)/0 -> sign(x)*inf+0j\n+\t*/\n+\tif (a.imag == 0.0) {r.imag = 0.0;}\n return r;\n }\n \n", "added_lines": 6, "deleted_lines": 2, "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 r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n\t/* Using matlab's convention (x+0j is x):\n\t (0+0j)/0 -> nan+0j\n\t (0+xj)/0 -> nan+sign(x)*infj\n\t (x+0j)/0 -> sign(x)*inf+0j\n\t*/\n\tif (a.imag == 0.0) {r.imag = 0.0;}\n return 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 r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n return 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", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "\t/* Using matlab's convention (x+0j is x):", "\t (0+0j)/0 -> nan+0j", "\t (0+xj)/0 -> nan+sign(x)*infj", "\t (x+0j)/0 -> sign(x)*inf+0j", "\t*/", "\tif (a.imag == 0.0) {r.imag = 0.0;}" ], "deleted": [ " if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}", " else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}" ] } }, { "old_path": "scipy_base/fastumath_unsigned.inc", "new_path": "scipy_base/fastumath_unsigned.inc", "filename": "fastumath_unsigned.inc", "extension": "inc", "change_type": "MODIFY", "diff": "@@ -326,8 +326,12 @@ static Py_complex c_quot_fast(Py_complex a, Py_complex b)\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n- if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n- else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n+\t/* Using matlab's convention (x+0j is x):\n+\t (0+0j)/0 -> nan+0j\n+\t (0+xj)/0 -> nan+sign(x)*infj\n+\t (x+0j)/0 -> sign(x)*inf+0j\n+\t*/\n+\tif (a.imag == 0.0) {r.imag = 0.0;}\n return r;\n }\n if (abs_breal >= abs_bimag) {\n", "added_lines": 6, "deleted_lines": 2, "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 r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n\t/* Using matlab's convention (x+0j is x):\n\t (0+0j)/0 -> nan+0j\n\t (0+xj)/0 -> nan+sign(x)*infj\n\t (x+0j)/0 -> sign(x)*inf+0j\n\t*/\n\tif (a.imag == 0.0) {r.imag = 0.0;}\n return 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, CFLOAT_maximum, CDOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_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, 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 r.real = a.real / b.real;\n r.imag = a.imag / b.imag;\n if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}\n else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}\n return 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, CFLOAT_maximum, CDOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, USHORT_minimum, INT_minimum, UINT_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, 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", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "\t/* Using matlab's convention (x+0j is x):", "\t (0+0j)/0 -> nan+0j", "\t (0+xj)/0 -> nan+sign(x)*infj", "\t (x+0j)/0 -> sign(x)*inf+0j", "\t*/", "\tif (a.imag == 0.0) {r.imag = 0.0;}" ], "deleted": [ " if ((a.real == 0.0) && (a.imag != 0.0)) {r.real = 0.0;}", " else if ((a.real != 0.0) && (a.imag == 0.0)) {r.imag = 0.0;}" ] } } ] }, { "hash": "44ea2a2d255f00af037173aef163051a4b00fce5", "msg": "Added atlas_threads_info.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-13T18:12:29+00:00", "author_timezone": 0, "committer_date": "2003-12-13T18:12:29+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "8ae8ab27ad2911433e3b2462a7ceadfd50a14e13" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 1, "insertions": 7, "lines": 8, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,6 +5,7 @@\n include directories, etc.) in the system. Currently, the following\n classes are available:\n atlas_info\n+ atlas_threads_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n@@ -113,6 +114,7 @@\n \n def get_info(name):\n cl = {'atlas':atlas_info,\n+ 'atlas_threads':atlas_threads_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n@@ -434,6 +436,7 @@ def calc_info(self):\n class atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n+ _lib_names = ['f77blas','cblas']\n \n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n@@ -447,7 +450,7 @@ def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n- ['f77blas', 'cblas', 'atlas'])\n+ self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n@@ -509,6 +512,9 @@ def calc_info(self):\n warnings.warn(message)\n self.set_info(**info)\n \n+class atlas_threads_info(atlas_info):\n+ _lib_names = ['ptf77blas','ptcblas']\n+\n class lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n", "added_lines": 7, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n atlas_threads_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'atlas_threads':atlas_threads_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n _lib_names = ['f77blas','cblas']\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse*','3dnow'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n self._lib_names + ['atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n else:\n dict_append(info,**atlas)\n dict_append(define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass atlas_threads_info(atlas_info):\n _lib_names = ['ptf77blas','ptcblas']\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n blas_info\n lapack_info\n fftw_info,dfftw_info,sfftw_info\n fftw_threads_info,dfftw_threads_info,sfftw_threads_info\n djbfft_info\n x11_info\n lapack_src_info\n blas_src_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw','lapack','blas',\n 'lapack_src', or 'blas_src'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (system_info could not find it).\n\nGlobal parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n system_info.verbosity - output the results to stdout if enabled.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nThe order of finding the locations of resources is the following:\n 1. environment variable\n 2. section in site.cfg\n 3. DEFAULT section in site.cfg\nOnly the first complete match is returned.\n\nExample:\n----------\n[DEFAULT]\nlibrary_dirs = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dirs = /usr/include:/usr/local/include:/opt/include\nsrc_dirs = /usr/local/src:/opt/src\n# search static libraries (.a) in preference to shared ones (.so)\nsearch_static_first = 0\n\n[fftw]\nfftw_libs = rfftw, fftw\nfftw_opt_libs = rfftw_threaded, fftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlibrary_dirs = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = lapack, f77blas, cblas, atlas\n\n[x11]\nlibrary_dirs = /usr/X11R6/lib\ninclude_dirs = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nimport warnings\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_src_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_src_dirs = ['/usr/local/src', '/opt/src']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib','/usr/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include',\n '/usr/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.insert(0,os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n default_src_dirs.append(os.path.join(sys.prefix, 'src'))\n\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\ndefault_src_dirs = filter(os.path.isdir, default_src_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info,\n 'dfftw':dfftw_info,\n 'sfftw':sfftw_info,\n 'fftw_threads':fftw_threads_info,\n 'dfftw_threads':dfftw_threads_info,\n 'sfftw_threads':sfftw_threads_info,\n 'djbfft':djbfft_info,\n 'blas':blas_info,\n 'lapack':lapack_info,\n 'lapack_src':lapack_src_info,\n 'blas_src':blas_src_info,\n }.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [atlas]) or by setting\n the ATLAS environment variable.\"\"\"\n\nclass LapackNotFoundError(NotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [lapack]) or by setting\n the LAPACK environment variable.\"\"\"\n\nclass LapackSrcNotFoundError(LapackNotFoundError):\n \"\"\"\n Lapack (http://www.netlib.org/lapack/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [lapack_src]) or by setting\n the LAPACK_SRC environment variable.\"\"\"\n\nclass BlasNotFoundError(NotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [blas]) or by setting\n the BLAS environment variable.\"\"\"\n\nclass BlasSrcNotFoundError(BlasNotFoundError):\n \"\"\"\n Blas (http://www.netlib.org/blas/) sources not found.\n Directories to search for the sources can be specified in the\n scipy_distutils/site.cfg file (section [blas_src]) or by setting\n the BLAS_SRC environment variable.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [fftw]) or by setting\n the FFTW environment variable.\"\"\"\n\nclass DJBFFTNotFoundError(NotFoundError):\n \"\"\"\n DJBFFT (http://cr.yp.to/djbfft.html) libraries not found.\n Directories to search for the libraries can be specified in the\n scipy_distutils/site.cfg file (section [djbfft]) or by setting\n the DJBFFT environment variable.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://www.numpy.org/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n dir_env_var = None\n search_static_first = 0 # XXX: disabled by default, may disappear in\n # future unless it is proved to be useful.\n verbosity = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n verbosity = 1,\n ):\n self.__class__.info = {}\n self.local_prefixes = []\n defaults = {}\n defaults['library_dirs'] = os.pathsep.join(default_lib_dirs)\n defaults['include_dirs'] = os.pathsep.join(default_include_dirs)\n defaults['src_dirs'] = os.pathsep.join(default_src_dirs)\n defaults['search_static_first'] = str(self.search_static_first)\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.search_static_first = self.cp.getboolean(self.section,\n 'search_static_first')\n assert isinstance(self.search_static_first, type(0))\n\n def set_info(self,**info):\n self.saved_results[self.__class__.__name__] = info\n\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbosity>0:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbosity>0 and flag:\n for k,v in res.items():\n v = str(v)\n if k=='sources' and len(v)>200: v = v[:60]+' ...\\n... '+v[-60:]\n print ' %s = %s'%(k,v)\n print\n return res\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(os.pathsep)\n if os.environ.has_key(self.dir_env_var):\n dirs = os.environ[self.dir_env_var].split(os.pathsep) + dirs\n default_dirs = self.cp.get('DEFAULT', key).split(os.pathsep)\n dirs.extend(default_dirs)\n ret = []\n [ret.append(d) for d in dirs if os.path.isdir(d) and d not in ret]\n if self.verbosity>1:\n print '(',key,'=',':'.join(ret),')'\n return ret\n\n def get_lib_dirs(self, key='library_dirs'):\n return self.get_paths(self.section, key)\n\n def get_include_dirs(self, key='include_dirs'):\n return self.get_paths(self.section, key)\n\n def get_src_dirs(self, key='src_dirs'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n if self.search_static_first:\n exts = ['.a',so_ext]\n else:\n exts = [so_ext,'.a']\n for ext in exts:\n info = self._check_libs(lib_dir,libs,opt_libs,ext)\n if info is not None: return info\n\n def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n return liblist\n\n def _extract_lib_names(self,libs):\n return [os.path.splitext(os.path.basename(p))[0][3:] \\\n for p in libs]\n\n def _check_libs(self,lib_dir,libs, opt_libs, ext):\n found_libs = self._lib_list(lib_dir, libs, ext)\n if len(found_libs) == len(libs):\n found_libs = self._extract_lib_names(found_libs)\n info = {'libraries' : found_libs, 'library_dirs' : [lib_dir]}\n opt_found_libs = self._lib_list(lib_dir, opt_libs, ext)\n if len(opt_found_libs) == len(opt_libs):\n opt_found_libs = self._extract_lib_names(opt_found_libs)\n info['libraries'].extend(opt_found_libs)\n return info\n\n def combine_paths(self,*args):\n return combine_paths(*args,**{'verbosity':self.verbosity})\n\nclass fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw', 'fftw']\n includes = ['fftw.h','rfftw.h']\n macros = [('SCIPY_FFTW_H',None)]\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n libs = self.get_libs(self.section+'_libs', self.libs)\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(self.combine_paths(d,self.includes))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=self.macros)\n else:\n info = None\n if info is not None:\n self.set_info(**info)\n\nclass dfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw','dfftw']\n includes = ['dfftw.h','drfftw.h']\n macros = [('SCIPY_DFFTW_H',None)]\n\nclass sfftw_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw','sfftw']\n includes = ['sfftw.h','srfftw.h']\n macros = [('SCIPY_SFFTW_H',None)]\n\nclass fftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['rfftw_threads','fftw_threads']\n includes = ['fftw_threads.h','rfftw_threads.h']\n macros = [('SCIPY_FFTW_THREADS_H',None)]\n\nclass dfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['drfftw_threads','dfftw_threads']\n includes = ['dfftw_threads.h','drfftw_threads.h']\n macros = [('SCIPY_DFFTW_THREADS_H',None)]\n\nclass sfftw_threads_info(fftw_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n libs = ['srfftw_threads','sfftw_threads']\n includes = ['sfftw_threads.h','srfftw_threads.h']\n macros = [('SCIPY_SFFTW_THREADS_H',None)]\n\nclass djbfft_info(system_info):\n section = 'djbfft'\n dir_env_var = 'DJBFFT'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['djbfft'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n info = None\n for d in lib_dirs:\n p = self.combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n p = self.combine_paths (d,['libdjbfft.a'])\n if p:\n info = {'libraries':['djbfft'],'library_dirs':[d]}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:\n dict_append(info,include_dirs=[d],\n define_macros=[('SCIPY_DJBFFT_H',None)])\n self.set_info(**info)\n return\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n dir_env_var = 'ATLAS'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',\n 'sse*','3dnow'])+[d])\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n info = {}\n atlas_libs = self.get_libs('atlas_libs',\n ['f77blas', 'cblas', 'atlas'])\n lapack_libs = self.get_libs('lapack_libs',['lapack'])\n atlas = None\n lapack = None\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]\n for d2 in lib_dirs2:\n lapack = self.check_libs(d2,lapack_libs,[])\n if lapack is not None:\n break\n else:\n lapack = None\n if lapack is not None:\n break\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h:\n h = os.path.dirname(h)\n dict_append(info,include_dirs=[h])\n\n if lapack is not None:\n dict_append(info,**lapack)\n dict_append(info,**atlas)\n else:\n dict_append(info,**atlas)\n dict_append(define_macros=[('ATLAS_WITHOUT_LAPACK',None)])\n message = \"\"\"\n*********************************************************************\n Could not find lapack library within the ATLAS installation.\n*********************************************************************\n\"\"\"\n warnings.warn(message)\n self.set_info(**info)\n return\n # Check if lapack library is complete, only warn if it is not.\n lapack_dir = lapack['library_dirs'][0]\n lapack_name = lapack['libraries'][0]\n lapack_lib = None\n for e in ['.a',so_ext]:\n fn = os.path.join(lapack_dir,'lib'+lapack_name+e)\n if os.path.exists(fn):\n lapack_lib = fn\n break\n if lapack_lib is not None:\n sz = os.stat(lapack_lib)[6]\n if sz <= 4000*1024:\n message = \"\"\"\n*********************************************************************\n Lapack library (from ATLAS) is probably incomplete:\n size of %s is %sk (expected >4000k)\n\n Follow the instructions in the KNOWN PROBLEMS section of the file\n scipy/INSTALL.txt.\n*********************************************************************\n\"\"\" % (lapack_lib,sz/1024)\n warnings.warn(message)\n self.set_info(**info)\n\nclass lapack_info(system_info):\n section = 'lapack'\n dir_env_var = 'LAPACK'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n self.set_info(**info)\n\nclass lapack_src_info(system_info):\n section = 'lapack_src'\n dir_env_var = 'LAPACK_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'dgesv.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n # The following is extracted from LAPACK-3.0/SRC/Makefile\n allaux='''\n ilaenv ieeeck lsame lsamen xerbla\n ''' # *.f\n laux = '''\n bdsdc bdsqr disna labad lacpy ladiv lae2 laebz laed0 laed1\n laed2 laed3 laed4 laed5 laed6 laed7 laed8 laed9 laeda laev2\n lagtf lagts lamch lamrg lanst lapy2 lapy3 larnv larrb larre\n larrf lartg laruv las2 lascl lasd0 lasd1 lasd2 lasd3 lasd4\n lasd5 lasd6 lasd7 lasd8 lasd9 lasda lasdq lasdt laset lasq1\n lasq2 lasq3 lasq4 lasq5 lasq6 lasr lasrt lassq lasv2 pttrf\n stebz stedc steqr sterf\n ''' # [s|d]*.f\n lasrc = '''\n gbbrd gbcon gbequ gbrfs gbsv gbsvx gbtf2 gbtrf gbtrs gebak\n gebal gebd2 gebrd gecon geequ gees geesx geev geevx gegs gegv\n gehd2 gehrd gelq2 gelqf gels gelsd gelss gelsx gelsy geql2\n geqlf geqp3 geqpf geqr2 geqrf gerfs gerq2 gerqf gesc2 gesdd\n gesv gesvd gesvx getc2 getf2 getrf getri getrs ggbak ggbal\n gges ggesx ggev ggevx ggglm gghrd gglse ggqrf ggrqf ggsvd\n ggsvp gtcon gtrfs gtsv gtsvx gttrf gttrs gtts2 hgeqz hsein\n hseqr labrd lacon laein lags2 lagtm lahqr lahrd laic1 lals0\n lalsa lalsd langb lange langt lanhs lansb lansp lansy lantb\n lantp lantr lapll lapmt laqgb laqge laqp2 laqps laqsb laqsp\n laqsy lar1v lar2v larf larfb larfg larft larfx largv larrv\n lartv larz larzb larzt laswp lasyf latbs latdf latps latrd\n latrs latrz latzm lauu2 lauum pbcon pbequ pbrfs pbstf pbsv\n pbsvx pbtf2 pbtrf pbtrs pocon poequ porfs posv posvx potf2\n potrf potri potrs ppcon ppequ pprfs ppsv ppsvx pptrf pptri\n pptrs ptcon pteqr ptrfs ptsv ptsvx pttrs ptts2 spcon sprfs\n spsv spsvx sptrf sptri sptrs stegr stein sycon syrfs sysv\n sysvx sytf2 sytrf sytri sytrs tbcon tbrfs tbtrs tgevc tgex2\n tgexc tgsen tgsja tgsna tgsy2 tgsyl tpcon tprfs tptri tptrs\n trcon trevc trexc trrfs trsen trsna trsyl trti2 trtri trtrs\n tzrqf tzrzf\n ''' # [s|c|d|z]*.f\n sd_lasrc = '''\n laexc lag2 lagv2 laln2 lanv2 laqtr lasy2 opgtr opmtr org2l\n org2r orgbr orghr orgl2 orglq orgql orgqr orgr2 orgrq orgtr\n orm2l orm2r ormbr ormhr orml2 ormlq ormql ormqr ormr2 ormr3\n ormrq ormrz ormtr rscl sbev sbevd sbevx sbgst sbgv sbgvd sbgvx\n sbtrd spev spevd spevx spgst spgv spgvd spgvx sptrd stev stevd\n stevr stevx syev syevd syevr syevx sygs2 sygst sygv sygvd\n sygvx sytd2 sytrd\n ''' # [s|d]*.f\n cz_lasrc = '''\n bdsqr hbev hbevd hbevx hbgst hbgv hbgvd hbgvx hbtrd hecon heev\n heevd heevr heevx hegs2 hegst hegv hegvd hegvx herfs hesv\n hesvx hetd2 hetf2 hetrd hetrf hetri hetrs hpcon hpev hpevd\n hpevx hpgst hpgv hpgvd hpgvx hprfs hpsv hpsvx hptrd hptrf\n hptri hptrs lacgv lacp2 lacpy lacrm lacrt ladiv laed0 laed7\n laed8 laesy laev2 lahef lanhb lanhe lanhp lanht laqhb laqhe\n laqhp larcm larnv lartg lascl laset lasr lassq pttrf rot spmv\n spr stedc steqr symv syr ung2l ung2r ungbr unghr ungl2 unglq\n ungql ungqr ungr2 ungrq ungtr unm2l unm2r unmbr unmhr unml2\n unmlq unmql unmqr unmr2 unmr3 unmrq unmrz unmtr upgtr upmtr\n ''' # [c|z]*.f\n #######\n sclaux = laux + ' econd ' # s*.f\n dzlaux = laux + ' secnd ' # d*.f\n slasrc = lasrc + sd_lasrc # s*.f\n dlasrc = lasrc + sd_lasrc # d*.f\n clasrc = lasrc + cz_lasrc + ' srot srscl ' # c*.f\n zlasrc = lasrc + cz_lasrc + ' drot drscl ' # z*.f\n oclasrc = ' icmax1 scsum1 ' # *.f\n ozlasrc = ' izmax1 dzsum1 ' # *.f\n sources = ['s%s.f'%f for f in (sclaux+slasrc).split()] \\\n + ['d%s.f'%f for f in (dzlaux+dlasrc).split()] \\\n + ['c%s.f'%f for f in (clasrc).split()] \\\n + ['z%s.f'%f for f in (zlasrc).split()] \\\n + ['%s.f'%f for f in (allaux+oclasrc+ozlasrc).split()]\n sources = [os.path.join(src_dir,f) for f in sources]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n section = 'blas'\n dir_env_var = 'BLAS'\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n\n blas_libs = self.get_libs('blas_libs', ['blas'])\n for d in lib_dirs:\n blas = self.check_libs(d,blas_libs,[])\n if blas is not None:\n info = blas \n break\n else:\n return\n self.set_info(**info)\n\nclass blas_src_info(system_info):\n section = 'blas_src'\n dir_env_var = 'BLAS_SRC'\n\n def get_paths(self, section, key):\n pre_dirs = system_info.get_paths(self, section, key)\n dirs = []\n for d in pre_dirs:\n dirs.extend([d] + self.combine_paths(d,['blas']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n src_dirs = self.get_src_dirs()\n src_dir = ''\n for d in src_dirs:\n if os.path.isfile(os.path.join(d,'daxpy.f')):\n src_dir = d\n break\n if not src_dir:\n #XXX: Get sources from netlib. May be ask first.\n return\n blas1 = '''\n caxpy csscal dnrm2 dzasum saxpy srotg zdotc ccopy cswap drot\n dznrm2 scasum srotm zdotu cdotc dasum drotg icamax scnrm2\n srotmg zdrot cdotu daxpy drotm idamax scopy sscal zdscal crotg\n dcabs1 drotmg isamax sdot sswap zrotg cscal dcopy dscal izamax\n snrm2 zaxpy zscal csrot ddot dswap sasum srot zcopy zswap\n '''\n blas2 = '''\n cgbmv chpmv ctrsv dsymv dtrsv sspr2 strmv zhemv ztpmv cgemv\n chpr dgbmv dsyr lsame ssymv strsv zher ztpsv cgerc chpr2 dgemv\n dsyr2 sgbmv ssyr xerbla zher2 ztrmv cgeru ctbmv dger dtbmv\n sgemv ssyr2 zgbmv zhpmv ztrsv chbmv ctbsv dsbmv dtbsv sger\n stbmv zgemv zhpr chemv ctpmv dspmv dtpmv ssbmv stbsv zgerc\n zhpr2 cher ctpsv dspr dtpsv sspmv stpmv zgeru ztbmv cher2\n ctrmv dspr2 dtrmv sspr stpsv zhbmv ztbsv\n '''\n blas3 = '''\n cgemm csymm ctrsm dsyrk sgemm strmm zhemm zsyr2k chemm csyr2k\n dgemm dtrmm ssymm strsm zher2k zsyrk cher2k csyrk dsymm dtrsm\n ssyr2k zherk ztrmm cherk ctrmm dsyr2k ssyrk zgemm zsymm ztrsm\n '''\n sources = [os.path.join(src_dir,f+'.f') \\\n for f in (blas1+blas2+blas3).split()]\n #XXX: should we check here actual existence of source files?\n info = {'sources':sources}\n self.set_info(**info)\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform in ['win32','cygwin']:\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if self.combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n verbosity = kws.get('verbosity',1)\n if verbosity>1 and result:\n print '(','paths:',','.join(result),')'\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n if k in ['library_dirs','include_dirs','define_macros']:\n [d[k].append(vv) for vv in v if vv not in d[k]]\n else:\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n c.verbosity = 2\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", "methods": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 17, "complexity": 1, "token_count": 84, "parameters": [ "name" ], "start_line": 115, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 21, "complexity": 2, "token_count": 186, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 209, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 231, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 234, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 237, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 6, "token_count": 138, "parameters": [ "self", "section", "key" ], "start_line": 263, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 278, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 281, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 284, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 291, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 302, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 316, "end_line": 325, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 327, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 337, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 340, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 406, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 413, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 72, "parameters": [ "self", "section", "key" ], "start_line": 441, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 63, "complexity": 14, "token_count": 352, "parameters": [ "self" ], "start_line": 449, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 522, "end_line": 533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 539, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 546, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 637, "end_line": 648, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 654, "end_line": 659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 661, "end_line": 696, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 701, "end_line": 704, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 706, "end_line": 725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 727, "end_line": 751, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 753, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 763, "end_line": 771, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 16, "complexity": 1, "token_count": 80, "parameters": [ "name" ], "start_line": 114, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , verbosity = 1 , )", "filename": "system_info.py", "nloc": 21, "complexity": 2, "token_count": 186, "parameters": [ "self", "default_lib_dirs", "default_include_dirs", "verbosity" ], "start_line": 207, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "set_info", "long_name": "set_info( self , ** info )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "info" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "has_info", "long_name": "has_info( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 232, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( self )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 153, "parameters": [ "self" ], "start_line": 235, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 11, "complexity": 6, "token_count": 138, "parameters": [ "self", "section", "key" ], "start_line": 261, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_lib_dirs", "long_name": "get_lib_dirs( self , key = 'library_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 273, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_include_dirs", "long_name": "get_include_dirs( self , key = 'include_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 276, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_src_dirs", "long_name": "get_src_dirs( self , key = 'src_dirs' )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "key" ], "start_line": 279, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_libs", "long_name": "get_libs( self , key , default )", "filename": "system_info.py", "nloc": 6, "complexity": 3, "token_count": 49, "parameters": [ "self", "key", "default" ], "start_line": 282, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_libs", "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", "filename": "system_info.py", "nloc": 8, "complexity": 4, "token_count": 63, "parameters": [ "self", "lib_dir", "libs", "opt_libs" ], "start_line": 289, "end_line": 298, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "_lib_list", "long_name": "_lib_list( self , lib_dir , libs , ext )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 65, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 300, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_extract_lib_names", "long_name": "_extract_lib_names( self , libs )", "filename": "system_info.py", "nloc": 3, "complexity": 2, "token_count": 37, "parameters": [ "self", "libs" ], "start_line": 310, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_check_libs", "long_name": "_check_libs( self , lib_dir , libs , opt_libs , ext )", "filename": "system_info.py", "nloc": 10, "complexity": 3, "token_count": 99, "parameters": [ "self", "lib_dir", "libs", "opt_libs", "ext" ], "start_line": 314, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( self , * args )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "args" ], "start_line": 325, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 335, "end_line": 336, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 26, "complexity": 8, "token_count": 150, "parameters": [ "self" ], "start_line": 338, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 404, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 21, "complexity": 7, "token_count": 139, "parameters": [ "self" ], "start_line": 411, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 72, "parameters": [ "self", "section", "key" ], "start_line": 438, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 63, "complexity": 14, "token_count": 352, "parameters": [ "self" ], "start_line": 446, "end_line": 510, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 516, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 68, "parameters": [ "self", "section", "key" ], "start_line": 533, "end_line": 538, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 81, "complexity": 10, "token_count": 228, "parameters": [ "self" ], "start_line": 540, "end_line": 624, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 85, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 11, "complexity": 3, "token_count": 62, "parameters": [ "self" ], "start_line": 631, "end_line": 642, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 6, "complexity": 4, "token_count": 66, "parameters": [ "self", "section", "key" ], "start_line": 648, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 34, "complexity": 5, "token_count": 102, "parameters": [ "self" ], "start_line": 655, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "system_info.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 695, "end_line": 698, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 20, "complexity": 7, "token_count": 116, "parameters": [ "self" ], "start_line": 700, "end_line": 719, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args , ** kws )", "filename": "system_info.py", "nloc": 22, "complexity": 11, "token_count": 195, "parameters": [ "args", "kws" ], "start_line": 721, "end_line": 745, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "dict_append", "long_name": "dict_append( d , ** kws )", "filename": "system_info.py", "nloc": 9, "complexity": 6, "token_count": 80, "parameters": [ "d", "kws" ], "start_line": 747, "end_line": 755, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "show_all", "long_name": "show_all( )", "filename": "system_info.py", "nloc": 9, "complexity": 3, "token_count": 64, "parameters": [], "start_line": 757, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 63, "complexity": 14, "token_count": 352, "parameters": [ "self" ], "start_line": 449, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "get_info", "long_name": "get_info( name )", "filename": "system_info.py", "nloc": 17, "complexity": 1, "token_count": 84, "parameters": [ "name" ], "start_line": 115, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 } ], "nloc": 686, "complexity": 136, "token_count": 3514, "diff_parsed": { "added": [ " atlas_threads_info", " 'atlas_threads':atlas_threads_info,", " _lib_names = ['f77blas','cblas']", " self._lib_names + ['atlas'])", "class atlas_threads_info(atlas_info):", " _lib_names = ['ptf77blas','ptcblas']", "" ], "deleted": [ " ['f77blas', 'cblas', 'atlas'])" ] } } ] }, { "hash": "fb700bfdb970f8fb92d01c54726aa3420e46ab02", "msg": "ifc-8 requires -nofor_main. Added athlon-mp opt. flags. Enabled sse again.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-13T20:12:40+00:00", "author_timezone": 0, "committer_date": "2003-12-13T20:12:40+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "44ea2a2d255f00af037173aef163051a4b00fce5" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 4, "insertions": 13, "lines": 17, "files": 2, "dmm_unit_size": 0.7142857142857143, "dmm_unit_complexity": 0.7142857142857143, "dmm_unit_interfacing": 1.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": "@@ -1094,6 +1094,9 @@ def get_opt(self):\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n+ elif cpu.is_AthlonMP():\n+ opt = opt + ' -march=athlon-mp '\n+ # there's also: athlon-tbird, athlon-4, athlon-xp\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n@@ -1103,9 +1106,9 @@ def get_opt(self):\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx ' \n- if self.version > '3.2.2' and cpu.has_sse2():\n- opt = opt + ' -msse2 '\n- elif 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_sse(): opt = opt + ' -msse '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n@@ -1217,11 +1220,13 @@ def get_opt(self):\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n- elif cpu.has_mmx():\n+ if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n \n def get_linker_so(self):\n+ if self.get_version() and self.version >= '8.0':\n+ return [self.f77_compiler,'-shared','-nofor_main']\n return [self.f77_compiler,'-shared']\n \n def build_module_switch(self,module_dirs,temp_dir):\n", "added_lines": 9, "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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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_AthlonMP():\n opt = opt + ' -march=athlon-mp '\n # there's also: athlon-tbird, athlon-4, athlon-xp\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 self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n if self.get_version() and self.version >= '8.0':\n return [self.f77_compiler,'-shared','-nofor_main']\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 intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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 self.version > '3.2.2' and cpu.has_sse2():\n opt = opt + ' -msse2 '\n elif cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 64, "complexity": 31, "token_count": 372, "parameters": [ "self" ], "start_line": 1060, "end_line": 1127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1129, "end_line": 1145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1147, "end_line": 1153, "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": 1155, "end_line": 1163, "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": 1165, "end_line": 1166, "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": 1168, "end_line": 1169, "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": 1180, "end_line": 1209, "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": 1211, "end_line": 1225, "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": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1227, "end_line": 1230, "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": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1232, "end_line": 1241, "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": 1250, "end_line": 1253, "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": 20, "complexity": 4, "token_count": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1269, "end_line": 1297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1299, "end_line": 1313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1316, "end_line": 1325, "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": 1335, "end_line": 1338, "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": 1345, "end_line": 1366, "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": 1368, "end_line": 1370, "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": 1372, "end_line": 1373, "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": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1387, "end_line": 1415, "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": 1421, "end_line": 1422, "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": 1435, "end_line": 1466, "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": 1468, "end_line": 1469, "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": 1477, "end_line": 1501, "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": 1503, "end_line": 1506, "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": 1508, "end_line": 1512, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1528, "end_line": 1556, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1558, "end_line": 1560, "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": 1570, "end_line": 1595, "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": 1597, "end_line": 1599, "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": 1601, "end_line": 1602, "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": 1610, "end_line": 1635, "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": 1637, "end_line": 1638, "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": 1640, "end_line": 1643, "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": 1645, "end_line": 1651, "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": 1656, "end_line": 1664, "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": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 62, "complexity": 30, "token_count": 359, "parameters": [ "self" ], "start_line": 1060, "end_line": 1124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1126, "end_line": 1142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1144, "end_line": 1150, "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": 1152, "end_line": 1160, "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": 1162, "end_line": 1163, "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": 1165, "end_line": 1166, "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": 1177, "end_line": 1206, "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": 1208, "end_line": 1222, "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": 1224, "end_line": 1225, "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": 1227, "end_line": 1236, "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": 1245, "end_line": 1248, "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": 20, "complexity": 4, "token_count": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1264, "end_line": 1292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1294, "end_line": 1308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1311, "end_line": 1320, "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": 1330, "end_line": 1333, "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": 1340, "end_line": 1361, "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": 1363, "end_line": 1365, "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": 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": 24, "complexity": 6, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1382, "end_line": 1410, "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": 1416, "end_line": 1417, "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": 1430, "end_line": 1461, "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": 1463, "end_line": 1464, "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": 1472, "end_line": 1496, "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": 1498, "end_line": 1501, "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": 1503, "end_line": 1507, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1523, "end_line": 1551, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1553, "end_line": 1555, "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": 1565, "end_line": 1590, "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": 1592, "end_line": 1594, "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": 1596, "end_line": 1597, "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": 1605, "end_line": 1630, "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": 1632, "end_line": 1633, "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": 1635, "end_line": 1638, "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": 1640, "end_line": 1646, "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": 1651, "end_line": 1659, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1227, "end_line": 1230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 64, "complexity": 31, "token_count": 372, "parameters": [ "self" ], "start_line": 1060, "end_line": 1127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 } ], "nloc": 1243, "complexity": 329, "token_count": 7263, "diff_parsed": { "added": [ " elif cpu.is_AthlonMP():", " opt = opt + ' -march=athlon-mp '", " # there's also: athlon-tbird, athlon-4, athlon-xp", " if self.version > '3.2.2':", " if cpu.has_sse2(): opt = opt + ' -msse2 '", " if cpu.has_sse(): opt = opt + ' -msse '", " if cpu.has_mmx():", " if self.get_version() and self.version >= '8.0':", " return [self.f77_compiler,'-shared','-nofor_main']" ], "deleted": [ " if self.version > '3.2.2' and cpu.has_sse2():", " opt = opt + ' -msse2 '", " elif cpu.has_sse(): opt = opt + ' -msse '", " elif cpu.has_mmx():" ] } }, { "old_path": "scipy_distutils/command/cpuinfo.py", "new_path": "scipy_distutils/command/cpuinfo.py", "filename": "cpuinfo.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -87,6 +87,10 @@ def _is_AthlonK6(self):\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n \n+ def _is_AthlonMP(self):\n+ return re.match(r'.*?Athlon\\(tm\\) MP\\b',\n+ self.info[0]['model name']) is not None\n+\n def _is_AthlonHX(self):\n return re.match(r'.*?Athlon HX\\b',\n self.info[0]['model name']) is not None\n", "added_lines": 4, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n def _getNCPUs(self):\n return 1\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6_2(self):\n return self._is_AMD() and self.info[0]['model'] == '2'\n\n def _is_AthlonK6_3(self):\n return self._is_AMD() and self.info[0]['model'] == '3'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n def _is_AthlonMP(self):\n return re.match(r'.*?Athlon\\(tm\\) MP\\b',\n self.info[0]['model name']) is not None\n\n def _is_AthlonHX(self):\n return re.match(r'.*?Athlon HX\\b',\n self.info[0]['model name']) is not None\n\n def _is_Opteron(self):\n return re.match(r'.*?Opteron\\b',\n self.info[0]['model name']) is not None\n\n def _is_Hammer(self):\n return re.match(r'.*?Hammer\\b',\n self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium.*?II\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumPro(self):\n return re.match(r'.*?PentiumPro\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumMMX(self):\n return re.match(r'.*?Pentium.*?MMX\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium.*?III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium.*?(IV|4)\\b',\n self.info[0]['model name']) is not None\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['model name']) is not None\n\n\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\n def _has_3dnowext(self):\n return re.match(r'.*?\\b3dnowext\\b',self.info[0]['flags']) is not None\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def _getNCPUs(self):\n return int(self.info[0].get('NUM_PROCESSORS'))\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\nclass darwin_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('machine')\n if not status:\n if not info: info.append({})\n info[-1]['machine'] = string.strip(output)\n status,output = commands.getstatusoutput('sysctl hw')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['sysctl_hw'] = d\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _getNCPUs(self):\n try: return int(self.info[0]['sysctl_hw']['hw.ncpu'])\n except: return 1\n\n def _is_Power_Macintosh(self):\n return self.info[0]['sysctl_hw']['hw.machine']=='Power Macintosh'\n\n def _is_i386(self):\n return self.info[0]['arch']=='i386'\n def _is_ppc(self):\n return self.info[0]['arch']=='ppc'\n\n def __machine(self,n):\n return self.info[0]['machine'] == 'ppc%s'%n\n def _is_ppc601(self): return self.__machine(601)\n def _is_ppc602(self): return self.__machine(602)\n def _is_ppc603(self): return self.__machine(603)\n def _is_ppc603e(self): return self.__machine('603e')\n def _is_ppc604(self): return self.__machine(604)\n def _is_ppc604e(self): return self.__machine('604e')\n def _is_ppc620(self): return self.__machine(620)\n def _is_ppc630(self): return self.__machine(630)\n def _is_ppc740(self): return self.__machine(740)\n def _is_ppc7400(self): return self.__machine(7400)\n def _is_ppc7450(self): return self.__machine(7450)\n def _is_ppc750(self): return self.__machine(750)\n def _is_ppc403(self): return self.__machine(403)\n def _is_ppc505(self): return self.__machine(505)\n def _is_ppc801(self): return self.__machine(801)\n def _is_ppc821(self): return self.__machine(821)\n def _is_ppc823(self): return self.__machine(823)\n def _is_ppc860(self): return self.__machine(860)\n\nclass sunos_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('mach')\n if not status:\n if not info: info.append({})\n info[-1]['mach'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -i')\n if not status:\n if not info: info.append({})\n info[-1]['uname_i'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -X')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['uname_X'] = d\n status,output = commands.getstatusoutput('isainfo -b')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_b'] = string.strip(output)\n status,output = commands.getstatusoutput('isainfo -n')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_n'] = string.strip(output)\n status,output = commands.getstatusoutput('psrinfo -v 0')\n if not status:\n if not info: info.append({})\n for l in string.split(output,'\\n'):\n m = re.match(r'\\s*The (?P

[\\w\\d]+) processor operates at',l)\n if m:\n info[-1]['processor'] = m.group('p')\n break\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _is_32bit(self):\n return self.info[0]['isainfo_b']=='32'\n def _is_64bit(self):\n return self.info[0]['isainfo_b']=='64'\n\n def _is_i386(self):\n return self.info[0]['isainfo_n']=='i386'\n def _is_sparc(self):\n return self.info[0]['isainfo_n']=='sparc'\n def _is_sparcv9(self):\n return self.info[0]['isainfo_n']=='sparcv9'\n\n def _getNCPUs(self):\n try: return int(self.info[0]['uname_X']['NumCPU'])\n except: return 1\n\n def _is_sun4(self):\n return self.info[0]['arch']=='sun4'\n\n def _is_SUNW(self):\n return re.match(r'SUNW',self.info[0]['uname_i']) is not None\n def _is_sparcstation5(self):\n return re.match(r'.*SPARCstation-5',self.info[0]['uname_i']) is not None\n def _is_ultra1(self):\n return re.match(r'.*Ultra-1',self.info[0]['uname_i']) is not None\n def _is_ultra250(self):\n return re.match(r'.*Ultra-250',self.info[0]['uname_i']) is not None\n def _is_ultra2(self):\n return re.match(r'.*Ultra-2',self.info[0]['uname_i']) is not None\n def _is_ultra30(self):\n return re.match(r'.*Ultra-30',self.info[0]['uname_i']) is not None\n def _is_ultra4(self):\n return re.match(r'.*Ultra-4',self.info[0]['uname_i']) is not None\n def _is_ultra5_10(self):\n return re.match(r'.*Ultra-5_10',self.info[0]['uname_i']) is not None\n def _is_ultra5(self):\n return re.match(r'.*Ultra-5',self.info[0]['uname_i']) is not None\n def _is_ultra60(self):\n return re.match(r'.*Ultra-60',self.info[0]['uname_i']) is not None\n def _is_ultra80(self):\n return re.match(r'.*Ultra-80',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice(self):\n return re.match(r'.*Ultra-Enterprise',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice10k(self):\n return re.match(r'.*Ultra-Enterprise-10000',self.info[0]['uname_i']) is not None\n def _is_sunfire(self):\n return re.match(r'.*Sun-Fire',self.info[0]['uname_i']) is not None\n def _is_ultra(self):\n return re.match(r'.*Ultra',self.info[0]['uname_i']) is not None\n\n def _is_cpusparcv7(self):\n return self.info[0]['processor']=='sparcv7'\n def _is_cpusparcv8(self):\n return self.info[0]['processor']=='sparcv8'\n def _is_cpusparcv9(self):\n return self.info[0]['processor']=='sparcv9'\n\nclass win32_cpuinfo(cpuinfo_base):\n\n info = None\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n # XXX: what does the value of\n # HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\n # mean?\n\n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n #XXX: Bad style to use so long `try:...except:...`. Fix it!\n import _winreg\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n prgx = re.compile(r\"family\\s+(?P\\d+)\\s+model\\s+(?P\\d+)\"\\\n \"\\s+stepping\\s+(?P\\d+)\",re.IGNORECASE)\n chnd=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,pkey)\n pnum=0\n while 1:\n try:\n proc=_winreg.EnumKey(chnd,pnum)\n except _winreg.error:\n break\n else:\n pnum+=1\n print proc\n info.append({\"Processor\":proc})\n phnd=_winreg.OpenKey(chnd,proc)\n pidx=0\n while True:\n try:\n name,value,vtpe=_winreg.EnumValue(phnd,pidx)\n except _winreg.error:\n break\n else:\n pidx=pidx+1\n info[-1][name]=value\n if name==\"Identifier\":\n srch=prgx.search(value)\n if srch:\n info[-1][\"Family\"]=int(srch.group(\"FML\"))\n info[-1][\"Model\"]=int(srch.group(\"MDL\"))\n info[-1][\"Stepping\"]=int(srch.group(\"STP\"))\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['VendorIdentifier']=='AuthenticAMD'\n\n def _is_Am486(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_Am5x86(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_AMDK5(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [0,1,2,3]\n\n def _is_AMDK6(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [6,7]\n\n def _is_AMDK6_2(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==8\n\n def _is_AMDK6_3(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==9\n\n def _is_Athlon(self):\n return self.is_AMD() and self.info[0]['Family']==6\n\n def _is_Athlon64(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==4\n\n def _is_Opteron(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==5\n\n # Intel\n\n def _is_Intel(self):\n return self.info[0]['VendorIdentifier']=='GenuineIntel'\n\n def _is_i386(self):\n return self.info[0]['Family']==3\n\n def _is_i486(self):\n return self.info[0]['Family']==4\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['Family']==6\n\n def _is_Pentium(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_PentiumMMX(self):\n return self.is_Intel() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==4\n\n def _is_PentiumPro(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model']==1\n\n def _is_PentiumII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [3,5,6]\n\n def _is_PentiumIII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [7,8,9,10,11]\n\n def _is_PentiumIV(self):\n return self.is_Intel() and self.info[0]['Family']==15\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_mmx(self):\n if self.is_Intel():\n return (self.info[0]['Family']==5 and self.info[0]['Model']==4) \\\n or (self.info[0]['Family'] in [6,15])\n elif self.is_AMD():\n return self.info[0]['Family'] in [5,6,15]\n\n def _has_sse(self):\n if self.is_Intel():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [7,8,9,10,11]) \\\n or self.info[0]['Family']==15\n elif self.is_AMD():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [6,7,8,10]) \\\n or self.info[0]['Family']==15\n\n def _has_sse2(self):\n return self.info[0]['Family']==15\n\n def _has_3dnow(self):\n # XXX: does only AMD have 3dnow??\n return self.is_AMD() and self.info[0]['Family'] in [5,6,15]\n\n def _has_3dnowext(self):\n return self.is_AMD() and self.info[0]['Family'] in [6,15]\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\nelif sys.platform == 'darwin':\n cpuinfo = darwin_cpuinfo\nelif sys.platform[:5] == 'sunos':\n cpuinfo = sunos_cpuinfo\nelif sys.platform[:5] == 'win32':\n cpuinfo = win32_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_':\n r = getattr(cpu,name[1:])()\n if r:\n if r!=1:\n print '%s=%s' %(name[1:],r),\n else:\n print name[1:],\n print\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\ncpuinfo\n\nCopyright 2002 Pearu Peterson all rights reserved,\nPearu Peterson \nPermission to use, modify, and distribute this software is given under the \nterms of the SciPy (BSD style) license. See LICENSE.txt that came with\nthis distribution for specifics.\n\nNote: This should be merged into proc at some point. Perhaps proc should\nbe returning classes like this instead of using dictionaries.\n\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n$Revision$\n$Date$\nPearu Peterson\n\"\"\"\n\n__version__ = \"$Id$\"\n\n__all__ = ['cpuinfo']\n\nimport sys,string,re,types\n\nclass cpuinfo_base:\n \"\"\"Holds CPU information and provides methods for requiring\n the availability of various CPU features.\n \"\"\"\n\n def _try_call(self,func):\n try:\n return func()\n except:\n pass\n\n def __getattr__(self,name):\n if name[0]!='_':\n if hasattr(self,'_'+name):\n attr = getattr(self,'_'+name)\n if type(attr) is types.MethodType:\n return lambda func=self._try_call,attr=attr : func(attr)\n else:\n return lambda : None\n raise AttributeError,name \n\n def _getNCPUs(self):\n return 1\n\nclass linux_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n for line in open('/proc/cpuinfo').readlines():\n name_value = map(string.strip,string.split(line,':',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info or info[-1].has_key(name): # next processor\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['vendor_id']=='AuthenticAMD'\n\n def _is_AthlonK6_2(self):\n return self._is_AMD() and self.info[0]['model'] == '2'\n\n def _is_AthlonK6_3(self):\n return self._is_AMD() and self.info[0]['model'] == '3'\n\n def _is_AthlonK6(self):\n return re.match(r'.*?AMD-K6',self.info[0]['model name']) is not None\n\n def _is_AthlonK7(self):\n return re.match(r'.*?AMD-K7',self.info[0]['model name']) is not None\n\n def _is_AthlonHX(self):\n return re.match(r'.*?Athlon HX\\b',\n self.info[0]['model name']) is not None\n\n def _is_Opteron(self):\n return re.match(r'.*?Opteron\\b',\n self.info[0]['model name']) is not None\n\n def _is_Hammer(self):\n return re.match(r'.*?Hammer\\b',\n self.info[0]['model name']) is not None\n\n # Alpha\n\n def _is_Alpha(self):\n return self.info[0]['cpu']=='Alpha'\n\n def _is_EV4(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV4'\n\n def _is_EV5(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV5'\n\n def _is_EV56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'EV56'\n\n def _is_PCA56(self):\n return self.is_Alpha() and self.info[0]['cpu model'] == 'PCA56'\n\n # Intel\n\n #XXX\n _is_i386 = _not_impl\n\n def _is_Intel(self):\n return self.info[0]['vendor_id']=='GenuineIntel'\n\n def _is_i486(self):\n return self.info[0]['cpu']=='i486'\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '5'\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['cpu family'] == '6'\n\n def _is_Celeron(self):\n return re.match(r'.*?Celeron',\n self.info[0]['model name']) is not None\n\n def _is_Pentium(self):\n return re.match(r'.*?Pentium',\n self.info[0]['model name']) is not None\n\n def _is_PentiumII(self):\n return re.match(r'.*?Pentium.*?II\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumPro(self):\n return re.match(r'.*?PentiumPro\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumMMX(self):\n return re.match(r'.*?Pentium.*?MMX\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIII(self):\n return re.match(r'.*?Pentium.*?III\\b',\n self.info[0]['model name']) is not None\n\n def _is_PentiumIV(self):\n return re.match(r'.*?Pentium.*?(IV|4)\\b',\n self.info[0]['model name']) is not None\n\n def _is_Itanium(self):\n return re.match(r'.*?Itanium\\b',\n self.info[0]['model name']) is not None\n\n\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_fdiv_bug(self):\n return self.info[0]['fdiv_bug']=='yes'\n\n def _has_f00f_bug(self):\n return self.info[0]['f00f_bug']=='yes'\n\n def _has_mmx(self):\n return re.match(r'.*?\\bmmx\\b',self.info[0]['flags']) is not None\n\n def _has_sse(self):\n return re.match(r'.*?\\bsse\\b',self.info[0]['flags']) is not None\n\n def _has_sse2(self):\n return re.match(r'.*?\\bsse2\\b',self.info[0]['flags']) is not None\n\n def _has_3dnow(self):\n return re.match(r'.*?\\b3dnow\\b',self.info[0]['flags']) is not None\n\n def _has_3dnowext(self):\n return re.match(r'.*?\\b3dnowext\\b',self.info[0]['flags']) is not None\n\nclass irix_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('sysconf')\n if status not in [0,256]:\n return\n for line in output.split('\\n'):\n name_value = map(string.strip,string.split(line,' ',1))\n if len(name_value)!=2:\n continue\n name,value = name_value\n if not info:\n info.append({})\n info[-1][name] = value\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n #print info\n def _not_impl(self): pass\n\n def _is_singleCPU(self):\n return self.info[0].get('NUM_PROCESSORS') == '1'\n\n def _getNCPUs(self):\n return int(self.info[0].get('NUM_PROCESSORS'))\n\n def __cputype(self,n):\n return self.info[0].get('PROCESSORS').split()[0].lower() == 'r%s' % (n)\n def _is_r2000(self): return self.__cputype(2000)\n def _is_r3000(self): return self.__cputype(3000)\n def _is_r3900(self): return self.__cputype(3900)\n def _is_r4000(self): return self.__cputype(4000)\n def _is_r4100(self): return self.__cputype(4100)\n def _is_r4300(self): return self.__cputype(4300)\n def _is_r4400(self): return self.__cputype(4400)\n def _is_r4600(self): return self.__cputype(4600)\n def _is_r4650(self): return self.__cputype(4650)\n def _is_r5000(self): return self.__cputype(5000)\n def _is_r6000(self): return self.__cputype(6000)\n def _is_r8000(self): return self.__cputype(8000)\n def _is_r10000(self): return self.__cputype(10000)\n def _is_r12000(self): return self.__cputype(12000)\n def _is_rorion(self): return self.__cputype('orion')\n\n def get_ip(self):\n try: return self.info[0].get('MACHINE')\n except: pass\n def __machine(self,n):\n return self.info[0].get('MACHINE').lower() == 'ip%s' % (n)\n def _is_IP19(self): return self.__machine(19)\n def _is_IP20(self): return self.__machine(20)\n def _is_IP21(self): return self.__machine(21)\n def _is_IP22(self): return self.__machine(22)\n def _is_IP22_4k(self): return self.__machine(22) and self._is_r4000()\n def _is_IP22_5k(self): return self.__machine(22) and self._is_r5000()\n def _is_IP24(self): return self.__machine(24)\n def _is_IP25(self): return self.__machine(25)\n def _is_IP26(self): return self.__machine(26)\n def _is_IP27(self): return self.__machine(27)\n def _is_IP28(self): return self.__machine(28)\n def _is_IP30(self): return self.__machine(30)\n def _is_IP32(self): return self.__machine(32)\n def _is_IP32_5k(self): return self.__machine(32) and self._is_r5000()\n def _is_IP32_10k(self): return self.__machine(32) and self._is_r10000()\n\nclass darwin_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('machine')\n if not status:\n if not info: info.append({})\n info[-1]['machine'] = string.strip(output)\n status,output = commands.getstatusoutput('sysctl hw')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['sysctl_hw'] = d\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _getNCPUs(self):\n try: return int(self.info[0]['sysctl_hw']['hw.ncpu'])\n except: return 1\n\n def _is_Power_Macintosh(self):\n return self.info[0]['sysctl_hw']['hw.machine']=='Power Macintosh'\n\n def _is_i386(self):\n return self.info[0]['arch']=='i386'\n def _is_ppc(self):\n return self.info[0]['arch']=='ppc'\n\n def __machine(self,n):\n return self.info[0]['machine'] == 'ppc%s'%n\n def _is_ppc601(self): return self.__machine(601)\n def _is_ppc602(self): return self.__machine(602)\n def _is_ppc603(self): return self.__machine(603)\n def _is_ppc603e(self): return self.__machine('603e')\n def _is_ppc604(self): return self.__machine(604)\n def _is_ppc604e(self): return self.__machine('604e')\n def _is_ppc620(self): return self.__machine(620)\n def _is_ppc630(self): return self.__machine(630)\n def _is_ppc740(self): return self.__machine(740)\n def _is_ppc7400(self): return self.__machine(7400)\n def _is_ppc7450(self): return self.__machine(7450)\n def _is_ppc750(self): return self.__machine(750)\n def _is_ppc403(self): return self.__machine(403)\n def _is_ppc505(self): return self.__machine(505)\n def _is_ppc801(self): return self.__machine(801)\n def _is_ppc821(self): return self.__machine(821)\n def _is_ppc823(self): return self.__machine(823)\n def _is_ppc860(self): return self.__machine(860)\n\nclass sunos_cpuinfo(cpuinfo_base):\n\n info = None\n \n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n import commands\n status,output = commands.getstatusoutput('arch')\n if not status:\n if not info: info.append({})\n info[-1]['arch'] = string.strip(output)\n status,output = commands.getstatusoutput('mach')\n if not status:\n if not info: info.append({})\n info[-1]['mach'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -i')\n if not status:\n if not info: info.append({})\n info[-1]['uname_i'] = string.strip(output)\n status,output = commands.getstatusoutput('uname -X')\n if not status:\n if not info: info.append({})\n d = {}\n for l in string.split(output,'\\n'):\n l = map(string.strip,string.split(l, '='))\n if len(l)==2:\n d[l[0]]=l[1]\n info[-1]['uname_X'] = d\n status,output = commands.getstatusoutput('isainfo -b')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_b'] = string.strip(output)\n status,output = commands.getstatusoutput('isainfo -n')\n if not status:\n if not info: info.append({})\n info[-1]['isainfo_n'] = string.strip(output)\n status,output = commands.getstatusoutput('psrinfo -v 0')\n if not status:\n if not info: info.append({})\n for l in string.split(output,'\\n'):\n m = re.match(r'\\s*The (?P

[\\w\\d]+) processor operates at',l)\n if m:\n info[-1]['processor'] = m.group('p')\n break\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n def _is_32bit(self):\n return self.info[0]['isainfo_b']=='32'\n def _is_64bit(self):\n return self.info[0]['isainfo_b']=='64'\n\n def _is_i386(self):\n return self.info[0]['isainfo_n']=='i386'\n def _is_sparc(self):\n return self.info[0]['isainfo_n']=='sparc'\n def _is_sparcv9(self):\n return self.info[0]['isainfo_n']=='sparcv9'\n\n def _getNCPUs(self):\n try: return int(self.info[0]['uname_X']['NumCPU'])\n except: return 1\n\n def _is_sun4(self):\n return self.info[0]['arch']=='sun4'\n\n def _is_SUNW(self):\n return re.match(r'SUNW',self.info[0]['uname_i']) is not None\n def _is_sparcstation5(self):\n return re.match(r'.*SPARCstation-5',self.info[0]['uname_i']) is not None\n def _is_ultra1(self):\n return re.match(r'.*Ultra-1',self.info[0]['uname_i']) is not None\n def _is_ultra250(self):\n return re.match(r'.*Ultra-250',self.info[0]['uname_i']) is not None\n def _is_ultra2(self):\n return re.match(r'.*Ultra-2',self.info[0]['uname_i']) is not None\n def _is_ultra30(self):\n return re.match(r'.*Ultra-30',self.info[0]['uname_i']) is not None\n def _is_ultra4(self):\n return re.match(r'.*Ultra-4',self.info[0]['uname_i']) is not None\n def _is_ultra5_10(self):\n return re.match(r'.*Ultra-5_10',self.info[0]['uname_i']) is not None\n def _is_ultra5(self):\n return re.match(r'.*Ultra-5',self.info[0]['uname_i']) is not None\n def _is_ultra60(self):\n return re.match(r'.*Ultra-60',self.info[0]['uname_i']) is not None\n def _is_ultra80(self):\n return re.match(r'.*Ultra-80',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice(self):\n return re.match(r'.*Ultra-Enterprise',self.info[0]['uname_i']) is not None\n def _is_ultraenterprice10k(self):\n return re.match(r'.*Ultra-Enterprise-10000',self.info[0]['uname_i']) is not None\n def _is_sunfire(self):\n return re.match(r'.*Sun-Fire',self.info[0]['uname_i']) is not None\n def _is_ultra(self):\n return re.match(r'.*Ultra',self.info[0]['uname_i']) is not None\n\n def _is_cpusparcv7(self):\n return self.info[0]['processor']=='sparcv7'\n def _is_cpusparcv8(self):\n return self.info[0]['processor']=='sparcv8'\n def _is_cpusparcv9(self):\n return self.info[0]['processor']=='sparcv9'\n\nclass win32_cpuinfo(cpuinfo_base):\n\n info = None\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n # XXX: what does the value of\n # HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\n # mean?\n\n def __init__(self):\n if self.info is not None:\n return\n info = []\n try:\n #XXX: Bad style to use so long `try:...except:...`. Fix it!\n import _winreg\n pkey = \"HARDWARE\\\\DESCRIPTION\\\\System\\\\CentralProcessor\"\n prgx = re.compile(r\"family\\s+(?P\\d+)\\s+model\\s+(?P\\d+)\"\\\n \"\\s+stepping\\s+(?P\\d+)\",re.IGNORECASE)\n chnd=_winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE,pkey)\n pnum=0\n while 1:\n try:\n proc=_winreg.EnumKey(chnd,pnum)\n except _winreg.error:\n break\n else:\n pnum+=1\n print proc\n info.append({\"Processor\":proc})\n phnd=_winreg.OpenKey(chnd,proc)\n pidx=0\n while True:\n try:\n name,value,vtpe=_winreg.EnumValue(phnd,pidx)\n except _winreg.error:\n break\n else:\n pidx=pidx+1\n info[-1][name]=value\n if name==\"Identifier\":\n srch=prgx.search(value)\n if srch:\n info[-1][\"Family\"]=int(srch.group(\"FML\"))\n info[-1][\"Model\"]=int(srch.group(\"MDL\"))\n info[-1][\"Stepping\"]=int(srch.group(\"STP\"))\n except:\n print sys.exc_value,'(ignoring)'\n self.__class__.info = info\n\n def _not_impl(self): pass\n\n # Athlon\n\n def _is_AMD(self):\n return self.info[0]['VendorIdentifier']=='AuthenticAMD'\n\n def _is_Am486(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_Am5x86(self):\n return self.is_AMD() and self.info[0]['Family']==4\n\n def _is_AMDK5(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [0,1,2,3]\n\n def _is_AMDK6(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model'] in [6,7]\n\n def _is_AMDK6_2(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==8\n\n def _is_AMDK6_3(self):\n return self.is_AMD() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==9\n\n def _is_Athlon(self):\n return self.is_AMD() and self.info[0]['Family']==6\n\n def _is_Athlon64(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==4\n\n def _is_Opteron(self):\n return self.is_AMD() and self.info[0]['Family']==15 \\\n and self.info[0]['Model']==5\n\n # Intel\n\n def _is_Intel(self):\n return self.info[0]['VendorIdentifier']=='GenuineIntel'\n\n def _is_i386(self):\n return self.info[0]['Family']==3\n\n def _is_i486(self):\n return self.info[0]['Family']==4\n\n def _is_i586(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_i686(self):\n return self.is_Intel() and self.info[0]['Family']==6\n\n def _is_Pentium(self):\n return self.is_Intel() and self.info[0]['Family']==5\n\n def _is_PentiumMMX(self):\n return self.is_Intel() and self.info[0]['Family']==5 \\\n and self.info[0]['Model']==4\n\n def _is_PentiumPro(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model']==1\n\n def _is_PentiumII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [3,5,6]\n\n def _is_PentiumIII(self):\n return self.is_Intel() and self.info[0]['Family']==6 \\\n and self.info[0]['Model'] in [7,8,9,10,11]\n\n def _is_PentiumIV(self):\n return self.is_Intel() and self.info[0]['Family']==15\n\n # Varia\n\n def _is_singleCPU(self):\n return len(self.info) == 1\n\n def _getNCPUs(self):\n return len(self.info)\n\n def _has_mmx(self):\n if self.is_Intel():\n return (self.info[0]['Family']==5 and self.info[0]['Model']==4) \\\n or (self.info[0]['Family'] in [6,15])\n elif self.is_AMD():\n return self.info[0]['Family'] in [5,6,15]\n\n def _has_sse(self):\n if self.is_Intel():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [7,8,9,10,11]) \\\n or self.info[0]['Family']==15\n elif self.is_AMD():\n return (self.info[0]['Family']==6 and \\\n self.info[0]['Model'] in [6,7,8,10]) \\\n or self.info[0]['Family']==15\n\n def _has_sse2(self):\n return self.info[0]['Family']==15\n\n def _has_3dnow(self):\n # XXX: does only AMD have 3dnow??\n return self.is_AMD() and self.info[0]['Family'] in [5,6,15]\n\n def _has_3dnowext(self):\n return self.is_AMD() and self.info[0]['Family'] in [6,15]\n\nif sys.platform[:5] == 'linux': # variations: linux2,linux-i386 (any others?)\n cpuinfo = linux_cpuinfo\nelif sys.platform[:4] == 'irix':\n cpuinfo = irix_cpuinfo\nelif sys.platform == 'darwin':\n cpuinfo = darwin_cpuinfo\nelif sys.platform[:5] == 'sunos':\n cpuinfo = sunos_cpuinfo\nelif sys.platform[:5] == 'win32':\n cpuinfo = win32_cpuinfo\n#XXX: other OS's. Eg. use _winreg on Win32. Or os.uname on unices.\nelse:\n cpuinfo = cpuinfo_base\n\nif __name__ == \"__main__\":\n cpu = cpuinfo()\n\n cpu.is_blaa()\n cpu.is_Intel()\n cpu.is_Alpha()\n\n print 'CPU information:',\n for name in dir(cpuinfo):\n if name[0]=='_' and name[1]!='_':\n r = getattr(cpu,name[1:])()\n if r:\n if r!=1:\n print '%s=%s' %(name[1:],r),\n else:\n print name[1:],\n print\n", "methods": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "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": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 54, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 75, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 81, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 84, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 102, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 108, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 111, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "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": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 117, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "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": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "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": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 131, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 134, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 144, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 148, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 168, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 176, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 179, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 182, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 185, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 188, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 194, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 197, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 200, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 207, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 231, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 234, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 237, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 255, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 258, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 280, "end_line": 305, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 309, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 313, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 316, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 318, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 321, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 346, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 395, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 397, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 400, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 402, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 404, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 407, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 411, "end_line": 412, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 414, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 416, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 418, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 420, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 422, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 424, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 426, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 428, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 430, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 432, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 434, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 438, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 440, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 442, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 445, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 447, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 449, "end_line": 450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 460, "end_line": 499, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 505, "end_line": 506, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 508, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 511, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 514, "end_line": 516, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 518, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 526, "end_line": 528, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 530, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 533, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 543, "end_line": 544, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 546, "end_line": 547, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 549, "end_line": 550, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 552, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 555, "end_line": 556, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 558, "end_line": 559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 561, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 565, "end_line": 567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 569, "end_line": 571, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 573, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 577, "end_line": 578, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 582, "end_line": 583, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 585, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 588, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 595, "end_line": 603, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 605, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 608, "end_line": 610, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 612, "end_line": 613, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_try_call", "long_name": "_try_call( self , func )", "filename": "cpuinfo.py", "nloc": 5, "complexity": 2, "token_count": 16, "parameters": [ "self", "func" ], "start_line": 31, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 4, "token_count": 71, "parameters": [ "self", "name" ], "start_line": 37, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 7, "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": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 16, "complexity": 7, "token_count": 112, "parameters": [ "self" ], "start_line": 54, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 75, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_2", "long_name": "_is_AthlonK6_2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6_3", "long_name": "_is_AthlonK6_3( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 81, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK6", "long_name": "_is_AthlonK6( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 84, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonK7", "long_name": "_is_AthlonK7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 87, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AthlonHX", "long_name": "_is_AthlonHX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 94, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Hammer", "long_name": "_is_Hammer( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 98, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Alpha", "long_name": "_is_Alpha( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV4", "long_name": "_is_EV4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 107, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_EV5", "long_name": "_is_EV5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "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": "_is_EV56", "long_name": "_is_EV56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PCA56", "long_name": "_is_PCA56( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "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": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "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": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 127, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "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": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 133, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Celeron", "long_name": "_is_Celeron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 136, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 144, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 148, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 152, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 156, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 160, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Itanium", "long_name": "_is_Itanium( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 172, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 175, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_fdiv_bug", "long_name": "_has_fdiv_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 178, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_f00f_bug", "long_name": "_has_f00f_bug( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 181, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 184, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 187, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 190, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 193, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 196, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 20, "complexity": 7, "token_count": 122, "parameters": [ "self" ], "start_line": 203, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 227, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 230, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__cputype", "long_name": "__cputype( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 36, "parameters": [ "self", "n" ], "start_line": 233, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_ip", "long_name": "get_ip( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 251, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 29, "parameters": [ "self", "n" ], "start_line": 254, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 26, "complexity": 11, "token_count": 205, "parameters": [ "self" ], "start_line": 276, "end_line": 301, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 305, "end_line": 307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Power_Macintosh", "long_name": "_is_Power_Macintosh( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 309, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 312, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ppc", "long_name": "_is_ppc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 314, "end_line": 315, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__machine", "long_name": "__machine( self , n )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 21, "parameters": [ "self", "n" ], "start_line": 317, "end_line": 318, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 46, "complexity": 21, "token_count": 392, "parameters": [ "self" ], "start_line": 342, "end_line": 387, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_is_32bit", "long_name": "_is_32bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 391, "end_line": 392, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_64bit", "long_name": "_is_64bit( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 393, "end_line": 394, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 396, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparc", "long_name": "_is_sparc( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 398, "end_line": 399, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcv9", "long_name": "_is_sparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 400, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 403, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_sun4", "long_name": "_is_sun4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 407, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_SUNW", "long_name": "_is_SUNW( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 410, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sparcstation5", "long_name": "_is_sparcstation5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 412, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra1", "long_name": "_is_ultra1( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 414, "end_line": 415, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra250", "long_name": "_is_ultra250( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 416, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra2", "long_name": "_is_ultra2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 418, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra30", "long_name": "_is_ultra30( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 420, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra4", "long_name": "_is_ultra4( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 422, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5_10", "long_name": "_is_ultra5_10( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 424, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra5", "long_name": "_is_ultra5( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 426, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra60", "long_name": "_is_ultra60( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 428, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra80", "long_name": "_is_ultra80( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 430, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice", "long_name": "_is_ultraenterprice( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 432, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultraenterprice10k", "long_name": "_is_ultraenterprice10k( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 434, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_sunfire", "long_name": "_is_sunfire( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_ultra", "long_name": "_is_ultra( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 438, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv7", "long_name": "_is_cpusparcv7( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 441, "end_line": 442, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv8", "long_name": "_is_cpusparcv8( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 443, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_cpusparcv9", "long_name": "_is_cpusparcv9( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 445, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self )", "filename": "cpuinfo.py", "nloc": 39, "complexity": 9, "token_count": 233, "parameters": [ "self" ], "start_line": 456, "end_line": 495, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 1 }, { "name": "_is_AMD", "long_name": "_is_AMD( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 501, "end_line": 502, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am486", "long_name": "_is_Am486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 504, "end_line": 505, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Am5x86", "long_name": "_is_Am5x86( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 507, "end_line": 508, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_AMDK5", "long_name": "_is_AMDK5( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 44, "parameters": [ "self" ], "start_line": 510, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6", "long_name": "_is_AMDK6( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 40, "parameters": [ "self" ], "start_line": 514, "end_line": 516, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_2", "long_name": "_is_AMDK6_2( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 518, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_AMDK6_3", "long_name": "_is_AMDK6_3( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 522, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Athlon", "long_name": "_is_Athlon( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 526, "end_line": 527, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Athlon64", "long_name": "_is_Athlon64( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 529, "end_line": 531, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Opteron", "long_name": "_is_Opteron( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 533, "end_line": 535, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_Intel", "long_name": "_is_Intel( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 539, "end_line": 540, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i386", "long_name": "_is_i386( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 542, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i486", "long_name": "_is_i486( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 545, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i586", "long_name": "_is_i586( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 548, "end_line": 549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_i686", "long_name": "_is_i686( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 551, "end_line": 552, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_Pentium", "long_name": "_is_Pentium( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 554, "end_line": 555, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_PentiumMMX", "long_name": "_is_PentiumMMX( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 557, "end_line": 559, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumPro", "long_name": "_is_PentiumPro( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 561, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumII", "long_name": "_is_PentiumII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 565, "end_line": 567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIII", "long_name": "_is_PentiumIII( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 3, "token_count": 46, "parameters": [ "self" ], "start_line": 569, "end_line": 571, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_is_PentiumIV", "long_name": "_is_PentiumIV( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 573, "end_line": 574, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_singleCPU", "long_name": "_is_singleCPU( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 578, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_getNCPUs", "long_name": "_getNCPUs( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 581, "end_line": 582, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_mmx", "long_name": "_has_mmx( self )", "filename": "cpuinfo.py", "nloc": 6, "complexity": 5, "token_count": 82, "parameters": [ "self" ], "start_line": 584, "end_line": 589, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "_has_sse", "long_name": "_has_sse( self )", "filename": "cpuinfo.py", "nloc": 9, "complexity": 7, "token_count": 117, "parameters": [ "self" ], "start_line": 591, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "_has_sse2", "long_name": "_has_sse2( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 601, "end_line": 602, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_has_3dnow", "long_name": "_has_3dnow( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 604, "end_line": 606, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_has_3dnowext", "long_name": "_has_3dnowext( self )", "filename": "cpuinfo.py", "nloc": 2, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 608, "end_line": 609, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "_is_AthlonMP", "long_name": "_is_AthlonMP( self )", "filename": "cpuinfo.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "nloc": 511, "complexity": 210, "token_count": 4705, "diff_parsed": { "added": [ " def _is_AthlonMP(self):", " return re.match(r'.*?Athlon\\(tm\\) MP\\b',", " self.info[0]['model name']) is not None", "" ], "deleted": [] } } ] }, { "hash": "0dd3d2354b41c42153ac57151643e8ab082988b7", "msg": "Intel Fortran Compiler 8.x executable is ifort", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-13T21:47:36+00:00", "author_timezone": 0, "committer_date": "2003-12-13T21:47:36+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "fb700bfdb970f8fb92d01c54726aa3420e46ab02" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 0, "insertions": 10, "lines": 10, "files": 1, "dmm_unit_size": 0.5, "dmm_unit_complexity": 0.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": "@@ -1182,6 +1182,11 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n \n if fc is None:\n fc = 'ifc'\n+ self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n+ self.dummy_fortran_files()\n+ if not self.get_version():\n+ fc = 'ifort'\n+ self.version = None\n if f90c is None:\n f90c = fc\n \n@@ -1250,6 +1255,11 @@ class intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n+ self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n+ self.dummy_fortran_files()\n+ if not self.get_version():\n+ fc = 'ifort'\n+ self.version = None\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n \n \n", "added_lines": 10, "deleted_lines": 0, "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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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_AthlonMP():\n opt = opt + ' -march=athlon-mp '\n # there's also: athlon-tbird, athlon-4, athlon-xp\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 self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n if not self.get_version():\n fc = 'ifort'\n self.version = None\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 if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n if self.get_version() and self.version >= '8.0':\n return [self.f77_compiler,'-shared','-nofor_main']\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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n if not self.get_version():\n fc = 'ifort'\n self.version = None\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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_AthlonMP():\n opt = opt + ' -march=athlon-mp '\n # there's also: athlon-tbird, athlon-4, athlon-xp\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 self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n if self.get_version() and self.version >= '8.0':\n return [self.f77_compiler,'-shared','-nofor_main']\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 intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 64, "complexity": 31, "token_count": 372, "parameters": [ "self" ], "start_line": 1060, "end_line": 1127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1129, "end_line": 1145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1147, "end_line": 1153, "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": 1155, "end_line": 1163, "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": 1165, "end_line": 1166, "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": 1168, "end_line": 1169, "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": 28, "complexity": 6, "token_count": 183, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1180, "end_line": 1214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 1216, "end_line": 1230, "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": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1232, "end_line": 1235, "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": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1237, "end_line": 1246, "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": 9, "complexity": 3, "token_count": 69, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1255, "end_line": 1263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1279, "end_line": 1307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1309, "end_line": 1323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1326, "end_line": 1335, "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": 1345, "end_line": 1348, "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": 1355, "end_line": 1376, "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": 1378, "end_line": 1380, "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": 1382, "end_line": 1383, "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": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1397, "end_line": 1425, "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": 1431, "end_line": 1432, "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": 1445, "end_line": 1476, "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": 1478, "end_line": 1479, "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": 1487, "end_line": 1511, "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": 1513, "end_line": 1516, "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": 1518, "end_line": 1522, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1538, "end_line": 1566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1568, "end_line": 1570, "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": 1580, "end_line": 1605, "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": 1607, "end_line": 1609, "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": 1611, "end_line": 1612, "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": 1620, "end_line": 1645, "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": 1647, "end_line": 1648, "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": 1650, "end_line": 1653, "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": 1655, "end_line": 1661, "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": 1666, "end_line": 1674, "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": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 64, "complexity": 31, "token_count": 372, "parameters": [ "self" ], "start_line": 1060, "end_line": 1127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1129, "end_line": 1145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1147, "end_line": 1153, "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": 1155, "end_line": 1163, "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": 1165, "end_line": 1166, "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": 1168, "end_line": 1169, "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": 1180, "end_line": 1209, "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": 1211, "end_line": 1225, "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": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1227, "end_line": 1230, "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": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1232, "end_line": 1241, "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": 1250, "end_line": 1253, "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": 20, "complexity": 4, "token_count": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1269, "end_line": 1297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1299, "end_line": 1313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1316, "end_line": 1325, "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": 1335, "end_line": 1338, "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": 1345, "end_line": 1366, "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": 1368, "end_line": 1370, "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": 1372, "end_line": 1373, "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": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1387, "end_line": 1415, "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": 1421, "end_line": 1422, "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": 1435, "end_line": 1466, "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": 1468, "end_line": 1469, "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": 1477, "end_line": 1501, "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": 1503, "end_line": 1506, "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": 1508, "end_line": 1512, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1528, "end_line": 1556, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1558, "end_line": 1560, "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": 1570, "end_line": 1595, "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": 1597, "end_line": 1599, "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": 1601, "end_line": 1602, "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": 1610, "end_line": 1635, "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": 1637, "end_line": 1638, "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": 1640, "end_line": 1643, "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": 1645, "end_line": 1651, "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": 1656, "end_line": 1664, "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": 28, "complexity": 6, "token_count": 183, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1180, "end_line": 1214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 } ], "nloc": 1253, "complexity": 331, "token_count": 7323, "diff_parsed": { "added": [ " self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\", " self.dummy_fortran_files()", " if not self.get_version():", " fc = 'ifort'", " self.version = None", " self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\", " self.dummy_fortran_files()", " if not self.get_version():", " fc = 'ifort'", " self.version = None" ], "deleted": [] } } ] }, { "hash": "714a0aaa3311e5af057f32a805f131fef3f3bd55", "msg": "Fix (scoreboard) building on win32", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-13T22:09:40+00:00", "author_timezone": 0, "committer_date": "2003-12-13T22:09:40+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0dd3d2354b41c42153ac57151643e8ab082988b7" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/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_clib.py", "new_path": "scipy_distutils/command/build_clib.py", "filename": "build_clib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -255,7 +255,7 @@ def build_libraries (self, libraries):\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n- cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)\n+ cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name)\n log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"distutils.command.build_clib\n\nImplements the Distutils 'build_clib' command, to build a C/C++ library\nthat is included in the module distribution and needed by an extension\nmodule.\"\"\"\n\n# created (an empty husk) 1999/12/18, Greg Ward\n# fleshed out 2000/02/03-04\n\n__revision__ = \"$Id$\"\n\n\n# XXX this module has *lots* of code ripped-off quite transparently from\n# build_ext.py -- not surprisingly really, as the work required to build\n# a static library from a collection of C source files is not really all\n# that different from what's required to build a shared object file from\n# a collection of C source files. Nevertheless, I haven't done the\n# necessary refactoring to account for the overlap in code between the\n# two modules, mainly because a number of subtle details changed in the\n# cut 'n paste. Sigh.\n\nimport os, string, sys\nfrom glob import glob\nfrom types import *\nfrom distutils.core import Command\nfrom distutils.errors import *\nfrom distutils.sysconfig import customize_compiler\nfrom scipy_distutils.misc_util import red_text,yellow_text\nfrom scipy_distutils import log\n\ndef show_compilers ():\n from distutils.ccompiler import show_compilers\n show_compilers()\n\ndef get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob(os.path.join(dir,\"*.h\"))\n headers.extend(head)\n\n return headers\n\ndef get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n\n return direcs\n\n\nclass build_clib (Command):\n\n description = \"build C/C++ libraries used by Python extensions\"\n\n user_options = [\n ('build-clib', 'b',\n \"directory to build C/C++ 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 ('compiler=', 'c',\n \"specify the compiler type\"),\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 self.build_clib = None\n self.build_temp = None\n\n # List of libraries to build\n self.libraries = None\n\n # Compilation options for all libraries\n self.include_dirs = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.compiler = None\n\n # initialize_options()\n\n\n def finalize_options (self):\n\n # This might be confusing: both build-clib and build-temp default\n # to build-temp as defined by the \"build\" command. This is because\n # I think that C libraries are really just temporary build\n # by-products, at least from the point of view of building Python\n # extensions -- but I want to keep my options open.\n self.set_undefined_options('build',\n ('build_temp', 'build_clib'),\n ('build_temp', 'build_temp'),\n ('compiler', 'compiler'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.libraries = self.distribution.libraries\n if self.libraries:\n self.check_library_list(self.libraries)\n\n if self.include_dirs is None:\n self.include_dirs = self.distribution.include_dirs or []\n if type(self.include_dirs) is StringType:\n self.include_dirs = string.split(self.include_dirs,\n os.pathsep)\n\n from scipy_distutils import misc_util\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n # XXX same as for build_ext -- what about 'self.define' and\n # 'self.undef' ?\n\n # finalize_options()\n\n\n def run (self):\n\n if not self.libraries:\n return\n\n # Yech -- this is cut 'n pasted from build_ext.py!\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n customize_compiler(self.compiler)\n\n if self.include_dirs is not None:\n self.compiler.set_include_dirs(self.include_dirs)\n if self.define is not None:\n # 'define' option is a list of (name,value) tuples\n for (name,value) in self.define:\n self.compiler.define_macro(name, value)\n if self.undef is not None:\n for macro in self.undef:\n self.compiler.undefine_macro(macro)\n\n self.build_libraries(self.libraries)\n\n # run()\n\n\n def check_library_list (self, libraries):\n \"\"\"Ensure that the list of libraries (presumably provided as a\n command option 'libraries') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (library_name, build_info_dict).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n\n # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,\n # with only names changed to protect the innocent!\n\n if type(libraries) is not ListType:\n print type(libraries)\n raise DistutilsSetupError, \\\n \"'libraries' option must be a list of tuples\"\n\n for lib in libraries:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'libraries' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'libraries' \" + \\\n \"must be a string (the library name)\"\n if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):\n raise DistutilsSetupError, \\\n (\"bad library name '%s': \" + \n \"may not contain directory separators\") % \\\n lib[0]\n\n if type(lib[1]) is not DictionaryType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'libraries' \" + \\\n \"must be a dictionary (build info)\"\n # for lib\n\n # check_library_list ()\n\n\n def get_library_names (self):\n # Assume the library list is valid -- 'check_library_list()' is\n # called from 'finalize_options()', so it should be!\n\n if not self.libraries:\n return None\n\n lib_names = []\n for (lib_name, build_info) in self.libraries:\n lib_names.append(lib_name)\n return lib_names\n\n # get_library_names ()\n\n\n def get_source_files (self):\n self.check_library_list(self.libraries)\n filenames = []\n\n # Gets source files specified and any \"*.h\" header files in\n # those directories. \n for ext in self.libraries:\n sources = ext[1]['sources']\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n\n return filenames\n\n def build_libraries (self, libraries):\n\n compiler = self.compiler\n\n for (lib_name, build_info) in libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in '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\n log.info(\"building '%s' library\", lib_name)\n\n # First, compile the source code to object files in the library\n # directory. (This should probably change to putting object\n # files in a temporary build directory.)\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug)\n\n # Now \"link\" the object files together into a static library.\n # (On Unix at least, this isn't really linking -- it just\n # builds an archive. Whatever.)\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name)\n log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n log.warn('Ignoring failure during %s, build'\\\n ' (exit status = %s)', lib_name, failure)\n\n # for libraries\n\n # build_libraries ()\n\n# class build_lib\n", "source_code_before": "\"\"\"distutils.command.build_clib\n\nImplements the Distutils 'build_clib' command, to build a C/C++ library\nthat is included in the module distribution and needed by an extension\nmodule.\"\"\"\n\n# created (an empty husk) 1999/12/18, Greg Ward\n# fleshed out 2000/02/03-04\n\n__revision__ = \"$Id$\"\n\n\n# XXX this module has *lots* of code ripped-off quite transparently from\n# build_ext.py -- not surprisingly really, as the work required to build\n# a static library from a collection of C source files is not really all\n# that different from what's required to build a shared object file from\n# a collection of C source files. Nevertheless, I haven't done the\n# necessary refactoring to account for the overlap in code between the\n# two modules, mainly because a number of subtle details changed in the\n# cut 'n paste. Sigh.\n\nimport os, string, sys\nfrom glob import glob\nfrom types import *\nfrom distutils.core import Command\nfrom distutils.errors import *\nfrom distutils.sysconfig import customize_compiler\nfrom scipy_distutils.misc_util import red_text,yellow_text\nfrom scipy_distutils import log\n\ndef show_compilers ():\n from distutils.ccompiler import show_compilers\n show_compilers()\n\ndef get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob(os.path.join(dir,\"*.h\"))\n headers.extend(head)\n\n return headers\n\ndef get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n\n return direcs\n\n\nclass build_clib (Command):\n\n description = \"build C/C++ libraries used by Python extensions\"\n\n user_options = [\n ('build-clib', 'b',\n \"directory to build C/C++ 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 ('compiler=', 'c',\n \"specify the compiler type\"),\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 self.build_clib = None\n self.build_temp = None\n\n # List of libraries to build\n self.libraries = None\n\n # Compilation options for all libraries\n self.include_dirs = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.compiler = None\n\n # initialize_options()\n\n\n def finalize_options (self):\n\n # This might be confusing: both build-clib and build-temp default\n # to build-temp as defined by the \"build\" command. This is because\n # I think that C libraries are really just temporary build\n # by-products, at least from the point of view of building Python\n # extensions -- but I want to keep my options open.\n self.set_undefined_options('build',\n ('build_temp', 'build_clib'),\n ('build_temp', 'build_temp'),\n ('compiler', 'compiler'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.libraries = self.distribution.libraries\n if self.libraries:\n self.check_library_list(self.libraries)\n\n if self.include_dirs is None:\n self.include_dirs = self.distribution.include_dirs or []\n if type(self.include_dirs) is StringType:\n self.include_dirs = string.split(self.include_dirs,\n os.pathsep)\n\n from scipy_distutils import misc_util\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n # XXX same as for build_ext -- what about 'self.define' and\n # 'self.undef' ?\n\n # finalize_options()\n\n\n def run (self):\n\n if not self.libraries:\n return\n\n # Yech -- this is cut 'n pasted from build_ext.py!\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n customize_compiler(self.compiler)\n\n if self.include_dirs is not None:\n self.compiler.set_include_dirs(self.include_dirs)\n if self.define is not None:\n # 'define' option is a list of (name,value) tuples\n for (name,value) in self.define:\n self.compiler.define_macro(name, value)\n if self.undef is not None:\n for macro in self.undef:\n self.compiler.undefine_macro(macro)\n\n self.build_libraries(self.libraries)\n\n # run()\n\n\n def check_library_list (self, libraries):\n \"\"\"Ensure that the list of libraries (presumably provided as a\n command option 'libraries') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (library_name, build_info_dict).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n\n # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,\n # with only names changed to protect the innocent!\n\n if type(libraries) is not ListType:\n print type(libraries)\n raise DistutilsSetupError, \\\n \"'libraries' option must be a list of tuples\"\n\n for lib in libraries:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'libraries' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'libraries' \" + \\\n \"must be a string (the library name)\"\n if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):\n raise DistutilsSetupError, \\\n (\"bad library name '%s': \" + \n \"may not contain directory separators\") % \\\n lib[0]\n\n if type(lib[1]) is not DictionaryType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'libraries' \" + \\\n \"must be a dictionary (build info)\"\n # for lib\n\n # check_library_list ()\n\n\n def get_library_names (self):\n # Assume the library list is valid -- 'check_library_list()' is\n # called from 'finalize_options()', so it should be!\n\n if not self.libraries:\n return None\n\n lib_names = []\n for (lib_name, build_info) in self.libraries:\n lib_names.append(lib_name)\n return lib_names\n\n # get_library_names ()\n\n\n def get_source_files (self):\n self.check_library_list(self.libraries)\n filenames = []\n\n # Gets source files specified and any \"*.h\" header files in\n # those directories. \n for ext in self.libraries:\n sources = ext[1]['sources']\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n\n return filenames\n\n def build_libraries (self, libraries):\n\n compiler = self.compiler\n\n for (lib_name, build_info) in libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in '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\n log.info(\"building '%s' library\", lib_name)\n\n # First, compile the source code to object files in the library\n # directory. (This should probably change to putting object\n # files in a temporary build directory.)\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug)\n\n # Now \"link\" the object files together into a static library.\n # (On Unix at least, this isn't really linking -- it just\n # builds an archive. Whatever.)\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)\n log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n log.warn('Ignoring failure during %s, build'\\\n ' (exit status = %s)', lib_name, failure)\n\n # for libraries\n\n # build_libraries ()\n\n# class build_lib\n", "methods": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_clib.py", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_headers", "long_name": "get_headers( directory_list )", "filename": "build_clib.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "directory_list" ], "start_line": 35, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_directories", "long_name": "get_directories( list_of_sources )", "filename": "build_clib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 44, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_clib.py", "nloc": 10, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 79, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 5, "token_count": 127, "parameters": [ "self" ], "start_line": 97, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 7, "token_count": 132, "parameters": [ "self" ], "start_line": 130, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_library_list", "long_name": "check_library_list( self , libraries )", "filename": "build_clib.py", "nloc": 22, "complexity": 10, "token_count": 133, "parameters": [ "self", "libraries" ], "start_line": 158, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 197, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_clib.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 212, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 27, "complexity": 5, "token_count": 188, "parameters": [ "self", "libraries" ], "start_line": 225, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "methods_before": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_clib.py", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_headers", "long_name": "get_headers( directory_list )", "filename": "build_clib.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "directory_list" ], "start_line": 35, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_directories", "long_name": "get_directories( list_of_sources )", "filename": "build_clib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 44, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_clib.py", "nloc": 10, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 79, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 5, "token_count": 127, "parameters": [ "self" ], "start_line": 97, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 7, "token_count": 132, "parameters": [ "self" ], "start_line": 130, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_library_list", "long_name": "check_library_list( self , libraries )", "filename": "build_clib.py", "nloc": 22, "complexity": 10, "token_count": 133, "parameters": [ "self", "libraries" ], "start_line": 158, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 197, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_clib.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 212, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 27, "complexity": 5, "token_count": 181, "parameters": [ "self", "libraries" ], "start_line": 225, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 27, "complexity": 5, "token_count": 188, "parameters": [ "self", "libraries" ], "start_line": 225, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "nloc": 159, "complexity": 40, "token_count": 952, "diff_parsed": { "added": [ " cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name)" ], "deleted": [ " cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)" ] } } ] }, { "hash": "3aad5a223f49be0a25f36f9d2d116b988f1b7e9d", "msg": "Added missing version attribute to intel_itanium_fortran_compiler", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-14T10:36:51+00:00", "author_timezone": 0, "committer_date": "2003-12-14T10:36:51+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "714a0aaa3311e5af057f32a805f131fef3f3bd55" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 0, "insertions": 1, "lines": 1, "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": "@@ -1257,6 +1257,7 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n fc = 'efc'\n self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n+ self.version = None\n if not self.get_version():\n fc = 'ifort'\n self.version = None\n", "added_lines": 1, "deleted_lines": 0, "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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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_AthlonMP():\n opt = opt + ' -march=athlon-mp '\n # there's also: athlon-tbird, athlon-4, athlon-xp\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 self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n if not self.get_version():\n fc = 'ifort'\n self.version = None\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 if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n if self.get_version() and self.version >= '8.0':\n return [self.f77_compiler,'-shared','-nofor_main']\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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n self.version = None\n if not self.get_version():\n fc = 'ifort'\n self.version = None\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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_AthlonMP():\n opt = opt + ' -march=athlon-mp '\n # there's also: athlon-tbird, athlon-4, athlon-xp\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 self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n if not self.get_version():\n fc = 'ifort'\n self.version = None\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 if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n if self.get_version() and self.version >= '8.0':\n return [self.f77_compiler,'-shared','-nofor_main']\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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n if not self.get_version():\n fc = 'ifort'\n self.version = None\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 64, "complexity": 31, "token_count": 372, "parameters": [ "self" ], "start_line": 1060, "end_line": 1127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1129, "end_line": 1145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1147, "end_line": 1153, "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": 1155, "end_line": 1163, "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": 1165, "end_line": 1166, "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": 1168, "end_line": 1169, "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": 28, "complexity": 6, "token_count": 183, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1180, "end_line": 1214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 1216, "end_line": 1230, "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": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1232, "end_line": 1235, "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": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1237, "end_line": 1246, "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": 10, "complexity": 3, "token_count": 74, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1255, "end_line": 1264, "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": 20, "complexity": 4, "token_count": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1280, "end_line": 1308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1310, "end_line": 1324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1327, "end_line": 1336, "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": 1346, "end_line": 1349, "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": 1356, "end_line": 1377, "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": 1379, "end_line": 1381, "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": 1383, "end_line": 1384, "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": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1398, "end_line": 1426, "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": 1432, "end_line": 1433, "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": 1446, "end_line": 1477, "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": 1479, "end_line": 1480, "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": 1488, "end_line": 1512, "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": 1514, "end_line": 1517, "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": 1519, "end_line": 1523, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1539, "end_line": 1567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1569, "end_line": 1571, "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": 1581, "end_line": 1606, "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": 1608, "end_line": 1610, "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": 1612, "end_line": 1613, "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": 1621, "end_line": 1646, "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": 1648, "end_line": 1649, "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": 1651, "end_line": 1654, "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": 1656, "end_line": 1662, "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": 1667, "end_line": 1675, "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": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 64, "complexity": 31, "token_count": 372, "parameters": [ "self" ], "start_line": 1060, "end_line": 1127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1129, "end_line": 1145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1147, "end_line": 1153, "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": 1155, "end_line": 1163, "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": 1165, "end_line": 1166, "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": 1168, "end_line": 1169, "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": 28, "complexity": 6, "token_count": 183, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1180, "end_line": 1214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 1216, "end_line": 1230, "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": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1232, "end_line": 1235, "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": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1237, "end_line": 1246, "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": 9, "complexity": 3, "token_count": 69, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1255, "end_line": 1263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1279, "end_line": 1307, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1309, "end_line": 1323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1326, "end_line": 1335, "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": 1345, "end_line": 1348, "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": 1355, "end_line": 1376, "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": 1378, "end_line": 1380, "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": 1382, "end_line": 1383, "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": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1397, "end_line": 1425, "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": 1431, "end_line": 1432, "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": 1445, "end_line": 1476, "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": 1478, "end_line": 1479, "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": 1487, "end_line": 1511, "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": 1513, "end_line": 1516, "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": 1518, "end_line": 1522, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1538, "end_line": 1566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1568, "end_line": 1570, "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": 1580, "end_line": 1605, "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": 1607, "end_line": 1609, "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": 1611, "end_line": 1612, "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": 1620, "end_line": 1645, "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": 1647, "end_line": 1648, "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": 1650, "end_line": 1653, "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": 1655, "end_line": 1661, "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": 1666, "end_line": 1674, "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": 10, "complexity": 3, "token_count": 74, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1255, "end_line": 1264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "nloc": 1254, "complexity": 331, "token_count": 7328, "diff_parsed": { "added": [ " self.version = None" ], "deleted": [] } } ] }, { "hash": "3e0ec132807342198418e6be7e6fba378947ebb6", "msg": "Another blindish attempt to fix failures in build scoreboard for win32.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-14T11:10:05+00:00", "author_timezone": 0, "committer_date": "2003-12-14T11:10:05+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3aad5a223f49be0a25f36f9d2d116b988f1b7e9d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 1, "insertions": 8, "lines": 9, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_clib.py", "new_path": "scipy_distutils/command/build_clib.py", "filename": "build_clib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -255,7 +255,14 @@ def build_libraries (self, libraries):\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n- cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name)\n+ lib_file = None\n+ if sys.platform=='win32':\n+ lib_file = os.path.join(self.build_clib,'%s.lib' % lib_name)\n+ if not os.path.isfile(lib_file):\n+ lib_file = None\n+ if lib_file is None:\n+ lib_file = os.path.join(self.build_clib,'lib%s.a' % lib_name)\n+ cmd = 'ranlib '+lib_file\n log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n", "added_lines": 8, "deleted_lines": 1, "source_code": "\"\"\"distutils.command.build_clib\n\nImplements the Distutils 'build_clib' command, to build a C/C++ library\nthat is included in the module distribution and needed by an extension\nmodule.\"\"\"\n\n# created (an empty husk) 1999/12/18, Greg Ward\n# fleshed out 2000/02/03-04\n\n__revision__ = \"$Id$\"\n\n\n# XXX this module has *lots* of code ripped-off quite transparently from\n# build_ext.py -- not surprisingly really, as the work required to build\n# a static library from a collection of C source files is not really all\n# that different from what's required to build a shared object file from\n# a collection of C source files. Nevertheless, I haven't done the\n# necessary refactoring to account for the overlap in code between the\n# two modules, mainly because a number of subtle details changed in the\n# cut 'n paste. Sigh.\n\nimport os, string, sys\nfrom glob import glob\nfrom types import *\nfrom distutils.core import Command\nfrom distutils.errors import *\nfrom distutils.sysconfig import customize_compiler\nfrom scipy_distutils.misc_util import red_text,yellow_text\nfrom scipy_distutils import log\n\ndef show_compilers ():\n from distutils.ccompiler import show_compilers\n show_compilers()\n\ndef get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob(os.path.join(dir,\"*.h\"))\n headers.extend(head)\n\n return headers\n\ndef get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n\n return direcs\n\n\nclass build_clib (Command):\n\n description = \"build C/C++ libraries used by Python extensions\"\n\n user_options = [\n ('build-clib', 'b',\n \"directory to build C/C++ 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 ('compiler=', 'c',\n \"specify the compiler type\"),\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 self.build_clib = None\n self.build_temp = None\n\n # List of libraries to build\n self.libraries = None\n\n # Compilation options for all libraries\n self.include_dirs = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.compiler = None\n\n # initialize_options()\n\n\n def finalize_options (self):\n\n # This might be confusing: both build-clib and build-temp default\n # to build-temp as defined by the \"build\" command. This is because\n # I think that C libraries are really just temporary build\n # by-products, at least from the point of view of building Python\n # extensions -- but I want to keep my options open.\n self.set_undefined_options('build',\n ('build_temp', 'build_clib'),\n ('build_temp', 'build_temp'),\n ('compiler', 'compiler'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.libraries = self.distribution.libraries\n if self.libraries:\n self.check_library_list(self.libraries)\n\n if self.include_dirs is None:\n self.include_dirs = self.distribution.include_dirs or []\n if type(self.include_dirs) is StringType:\n self.include_dirs = string.split(self.include_dirs,\n os.pathsep)\n\n from scipy_distutils import misc_util\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n # XXX same as for build_ext -- what about 'self.define' and\n # 'self.undef' ?\n\n # finalize_options()\n\n\n def run (self):\n\n if not self.libraries:\n return\n\n # Yech -- this is cut 'n pasted from build_ext.py!\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n customize_compiler(self.compiler)\n\n if self.include_dirs is not None:\n self.compiler.set_include_dirs(self.include_dirs)\n if self.define is not None:\n # 'define' option is a list of (name,value) tuples\n for (name,value) in self.define:\n self.compiler.define_macro(name, value)\n if self.undef is not None:\n for macro in self.undef:\n self.compiler.undefine_macro(macro)\n\n self.build_libraries(self.libraries)\n\n # run()\n\n\n def check_library_list (self, libraries):\n \"\"\"Ensure that the list of libraries (presumably provided as a\n command option 'libraries') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (library_name, build_info_dict).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n\n # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,\n # with only names changed to protect the innocent!\n\n if type(libraries) is not ListType:\n print type(libraries)\n raise DistutilsSetupError, \\\n \"'libraries' option must be a list of tuples\"\n\n for lib in libraries:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'libraries' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'libraries' \" + \\\n \"must be a string (the library name)\"\n if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):\n raise DistutilsSetupError, \\\n (\"bad library name '%s': \" + \n \"may not contain directory separators\") % \\\n lib[0]\n\n if type(lib[1]) is not DictionaryType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'libraries' \" + \\\n \"must be a dictionary (build info)\"\n # for lib\n\n # check_library_list ()\n\n\n def get_library_names (self):\n # Assume the library list is valid -- 'check_library_list()' is\n # called from 'finalize_options()', so it should be!\n\n if not self.libraries:\n return None\n\n lib_names = []\n for (lib_name, build_info) in self.libraries:\n lib_names.append(lib_name)\n return lib_names\n\n # get_library_names ()\n\n\n def get_source_files (self):\n self.check_library_list(self.libraries)\n filenames = []\n\n # Gets source files specified and any \"*.h\" header files in\n # those directories. \n for ext in self.libraries:\n sources = ext[1]['sources']\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n\n return filenames\n\n def build_libraries (self, libraries):\n\n compiler = self.compiler\n\n for (lib_name, build_info) in libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in '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\n log.info(\"building '%s' library\", lib_name)\n\n # First, compile the source code to object files in the library\n # directory. (This should probably change to putting object\n # files in a temporary build directory.)\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug)\n\n # Now \"link\" the object files together into a static library.\n # (On Unix at least, this isn't really linking -- it just\n # builds an archive. Whatever.)\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n lib_file = None\n if sys.platform=='win32':\n lib_file = os.path.join(self.build_clib,'%s.lib' % lib_name)\n if not os.path.isfile(lib_file):\n lib_file = None\n if lib_file is None:\n lib_file = os.path.join(self.build_clib,'lib%s.a' % lib_name)\n cmd = 'ranlib '+lib_file\n log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n log.warn('Ignoring failure during %s, build'\\\n ' (exit status = %s)', lib_name, failure)\n\n # for libraries\n\n # build_libraries ()\n\n# class build_lib\n", "source_code_before": "\"\"\"distutils.command.build_clib\n\nImplements the Distutils 'build_clib' command, to build a C/C++ library\nthat is included in the module distribution and needed by an extension\nmodule.\"\"\"\n\n# created (an empty husk) 1999/12/18, Greg Ward\n# fleshed out 2000/02/03-04\n\n__revision__ = \"$Id$\"\n\n\n# XXX this module has *lots* of code ripped-off quite transparently from\n# build_ext.py -- not surprisingly really, as the work required to build\n# a static library from a collection of C source files is not really all\n# that different from what's required to build a shared object file from\n# a collection of C source files. Nevertheless, I haven't done the\n# necessary refactoring to account for the overlap in code between the\n# two modules, mainly because a number of subtle details changed in the\n# cut 'n paste. Sigh.\n\nimport os, string, sys\nfrom glob import glob\nfrom types import *\nfrom distutils.core import Command\nfrom distutils.errors import *\nfrom distutils.sysconfig import customize_compiler\nfrom scipy_distutils.misc_util import red_text,yellow_text\nfrom scipy_distutils import log\n\ndef show_compilers ():\n from distutils.ccompiler import show_compilers\n show_compilers()\n\ndef get_headers(directory_list):\n # get *.h files from list of directories\n headers = []\n for dir in directory_list:\n head = glob(os.path.join(dir,\"*.h\"))\n headers.extend(head)\n\n return headers\n\ndef get_directories(list_of_sources):\n # get unique directories from list of sources.\n direcs = []\n for file in list_of_sources:\n dir = os.path.split(file)\n if dir[0] != '' and not dir[0] in direcs:\n direcs.append(dir[0])\n\n return direcs\n\n\nclass build_clib (Command):\n\n description = \"build C/C++ libraries used by Python extensions\"\n\n user_options = [\n ('build-clib', 'b',\n \"directory to build C/C++ 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 ('compiler=', 'c',\n \"specify the compiler type\"),\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 self.build_clib = None\n self.build_temp = None\n\n # List of libraries to build\n self.libraries = None\n\n # Compilation options for all libraries\n self.include_dirs = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.compiler = None\n\n # initialize_options()\n\n\n def finalize_options (self):\n\n # This might be confusing: both build-clib and build-temp default\n # to build-temp as defined by the \"build\" command. This is because\n # I think that C libraries are really just temporary build\n # by-products, at least from the point of view of building Python\n # extensions -- but I want to keep my options open.\n self.set_undefined_options('build',\n ('build_temp', 'build_clib'),\n ('build_temp', 'build_temp'),\n ('compiler', 'compiler'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.libraries = self.distribution.libraries\n if self.libraries:\n self.check_library_list(self.libraries)\n\n if self.include_dirs is None:\n self.include_dirs = self.distribution.include_dirs or []\n if type(self.include_dirs) is StringType:\n self.include_dirs = string.split(self.include_dirs,\n os.pathsep)\n\n from scipy_distutils import misc_util\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n # XXX same as for build_ext -- what about 'self.define' and\n # 'self.undef' ?\n\n # finalize_options()\n\n\n def run (self):\n\n if not self.libraries:\n return\n\n # Yech -- this is cut 'n pasted from build_ext.py!\n from distutils.ccompiler import new_compiler\n self.compiler = new_compiler(compiler=self.compiler,\n verbose=self.verbose,\n dry_run=self.dry_run,\n force=self.force)\n customize_compiler(self.compiler)\n\n if self.include_dirs is not None:\n self.compiler.set_include_dirs(self.include_dirs)\n if self.define is not None:\n # 'define' option is a list of (name,value) tuples\n for (name,value) in self.define:\n self.compiler.define_macro(name, value)\n if self.undef is not None:\n for macro in self.undef:\n self.compiler.undefine_macro(macro)\n\n self.build_libraries(self.libraries)\n\n # run()\n\n\n def check_library_list (self, libraries):\n \"\"\"Ensure that the list of libraries (presumably provided as a\n command option 'libraries') is valid, i.e. it is a list of\n 2-tuples, where the tuples are (library_name, build_info_dict).\n Raise DistutilsSetupError if the structure is invalid anywhere;\n just returns otherwise.\"\"\"\n\n # Yechh, blecch, ackk: this is ripped straight out of build_ext.py,\n # with only names changed to protect the innocent!\n\n if type(libraries) is not ListType:\n print type(libraries)\n raise DistutilsSetupError, \\\n \"'libraries' option must be a list of tuples\"\n\n for lib in libraries:\n if type(lib) is not TupleType and len(lib) != 2:\n raise DistutilsSetupError, \\\n \"each element of 'libraries' must a 2-tuple\"\n\n if type(lib[0]) is not StringType:\n raise DistutilsSetupError, \\\n \"first element of each tuple in 'libraries' \" + \\\n \"must be a string (the library name)\"\n if '/' in lib[0] or (os.sep != '/' and os.sep in lib[0]):\n raise DistutilsSetupError, \\\n (\"bad library name '%s': \" + \n \"may not contain directory separators\") % \\\n lib[0]\n\n if type(lib[1]) is not DictionaryType:\n raise DistutilsSetupError, \\\n \"second element of each tuple in 'libraries' \" + \\\n \"must be a dictionary (build info)\"\n # for lib\n\n # check_library_list ()\n\n\n def get_library_names (self):\n # Assume the library list is valid -- 'check_library_list()' is\n # called from 'finalize_options()', so it should be!\n\n if not self.libraries:\n return None\n\n lib_names = []\n for (lib_name, build_info) in self.libraries:\n lib_names.append(lib_name)\n return lib_names\n\n # get_library_names ()\n\n\n def get_source_files (self):\n self.check_library_list(self.libraries)\n filenames = []\n\n # Gets source files specified and any \"*.h\" header files in\n # those directories. \n for ext in self.libraries:\n sources = ext[1]['sources']\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n\n return filenames\n\n def build_libraries (self, libraries):\n\n compiler = self.compiler\n\n for (lib_name, build_info) in libraries:\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in '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\n log.info(\"building '%s' library\", lib_name)\n\n # First, compile the source code to object files in the library\n # directory. (This should probably change to putting object\n # files in a temporary build directory.)\n macros = build_info.get('macros')\n include_dirs = build_info.get('include_dirs')\n objects = self.compiler.compile(sources,\n output_dir=self.build_temp,\n macros=macros,\n include_dirs=include_dirs,\n debug=self.debug)\n\n # Now \"link\" the object files together into a static library.\n # (On Unix at least, this isn't really linking -- it just\n # builds an archive. Whatever.)\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n #XXX: ranlib may not be available on non-GNU platforms.\n cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name)\n log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n log.warn('Ignoring failure during %s, build'\\\n ' (exit status = %s)', lib_name, failure)\n\n # for libraries\n\n # build_libraries ()\n\n# class build_lib\n", "methods": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_clib.py", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_headers", "long_name": "get_headers( directory_list )", "filename": "build_clib.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "directory_list" ], "start_line": 35, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_directories", "long_name": "get_directories( list_of_sources )", "filename": "build_clib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 44, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_clib.py", "nloc": 10, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 79, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 5, "token_count": 127, "parameters": [ "self" ], "start_line": 97, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 7, "token_count": 132, "parameters": [ "self" ], "start_line": 130, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_library_list", "long_name": "check_library_list( self , libraries )", "filename": "build_clib.py", "nloc": 22, "complexity": 10, "token_count": 133, "parameters": [ "self", "libraries" ], "start_line": 158, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 197, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_clib.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 212, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 34, "complexity": 8, "token_count": 236, "parameters": [ "self", "libraries" ], "start_line": 225, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 } ], "methods_before": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_clib.py", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 31, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "get_headers", "long_name": "get_headers( directory_list )", "filename": "build_clib.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "directory_list" ], "start_line": 35, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "get_directories", "long_name": "get_directories( list_of_sources )", "filename": "build_clib.py", "nloc": 7, "complexity": 4, "token_count": 51, "parameters": [ "list_of_sources" ], "start_line": 44, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_clib.py", "nloc": 10, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 79, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 5, "token_count": 127, "parameters": [ "self" ], "start_line": 97, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_clib.py", "nloc": 18, "complexity": 7, "token_count": 132, "parameters": [ "self" ], "start_line": 130, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "check_library_list", "long_name": "check_library_list( self , libraries )", "filename": "build_clib.py", "nloc": 22, "complexity": 10, "token_count": 133, "parameters": [ "self", "libraries" ], "start_line": 158, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self )", "filename": "build_clib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 197, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_clib.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 212, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 27, "complexity": 5, "token_count": 188, "parameters": [ "self", "libraries" ], "start_line": 225, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 34, "complexity": 8, "token_count": 236, "parameters": [ "self", "libraries" ], "start_line": 225, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 } ], "nloc": 166, "complexity": 43, "token_count": 1000, "diff_parsed": { "added": [ " lib_file = None", " if sys.platform=='win32':", " lib_file = os.path.join(self.build_clib,'%s.lib' % lib_name)", " if not os.path.isfile(lib_file):", " lib_file = None", " if lib_file is None:", " lib_file = os.path.join(self.build_clib,'lib%s.a' % lib_name)", " cmd = 'ranlib '+lib_file" ], "deleted": [ " cmd = 'ranlib '+os.path.join(self.build_clib,'lib%s.a' % lib_name)" ] } } ] }, { "hash": "7827303bff3df95eb23d97faba28194640d27dbb", "msg": "Testing backport to Python 2.1 - it used to skip tests from base classes of test classes", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-15T21:20:41+00:00", "author_timezone": 0, "committer_date": "2003-12-15T21:20:41+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3e0ec132807342198418e6be7e6fba378947ebb6" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 1, "insertions": 10, "lines": 11, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -126,6 +126,15 @@ def measure(self,code_str,times=1):\n \n #------------\n \n+def _get_all_method_names(cls):\n+ names = dir(cls)\n+ if sys.version[:3]<='2.1':\n+ for b in cls.__bases__:\n+ for n in dir(b)+_get_all_method_names(b):\n+ if n not in names:\n+ names.append(n)\n+ return names\n+\n __all__.append('ScipyTest')\n class ScipyTest:\n \"\"\" Scipy tests site manager.\n@@ -159,7 +168,7 @@ def _module_str(self, module):\n \n def _get_method_names(self,clsobj,level):\n names = []\n- for mthname in dir(clsobj):\n+ for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n", "added_lines": 10, "deleted_lines": 1, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "source_code_before": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in dir(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "methods": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 19, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 51, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 110, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 160, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 163, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 169, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 54, "complexity": 14, "token_count": 448, "parameters": [ "self", "module", "level" ], "start_line": 191, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 266, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 291, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 317, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 325, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 347, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 386, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 423, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 432, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 470, "end_line": 497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 500, "end_line": 522, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 532, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 549, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 566, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 597, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 619, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 644, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 655, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 19, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 51, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 110, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 151, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 160, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 54, "complexity": 14, "token_count": 448, "parameters": [ "self", "module", "level" ], "start_line": 182, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 244, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 257, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 282, "end_line": 304, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 308, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 316, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 338, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 377, "end_line": 411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 414, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 423, "end_line": 458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 461, "end_line": 488, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 491, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 523, "end_line": 537, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 540, "end_line": 554, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 557, "end_line": 584, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 588, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 610, "end_line": 632, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 635, "end_line": 644, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 646, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 169, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 } ], "nloc": 470, "complexity": 116, "token_count": 3401, "diff_parsed": { "added": [ "def _get_all_method_names(cls):", " names = dir(cls)", " if sys.version[:3]<='2.1':", " for b in cls.__bases__:", " for n in dir(b)+_get_all_method_names(b):", " if n not in names:", " names.append(n)", " return names", "", " for mthname in _get_all_method_names(clsobj):" ], "deleted": [ " for mthname in dir(clsobj):" ] } } ] }, { "hash": "13ec9dd00ebcc4a8be35a28ead36d7f16cb044e9", "msg": "Impl. assert_array_less.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-16T15:16:09+00:00", "author_timezone": 0, "committer_date": "2003-12-16T15:16:09+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7827303bff3df95eb23d97faba28194640d27dbb" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 1, "insertions": 23, "lines": 24, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -10,7 +10,7 @@\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n- less_equal,array2string\n+ less_equal,array2string,less\n import scipy_base.fastumath as math\n except ImportError:\n pass\n@@ -640,6 +640,28 @@ def assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n print x, y\n raise ValueError, 'arrays are not almost equal'\n \n+__all__.append('assert_array_less')\n+def assert_array_less(x,y,err_msg=''):\n+ x,y = asarray(x), asarray(y)\n+ msg = '\\nArrays are not less-ordered'\n+ try:\n+ assert alltrue(equal(shape(x),shape(y))),\\\n+ msg + ' (shapes mismatch):\\n\\t' + err_msg\n+ reduced = ravel(less(x,y))\n+ cond = alltrue(reduced)\n+ if not cond:\n+ s1 = array2string(x,precision=16)\n+ s2 = array2string(y,precision=16)\n+ if len(s1)>120: s1 = s1[:120] + '...'\n+ if len(s2)>120: s2 = s2[:120] + '...'\n+ match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n+ msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n+ assert cond,\\\n+ msg + '\\n\\t' + err_msg\n+ except ValueError:\n+ print shape(x),shape(y)\n+ raise ValueError, 'arrays are not less-ordered'\n+\n __all__.append('rand')\n def rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n", "added_lines": 23, "deleted_lines": 1, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string,less\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('assert_array_less')\ndef assert_array_less(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not less-ordered'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(less(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not less-ordered'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "source_code_before": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\nimport imp\n\ntry:\n # These are used by Numeric tests.\n # If Numeric and scipy_base are not available, then some of the\n # functions below will not be available.\n from Numeric import alltrue,equal,shape,ravel,around,zeros,Float64,asarray,\\\n less_equal,array2string\n import scipy_base.fastumath as math\nexcept ImportError:\n pass\n\n__all__.append('set_package_path')\ndef set_package_path(level=1):\n \"\"\" Prepend package directory to sys.path.\n\n set_package_path should be called from a test_file.py that\n satisfies the following tree structure:\n\n //test_file.py\n\n Then the first existing path name from the following list\n\n /build/lib.-\n /..\n\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n d = os.path.dirname(os.path.dirname(os.path.abspath(testfile)))\n d1 = os.path.join(d,'build','lib.%s-%s'%(get_platform(),sys.version[:3]))\n if not os.path.isdir(d1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n\n__all__.append('set_local_path')\ndef set_local_path(level=1):\n \"\"\" Prepend local directory to sys.path.\n\n The caller is responsible for removing this path by using\n\n restore_path()\n \"\"\"\n from scipy_distutils.misc_util import get_frame\n f = get_frame(level)\n if f.f_locals['__name__']=='__main__':\n testfile = sys.argv[0]\n else:\n testfile = f.f_locals['__file__']\n local_path = os.path.dirname(os.path.abspath(testfile))\n sys.path.insert(0,local_path)\n\n__all__.append('restore_path')\ndef restore_path():\n del sys.path[0]\n\nif sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. See man 5 proc. \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[13])\n except:\n return int(100*(time.time()-_load_time))\n\n def memusage(_proc_pid_stat = '/proc/%s/stat'%(os.getpid())):\n \"\"\" Return virtual memory size in bytes of the running python.\n \"\"\"\n try:\n f=open(_proc_pid_stat,'r')\n l = f.readline().split(' ')\n f.close()\n return int(l[22])\n except:\n return\nelse:\n # os.getpid is not in all platforms available.\n # Using time is safe but inaccurate, especially when process\n # was suspended or sleeping.\n def jiffies(_load_time=time.time()):\n \"\"\" Return number of jiffies (1/100ths of a second) that this\n process has been scheduled in user mode. [Emulation with time.time]. \"\"\"\n return int(100*(time.time()-_load_time))\n\n def memusage():\n \"\"\" Return memory usage of running python. [Not implemented]\"\"\"\n return\n\n__all__.append('ScipyTestCase')\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n \"\"\" Return elapsed time for executing code_str in the\n namespace of the caller for given times.\n \"\"\"\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = jiffies()\n while i>> ScipyTest().test(level=1,verbosity=2)\n\n is package name or its module object.\n\n Package is supposed to contain a directory tests/\n with test_*.py files where * refers to the names of submodules.\n\n test_*.py files are supposed to define a classes, derived\n from ScipyTestCase or unittest.TestCase, with methods having\n names starting with test or bench or check.\n\n And that is it! No need to implement test or test_suite functions\n in each .py file.\n\n Also old styled test_suite(level=1) hooks are supported but\n soon to be removed.\n \"\"\"\n def __init__(self, package):\n self.package = package\n\n def _module_str(self, module):\n filename = module.__file__[-30:]\n if filename!=module.__file__:\n filename = '...'+filename\n return '' % (`module.__name__`, `filename`)\n\n def _get_method_names(self,clsobj,level):\n names = []\n for mthname in _get_all_method_names(clsobj):\n if mthname[:5] not in ['bench','check'] \\\n and mthname[:4] not in ['test']:\n continue\n mth = getattr(clsobj, mthname)\n if type(mth) is not types.MethodType:\n continue\n d = mth.im_func.func_defaults\n if d is not None:\n mthlevel = d[0]\n else:\n mthlevel = 1\n if level>=mthlevel:\n names.append(mthname)\n for base in clsobj.__bases__:\n for n in self._get_method_names(base,level):\n if n not in names:\n names.append(n)\n return names\n\n def _get_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n\n short_module_name = os.path.splitext(os.path.basename(f))[0]\n test_dir = os.path.join(d,'tests')\n test_file = os.path.join(test_dir,'test_'+short_module_name+'.py')\n\n local_test_dir = os.path.join(os.getcwd(),'tests')\n local_test_file = os.path.join(local_test_dir,\n 'test_'+short_module_name+'.py')\n if os.path.basename(os.path.dirname(local_test_dir)) \\\n == os.path.basename(os.path.dirname(test_dir)) \\\n and os.path.isfile(local_test_file):\n test_file = local_test_file\n\n if not os.path.isfile(test_file):\n print ' !! No test file %r found for %s' \\\n % (os.path.basename(test_file), mstr(module))\n return []\n\n try:\n if sys.version[:3]=='2.1':\n # Workaround for Python 2.1 .pyc file generator bug\n import random\n pref = '-nopyc'+`random.randint(1,100)`\n else:\n pref = ''\n f = open(test_file,'r')\n test_module = imp.load_module(\\\n module.__name__+'.test_'+short_module_name+pref,\n f, test_file+pref,('.py', 'r', 1))\n f.close()\n if sys.version[:3]=='2.1' and os.path.isfile(test_file+pref+'c'):\n os.remove(test_file+pref+'c')\n except:\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n\n if hasattr(test_module,'test_suite'):\n # Using old styled test suite\n try:\n total_suite = test_module.test_suite(level)\n return total_suite._tests\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n suite_list = []\n for name in dir(test_module):\n obj = getattr(test_module, name)\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:4] != 'test':\n continue\n suite_list.extend(map(obj,self._get_method_names(obj,level)))\n print ' Found',len(suite_list),'tests for',module.__name__\n return suite_list\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\n if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):\n # only touching those modules that have tests/ directory\n try: module._pliuh_plauh\n except AttributeError: pass\n for name in dir(module):\n obj = getattr(module,name)\n if isinstance(obj,_ModuleLoader) \\\n and not hasattr(obj,'_ppimport_module') \\\n and not hasattr(obj,'_ppimport_exc_info'):\n self._touch_ppimported(obj)\n\n def test(self,level=1,verbosity=1):\n \"\"\" Run Scipy module test suite with level and verbosity.\n \"\"\"\n if type(self.package) is type(''):\n exec 'import %s as this_package' % (self.package)\n else:\n this_package = self.package\n\n self._touch_ppimported(this_package)\n\n package_name = this_package.__name__\n\n suites = []\n for name, module in sys.modules.items():\n if package_name != name[:len(package_name)] \\\n or module is None \\\n or os.path.basename(os.path.dirname(module.__file__))=='tests':\n continue\n suites.extend(self._get_module_tests(module, level))\n\n all_tests = unittest.TestSuite(suites)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\n def run(self):\n \"\"\" Run Scipy module test suite with level and verbosity\n taken from sys.argv. Requires optparse module.\n \"\"\"\n try:\n from optparse import OptionParser\n except ImportError:\n print 'Failed to import optparse module, ignoring.'\n return self.test()\n usage = r'usage: %prog []'\n parser = OptionParser(usage)\n parser.add_option(\"-v\", \"--verbosity\",\n action=\"store\",\n dest=\"verbosity\",\n default=1,\n type='int')\n parser.add_option(\"-l\", \"--level\",\n action=\"store\",\n dest=\"level\",\n default=1,\n type='int')\n (options, args) = parser.parse_args()\n self.test(options.level,options.verbosity)\n\n#------------\n \ndef remove_ignored_patterns(files,pattern):\n from fnmatch import fnmatch\n good_files = []\n for file in files:\n if not fnmatch(file,pattern):\n good_files.append(file)\n return good_files\n\ndef remove_ignored_files(original,ignored_files,cur_dir):\n \"\"\" This is actually expanded to do pattern matching.\n\n \"\"\"\n if not ignored_files: ignored_files = []\n ignored_modules = map(lambda x: x+'.py',ignored_files)\n ignored_packages = ignored_files[:]\n # always ignore setup.py and __init__.py files\n ignored_files = ['setup.py','setup_*.py','__init__.py']\n ignored_files += ignored_modules + ignored_packages\n ignored_files = map(lambda x,cur_dir=cur_dir: os.path.join(cur_dir,x),\n ignored_files)\n #print 'ignored:', ignored_files\n #good_files = filter(lambda x,ignored = ignored_files: x not in ignored,\n # original)\n good_files = original\n for pattern in ignored_files:\n good_files = remove_ignored_patterns(good_files,pattern)\n\n return good_files\n\n__all__.append('harvest_modules')\ndef harvest_modules(package,ignore=None):\n \"\"\"* Retreive a list of all modules that live within a package.\n\n Only retreive files that are immediate children of the\n package -- do not recurse through child packages or\n directories. The returned list contains actual modules, not\n just their names.\n *\"\"\"\n d,f = os.path.split(package.__file__)\n\n # go through the directory and import every py file there.\n common_dir = os.path.join(d,'*.py')\n py_files = glob.glob(common_dir)\n #py_files.remove(os.path.join(d,'__init__.py'))\n #py_files.remove(os.path.join(d,'setup.py'))\n\n py_files = remove_ignored_files(py_files,ignore,d)\n #print 'py_files:', py_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n\n all_modules = []\n for file in py_files:\n d,f = os.path.split(file)\n base,ext = os.path.splitext(f)\n mod = prefix + '.' + base\n #print 'module: import ' + mod\n try:\n exec ('import ' + mod)\n all_modules.append(eval(mod))\n except:\n print 'FAILURE to import ' + mod\n output_exception()\n\n return all_modules\n\n__all__.append('harvest_packages')\ndef harvest_packages(package,ignore = None):\n \"\"\" Retreive a list of all sub-packages that live within a package.\n\n Only retreive packages that are immediate children of this\n package -- do not recurse through child packages or\n directories. The returned list contains actual package objects, not\n just their names.\n \"\"\"\n join = os.path.join\n\n d,f = os.path.split(package.__file__)\n\n common_dir = os.path.abspath(d)\n all_files = os.listdir(d)\n\n all_files = remove_ignored_files(all_files,ignore,'')\n #print 'all_files:', all_files\n try:\n prefix = package.__name__\n except:\n prefix = ''\n all_packages = []\n for directory in all_files:\n path = join(common_dir,directory)\n if os.path.isdir(path) and \\\n os.path.exists(join(path,'__init__.py')):\n sub_package = prefix + '.' + directory\n #print 'sub-package import ' + sub_package\n try:\n exec ('import ' + sub_package)\n all_packages.append(eval(sub_package))\n except:\n print 'FAILURE to import ' + sub_package\n output_exception()\n return all_packages\n\n__all__.append('harvest_modules_and_packages')\ndef harvest_modules_and_packages(package,ignore=None):\n \"\"\" Retreive list of all packages and modules that live within a package.\n\n See harvest_packages() and harvest_modules()\n \"\"\"\n all = harvest_modules(package,ignore) + harvest_packages(package,ignore)\n return all\n\n__all__.append('harvest_test_suites')\ndef harvest_test_suites(package,ignore = None,level=10):\n \"\"\"\n package -- the module to test. This is an actual module object\n (not a string)\n ignore -- a list of module names to omit from the tests\n level -- a value between 1 and 10. 1 will run the minimum number\n of tests. This is a fast \"smoke test\". Tests that take\n longer to run should have higher numbers ranging up to 10.\n \"\"\"\n suites=[]\n test_modules = harvest_modules_and_packages(package,ignore)\n #for i in test_modules:\n # print i.__name__\n for module in test_modules:\n if hasattr(module,'test_suite'):\n try:\n suite = module.test_suite(level=level)\n if suite:\n suites.append(suite)\n else:\n print \" !! FAILURE without error - shouldn't happen\",\n print module.__name__\n except:\n print ' !! FAILURE building test for ', module.__name__\n print ' ',\n output_exception()\n else:\n try:\n print 'No test suite found for ', module.__name__\n except AttributeError:\n # __version__.py getting replaced by a string throws a kink\n # in checking for modules, so we think is a module has\n # actually been overwritten\n print 'No test suite found for ', str(module)\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\n__all__.append('module_test')\ndef module_test(mod_name,mod_file,level=10):\n \"\"\"*\n\n *\"\"\"\n #print 'testing', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);%s.test(%d)' % \\\n ((test_module,)*3 + (level,))\n\n # This would be better cause it forces a reload of the orginal\n # module. It doesn't behave with packages however.\n #test_string = 'reload(%s);import %s;reload(%s);%s.test(%d)' % \\\n # ((mod_name,) + (test_module,)*3)\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n\n__all__.append('module_test_suite')\ndef module_test_suite(mod_name,mod_file,level=10):\n #try:\n print ' creating test suite for:', mod_name\n d,f = os.path.split(mod_file)\n\n # insert the tests directory to the python path\n test_dir = os.path.join(d,'tests')\n sys.path.insert(0,test_dir)\n\n # call the \"test_xxx.test()\" function for the appropriate\n # module.\n\n # This should deal with package naming issues correctly\n short_mod_name = string.split(mod_name,'.')[-1]\n test_module = 'test_' + short_mod_name\n test_string = 'import %s;reload(%s);suite = %s.test_suite(%d)' % \\\n ((test_module,)*3+(level,))\n #print test_string\n exec(test_string)\n\n # remove test directory from python path.\n sys.path = sys.path[1:]\n return suite\n #except:\n # print ' !! FAILURE loading test suite from', test_module, ':'\n # print ' ',\n # output_exception()\n\n\n# Utility function to facilitate testing.\n\n__all__.append('assert_equal')\ndef assert_equal(actual,desired,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert desired == actual, msg\n\n__all__.append('assert_almost_equal')\ndef assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n \"\"\"\n msg = '\\nItems are not equal:\\n' + err_msg\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert round(abs(desired - actual),decimal) == 0, msg\n\n__all__.append('assert_approx_equal')\ndef assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=1):\n \"\"\" Raise an assertion if two items are not\n equal. I think this should be part of unittest.py\n Approximately equal is defined as the number of significant digits\n correct\n \"\"\"\n msg = '\\nItems are not equal to %d significant digits:\\n' % significant\n msg += err_msg\n actual, desired = map(float, (actual, desired))\n # Normalized the numbers to be in range (-10.0,10.0)\n try:\n sc_desired = desired/pow(10,math.floor(math.log10(abs(desired))))\n except ZeroDivisionError:\n sc_desired = 0.0\n try:\n sc_actual = actual/pow(10,math.floor(math.log10(abs(actual))))\n except ZeroDivisionError:\n sc_actual = 0.0\n try:\n if ( verbose and len(repr(desired)) < 100 and len(repr(actual)) ):\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n except:\n msg = msg \\\n + 'DESIRED: ' + repr(desired) \\\n + '\\nACTUAL: ' + repr(actual)\n assert math.fabs(sc_desired - sc_actual) < pow(10.,-1*significant), msg\n\n\n__all__.append('assert_array_equal')\ndef assert_array_equal(x,y,err_msg=''):\n x,y = asarray(x), asarray(y)\n msg = '\\nArrays are not equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(x,y))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=16)\n s2 = array2string(y,precision=16)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print shape(x),shape(y)\n raise ValueError, 'arrays are not equal'\n\n__all__.append('assert_array_almost_equal')\ndef assert_array_almost_equal(x,y,decimal=6,err_msg=''):\n x = asarray(x)\n y = asarray(y)\n msg = '\\nArrays are not almost equal'\n try:\n assert alltrue(equal(shape(x),shape(y))),\\\n msg + ' (shapes mismatch):\\n\\t' + err_msg\n reduced = ravel(equal(less_equal(around(abs(x-y),decimal),10.0**(-decimal)),1))\n cond = alltrue(reduced)\n if not cond:\n s1 = array2string(x,precision=decimal+1)\n s2 = array2string(y,precision=decimal+1)\n if len(s1)>120: s1 = s1[:120] + '...'\n if len(s2)>120: s2 = s2[:120] + '...'\n match = 100-100.0*reduced.tolist().count(1)/len(reduced)\n msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)\n assert cond,\\\n msg + '\\n\\t' + err_msg\n except ValueError:\n print sys.exc_value\n print shape(x),shape(y)\n print x, y\n raise ValueError, 'arrays are not almost equal'\n\n__all__.append('rand')\ndef rand(*args):\n \"\"\" Returns an array of random numbers with the given shape.\n used for testing\n \"\"\"\n import whrandom\n results = zeros(args,Float64)\n f = results.flat\n for i in range(len(f)):\n f[i] = whrandom.random()\n return results\n\ndef output_exception():\n try:\n type, value, tb = sys.exc_info()\n info = traceback.extract_tb(tb)\n #this is more verbose\n #traceback.print_exc()\n filename, lineno, function, text = info[-1] # last line only\n print \"%s:%d: %s: %s (in %s)\" %\\\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n", "methods": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 19, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 51, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 110, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 160, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 163, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 169, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 54, "complexity": 14, "token_count": 448, "parameters": [ "self", "module", "level" ], "start_line": 191, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 266, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 291, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 317, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 325, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 347, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 386, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 423, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 432, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 470, "end_line": 497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 500, "end_line": 522, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 532, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 549, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 566, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 597, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 619, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_array_less", "long_name": "assert_array_less( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 644, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 666, "end_line": 675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 677, "end_line": 687, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_package_path", "long_name": "set_package_path( level = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 3, "token_count": 137, "parameters": [ "level" ], "start_line": 19, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 0 }, { "name": "set_local_path", "long_name": "set_local_path( level = 1 )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 75, "parameters": [ "level" ], "start_line": 51, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "restore_path", "long_name": "restore_path( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "jiffies", "long_name": "jiffies( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "_proc_pid_stat" ], "start_line": 72, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( _proc_pid_stat = '/proc/%s/stat' % ( os . getpid ( )", "filename": "testing.py", "nloc": 10, "complexity": 2, "token_count": 54, "parameters": [ "_proc_pid_stat" ], "start_line": 84, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "jiffies", "long_name": "jiffies( _load_time = time . time ( )", "filename": "testing.py", "nloc": 4, "complexity": 1, "token_count": 27, "parameters": [ "_load_time" ], "start_line": 98, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "memusage", "long_name": "memusage( )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 103, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "measure", "long_name": "measure( self , code_str , times = 1 )", "filename": "testing.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "code_str", "times" ], "start_line": 110, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "_get_all_method_names", "long_name": "_get_all_method_names( cls )", "filename": "testing.py", "nloc": 8, "complexity": 5, "token_count": 56, "parameters": [ "cls" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , package )", "filename": "testing.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "package" ], "start_line": 160, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_module_str", "long_name": "_module_str( self , module )", "filename": "testing.py", "nloc": 5, "complexity": 2, "token_count": 43, "parameters": [ "self", "module" ], "start_line": 163, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_method_names", "long_name": "_get_method_names( self , clsobj , level )", "filename": "testing.py", "nloc": 21, "complexity": 10, "token_count": 136, "parameters": [ "self", "clsobj", "level" ], "start_line": 169, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 54, "complexity": 14, "token_count": 448, "parameters": [ "self", "module", "level" ], "start_line": 191, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 61, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 253, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 18, "complexity": 6, "token_count": 148, "parameters": [ "self", "level", "verbosity" ], "start_line": 266, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 291, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "remove_ignored_patterns", "long_name": "remove_ignored_patterns( files , pattern )", "filename": "testing.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "files", "pattern" ], "start_line": 317, "end_line": 323, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "remove_ignored_files", "long_name": "remove_ignored_files( original , ignored_files , cur_dir )", "filename": "testing.py", "nloc": 12, "complexity": 3, "token_count": 93, "parameters": [ "original", "ignored_files", "cur_dir" ], "start_line": 325, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "harvest_modules", "long_name": "harvest_modules( package , ignore = None )", "filename": "testing.py", "nloc": 21, "complexity": 4, "token_count": 134, "parameters": [ "package", "ignore" ], "start_line": 347, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "harvest_packages", "long_name": "harvest_packages( package , ignore = None )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 148, "parameters": [ "package", "ignore" ], "start_line": 386, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 0 }, { "name": "harvest_modules_and_packages", "long_name": "harvest_modules_and_packages( package , ignore = None )", "filename": "testing.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "package", "ignore" ], "start_line": 423, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "harvest_test_suites", "long_name": "harvest_test_suites( package , ignore = None , level = 10 )", "filename": "testing.py", "nloc": 23, "complexity": 6, "token_count": 113, "parameters": [ "package", "ignore", "level" ], "start_line": 432, "end_line": 467, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "module_test", "long_name": "module_test( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 10, "complexity": 1, "token_count": 98, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 470, "end_line": 497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "module_test_suite", "long_name": "module_test_suite( mod_name , mod_file , level = 10 )", "filename": "testing.py", "nloc": 12, "complexity": 1, "token_count": 103, "parameters": [ "mod_name", "mod_file", "level" ], "start_line": 500, "end_line": 522, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "assert_equal", "long_name": "assert_equal( actual , desired , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 92, "parameters": [ "actual", "desired", "err_msg", "verbose" ], "start_line": 532, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_almost_equal", "long_name": "assert_almost_equal( actual , desired , decimal = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 12, "complexity": 5, "token_count": 106, "parameters": [ "actual", "desired", "decimal", "err_msg", "verbose" ], "start_line": 549, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "assert_approx_equal", "long_name": "assert_approx_equal( actual , desired , significant = 7 , err_msg = '' , verbose = 1 )", "filename": "testing.py", "nloc": 22, "complexity": 7, "token_count": 195, "parameters": [ "actual", "desired", "significant", "err_msg", "verbose" ], "start_line": 566, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "assert_array_equal", "long_name": "assert_array_equal( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 597, "end_line": 616, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "assert_array_almost_equal", "long_name": "assert_array_almost_equal( x , y , decimal = 6 , err_msg = '' )", "filename": "testing.py", "nloc": 23, "complexity": 5, "token_count": 226, "parameters": [ "x", "y", "decimal", "err_msg" ], "start_line": 619, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "rand", "long_name": "rand( * args )", "filename": "testing.py", "nloc": 7, "complexity": 2, "token_count": 45, "parameters": [ "args" ], "start_line": 644, "end_line": 653, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "output_exception", "long_name": "output_exception( )", "filename": "testing.py", "nloc": 9, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 655, "end_line": 665, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "assert_array_less", "long_name": "assert_array_less( x , y , err_msg = '' )", "filename": "testing.py", "nloc": 20, "complexity": 5, "token_count": 189, "parameters": [ "x", "y", "err_msg" ], "start_line": 644, "end_line": 663, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "nloc": 491, "complexity": 121, "token_count": 3599, "diff_parsed": { "added": [ " less_equal,array2string,less", "__all__.append('assert_array_less')", "def assert_array_less(x,y,err_msg=''):", " x,y = asarray(x), asarray(y)", " msg = '\\nArrays are not less-ordered'", " try:", " assert alltrue(equal(shape(x),shape(y))),\\", " msg + ' (shapes mismatch):\\n\\t' + err_msg", " reduced = ravel(less(x,y))", " cond = alltrue(reduced)", " if not cond:", " s1 = array2string(x,precision=16)", " s2 = array2string(y,precision=16)", " if len(s1)>120: s1 = s1[:120] + '...'", " if len(s2)>120: s2 = s2[:120] + '...'", " match = 100-100.0*reduced.tolist().count(1)/len(reduced)", " msg = msg + ' (mismatch %s%%):\\n\\tArray 1: %s\\n\\tArray 2: %s' % (match,s1,s2)", " assert cond,\\", " msg + '\\n\\t' + err_msg", " except ValueError:", " print shape(x),shape(y)", " raise ValueError, 'arrays are not less-ordered'", "" ], "deleted": [ " less_equal,array2string" ] } } ] }, { "hash": "449e90cf8ccd615976cd22ba4a59e89207cfc481", "msg": "Disabled mmx,sse under win32 to see if they caused internal compiler error (in emit_swap_insn at reg-stack.c:990) when compiling specfun.f", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-12-20T13:41:18+00:00", "author_timezone": 0, "committer_date": "2003-12-20T13:41:18+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "13ec9dd00ebcc4a8be35a28ead36d7f16cb044e9" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 2, "insertions": 4, "lines": 6, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.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": "@@ -1105,10 +1105,12 @@ def get_opt(self):\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n- if cpu.has_mmx(): opt = opt + ' -mmmx ' \n+ if sys.platform!='win32':\n+ if cpu.has_mmx(): opt = opt + ' -mmmx ' \n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n- if cpu.has_sse(): opt = opt + ' -msse '\n+ if sys.platform!='win32':\n+ if cpu.has_sse(): opt = opt + ' -msse '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n", "added_lines": 4, "deleted_lines": 2, "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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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_AthlonMP():\n opt = opt + ' -march=athlon-mp '\n # there's also: athlon-tbird, athlon-4, athlon-xp\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 sys.platform!='win32':\n if cpu.has_mmx(): opt = opt + ' -mmmx ' \n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if sys.platform!='win32':\n if cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n if not self.get_version():\n fc = 'ifort'\n self.version = None\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 if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n if self.get_version() and self.version >= '8.0':\n return [self.f77_compiler,'-shared','-nofor_main']\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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n self.version = None\n if not self.get_version():\n fc = 'ifort'\n self.version = None\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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 [win32,linux]\n Forte [sun]\n (Sun)\n SGI [irix]\n Intel [win32,linux]\n Itanium [win32,linux]\n NAG [linux]\n Compaq [win32,linux]\n Gnu [win32,linux,..]\n VAST [win32??,linux]\n F [unsupported]\n Lahey [win32??,linux]\n PG [linux]\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 yellow_text, cyan_text\nfrom scipy_distutils import log\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 if compiler=='mingw32':\n from scipy_distutils.mingw32_support import build_import_library\n build_import_library()\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 fcompiler_exec = os.environ.get('F77')\n f90compiler_exec = os.environ.get('F90')\n for compiler_class in all_compilers:\n compiler = compiler_class(fcompiler_exec,f90compiler_exec)\n if not compiler.is_available():\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 log.warn('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 log.debug('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 log.info('using %s Fortran compiler', fc)\n\n if sys.platform=='win32':\n #XXX: given fc.vendor, how to decide whether msvc or mingw32\n # should be used under win32?\n if fc.vendor in ['Compaq','Intel']:\n set_windows_compiler('msvc')\n else:\n # Is only Gnu compiler used with mingw32??\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 log.info(\" 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 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 log.info(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 log.info(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 log.info(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' \\\n or sys.platform[:4] == 'irix' \\\n or sys.platform[:3] == 'osf':\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 log.info('detecting %s Fortran compiler...'%(self.vendor))\n log.debug(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 log.info('found %s', 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 log.warn('failed to match version!')\n else:\n log.warn('%s: %s', exit_status,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 log.debug(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 log.debug(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 log.info('found: '+out_text)\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n log.warn('%s: %s', exit_status,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\\)|\\(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 os.name != 'posix':\n # this should presumably correspond to Apple\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_AthlonMP():\n opt = opt + ' -march=athlon-mp '\n # there's also: athlon-tbird, athlon-4, athlon-xp\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 self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_sse(): opt = opt + ' -msse '\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.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 log.debug(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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n if not self.get_version():\n fc = 'ifort'\n self.version = None\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 if cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n if self.get_version() and self.version >= '8.0':\n return [self.f77_compiler,'-shared','-nofor_main']\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 self.ver_cmd = fc+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n self.version = None\n if not self.get_version():\n fc = 'ifort'\n self.version = None\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass intel_ia32_visual_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 compile_switch = ' /c '\n object_switch = ' /Fo' #No space after /Fo !\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /verbose /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 = 'ifl'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' /nologo /MD /nbs /Qlowercase /us '\n # Compatibility problems betwen VC6 and VC7, use /Qvc6 for VC6 conformance\n\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 -4L72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' /4Yb /d2 '\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 if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' /O3 /Qip /Qipo /Qipo_obj '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' /G6 /Qaxi '\n elif cpu.is_PentiumIII():\n opt = opt + ' /G6 /QaxK '\n elif cpu.is_Pentium():\n opt = opt + ' /G5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' /G7 /QaxW '\n if cpu.has_mmx():\n opt = opt + ' /QaxM '\n return opt\n\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\n\nclass intel_itanium_visual_fortran_compiler(intel_ia32_visual_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 = 'efl' #XXX: this is just a wild guess!\n intel_ia32_visual_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\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 log.warn(\"\"\"\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 from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n\n switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n debug = ' /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 /fast /optimize:5 /unroll:0 /math_library:fast '\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 gnu_fortran_compiler,\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_visual_fortran_compiler,\n intel_itanium_visual_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_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", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 66, "complexity": 33, "token_count": 386, "parameters": [ "self" ], "start_line": 1060, "end_line": 1129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1131, "end_line": 1147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1149, "end_line": 1155, "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": 1157, "end_line": 1165, "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": 1167, "end_line": 1168, "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": 1170, "end_line": 1171, "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": 28, "complexity": 6, "token_count": 183, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1182, "end_line": 1216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 1218, "end_line": 1232, "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": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1234, "end_line": 1237, "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": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1239, "end_line": 1248, "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": 10, "complexity": 3, "token_count": 74, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1257, "end_line": 1266, "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": 20, "complexity": 4, "token_count": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1282, "end_line": 1310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1312, "end_line": 1326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1329, "end_line": 1338, "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": 1348, "end_line": 1351, "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": 1358, "end_line": 1379, "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": 1381, "end_line": 1383, "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": 1385, "end_line": 1386, "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": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1400, "end_line": 1428, "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": 1434, "end_line": 1435, "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": 1448, "end_line": 1479, "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": 1481, "end_line": 1482, "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": 1490, "end_line": 1514, "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": 1516, "end_line": 1519, "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": 1521, "end_line": 1525, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1541, "end_line": 1569, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1571, "end_line": 1573, "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": 1583, "end_line": 1608, "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": 1610, "end_line": 1612, "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": 1614, "end_line": 1615, "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": 1623, "end_line": 1648, "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": 1650, "end_line": 1651, "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": 1653, "end_line": 1656, "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": 1658, "end_line": 1664, "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": 1669, "end_line": 1677, "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": 10, "complexity": 2, "token_count": 51, "parameters": [ "compiler" ], "start_line": 73, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 92, "end_line": 97, "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": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 104, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 145, "end_line": 162, "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": 145, "parameters": [ "self" ], "start_line": 166, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "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": 200, "end_line": 202, "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": 204, "end_line": 207, "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": 211, "end_line": 218, "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": 220, "end_line": 240, "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": 242, "end_line": 247, "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": 249, "end_line": 254, "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": 258, "end_line": 275, "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": 279, "end_line": 288, "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": 292, "end_line": 303, "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": 305, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 347, "end_line": 352, "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": 362, "end_line": 383, "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": 400, "end_line": 425, "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": 427, "end_line": 456, "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": 458, "end_line": 463, "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": 465, "end_line": 468, "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": 169, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 470, "end_line": 498, "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": 502, "end_line": 505, "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": 507, "end_line": 512, "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": 514, "end_line": 518, "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": 520, "end_line": 522, "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": 524, "end_line": 526, "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": 528, "end_line": 529, "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": 132, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 531, "end_line": 550, "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": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 552, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "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": 599, "end_line": 607, "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": 609, "end_line": 610, "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": 129, "parameters": [ "self" ], "start_line": 612, "end_line": 637, "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": 639, "end_line": 640, "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": 641, "end_line": 642, "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": 643, "end_line": 644, "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": 645, "end_line": 646, "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": 647, "end_line": 652, "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": 654, "end_line": 669, "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": 677, "end_line": 678, "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": 680, "end_line": 685, "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": 693, "end_line": 756, "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": 758, "end_line": 773, "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": 775, "end_line": 776, "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": 809, "end_line": 850, "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": 852, "end_line": 857, "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": 133, "parameters": [ "self" ], "start_line": 859, "end_line": 877, "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": 882, "end_line": 883, "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": 895, "end_line": 915, "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": 917, "end_line": 937, "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": 939, "end_line": 941, "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": 943, "end_line": 944, "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": 946, "end_line": 956, "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": 963, "end_line": 984, "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": 114, "parameters": [ "self" ], "start_line": 986, "end_line": 1004, "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": 1012, "end_line": 1058, "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": 64, "complexity": 31, "token_count": 372, "parameters": [ "self" ], "start_line": 1060, "end_line": 1127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1129, "end_line": 1145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "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": 1147, "end_line": 1153, "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": 1155, "end_line": 1163, "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": 1165, "end_line": 1166, "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": 1168, "end_line": 1169, "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": 28, "complexity": 6, "token_count": 183, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1180, "end_line": 1214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 1216, "end_line": 1230, "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": 4, "complexity": 3, "token_count": 36, "parameters": [ "self" ], "start_line": 1232, "end_line": 1235, "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": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1237, "end_line": 1246, "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": 10, "complexity": 3, "token_count": 74, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1255, "end_line": 1264, "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": 20, "complexity": 4, "token_count": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1280, "end_line": 1308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1310, "end_line": 1324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "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": 1327, "end_line": 1336, "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": 1346, "end_line": 1349, "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": 1356, "end_line": 1377, "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": 1379, "end_line": 1381, "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": 1383, "end_line": 1384, "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": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1398, "end_line": 1426, "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": 1432, "end_line": 1433, "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": 1446, "end_line": 1477, "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": 1479, "end_line": 1480, "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": 1488, "end_line": 1512, "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": 1514, "end_line": 1517, "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": 1519, "end_line": 1523, "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": 21, "complexity": 4, "token_count": 137, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1539, "end_line": 1567, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 1569, "end_line": 1571, "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": 1581, "end_line": 1606, "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": 1608, "end_line": 1610, "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": 1612, "end_line": 1613, "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": 1621, "end_line": 1646, "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": 1648, "end_line": 1649, "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": 1651, "end_line": 1654, "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": 1656, "end_line": 1662, "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": 1667, "end_line": 1675, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 66, "complexity": 33, "token_count": 386, "parameters": [ "self" ], "start_line": 1060, "end_line": 1129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 70, "top_nesting_level": 1 } ], "nloc": 1256, "complexity": 333, "token_count": 7342, "diff_parsed": { "added": [ " if sys.platform!='win32':", " if cpu.has_mmx(): opt = opt + ' -mmmx '", " if sys.platform!='win32':", " if cpu.has_sse(): opt = opt + ' -msse '" ], "deleted": [ " if cpu.has_mmx(): opt = opt + ' -mmmx '", " if cpu.has_sse(): opt = opt + ' -msse '" ] } } ] }, { "hash": "594e5eba8fadd922c50c86c05a736ed53b59e6b5", "msg": "Added weave to scipy_core", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-01-04T10:54:17+00:00", "author_timezone": 0, "committer_date": "2004-01-04T10:54:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "449e90cf8ccd615976cd22ba4a59e89207cfc481" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/repo_copy", "deletions": 2, "insertions": 3, "lines": 5, "files": 2, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "setup.py", "new_path": "setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -4,6 +4,7 @@\n scipy_test\n scipy_distutils\n scipy_base\n+ weave\n \n Usage:\n python setup.py install\n@@ -17,7 +18,7 @@\n from scipy_distutils.misc_util import default_config_dict\n from scipy_distutils.misc_util import get_path, merge_config_dicts\n \n-bundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n+bundle_packages = ['scipy_distutils','scipy_test','scipy_base','weave']\n \n def setup_package():\n old_path = os.getcwd()\n", "added_lines": 2, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n weave\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.core import setup\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base','weave']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration())\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nBundle of SciPy core modules:\n scipy_test\n scipy_distutils\n scipy_base\n\nUsage:\n python setup.py install\n python setup.py sdist -f\n\"\"\"\n\nimport os\nimport sys\n\nfrom scipy_distutils.core import setup\nfrom scipy_distutils.misc_util import default_config_dict\nfrom scipy_distutils.misc_util import get_path, merge_config_dicts\n\nbundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n\ndef setup_package():\n old_path = os.getcwd()\n local_path = os.path.dirname(os.path.abspath(sys.argv[0]))\n os.chdir(local_path)\n sys.path.insert(0, local_path)\n\n try:\n configs = [{'name':'Scipy_core'}]\n versions = []\n for n in bundle_packages:\n sys.path.insert(0,os.path.join(local_path,n))\n try:\n mod = __import__('setup_'+n)\n configs.append(mod.configuration())\n mod = __import__(n+'_version')\n versions.append(mod)\n finally:\n del sys.path[0]\n \n config_dict = merge_config_dicts(configs)\n\n major = max([v.major for v in versions])\n minor = max([v.minor for v in versions])\n micro = max([v.micro for v in versions])\n release_level = min([v.release_level for v in versions])\n cvs_minor = reduce(lambda a,b:a+b,[v.cvs_minor for v in versions],0)\n cvs_serial = reduce(lambda a,b:a+b,[v.cvs_serial for v in versions],0)\n\n scipy_core_version = '%(major)d.%(minor)d.%(micro)d'\\\n '_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n\n print 'SciPy Core Version %s' % scipy_core_version\n setup( version = scipy_core_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy core modules: scipy_{distutils,test,base}\",\n license = \"SciPy License (BSD Style)\",\n url = \"http://www.scipy.org\",\n **config_dict\n )\n\n finally:\n del sys.path[0]\n os.chdir(old_path)\n\nif __name__ == \"__main__\":\n setup_package()\n", "methods": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 39, "complexity": 10, "token_count": 304, "parameters": [], "start_line": 23, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 } ], "methods_before": [ { "name": "setup_package", "long_name": "setup_package( )", "filename": "setup.py", "nloc": 39, "complexity": 10, "token_count": 304, "parameters": [], "start_line": 22, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 45, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 58, "complexity": 10, "token_count": 349, "diff_parsed": { "added": [ " weave", "bundle_packages = ['scipy_distutils','scipy_test','scipy_base','weave']" ], "deleted": [ "bundle_packages = ['scipy_distutils','scipy_test','scipy_base']" ] } }, { "old_path": "weave/weave_version.py", "new_path": "weave/weave_version.py", "filename": "weave_version.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,6 +1,6 @@\n major = 0\n minor = 2\n-micro = 0\n+micro = 1\n release_level = 'alpha'\n \n from __cvs_version__ import cvs_version\n", "added_lines": 1, "deleted_lines": 1, "source_code": "major = 0\nminor = 2\nmicro = 1\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nweave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "source_code_before": "major = 0\nminor = 2\nmicro = 0\nrelease_level = 'alpha'\n\nfrom __cvs_version__ import cvs_version\ncvs_minor = cvs_version[-3]\ncvs_serial = cvs_version[-1]\n\nweave_version = '%(major)d.%(minor)d.%(micro)d_%(release_level)s'\\\n '_%(cvs_minor)d.%(cvs_serial)d' % (locals ())\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 9, "complexity": 0, "token_count": 41, "diff_parsed": { "added": [ "micro = 1" ], "deleted": [ "micro = 0" ] } } ] }, { "hash": "f5b889b010ef1c5c5b3f3ab44068219c24cde8f7", "msg": "Applied Brett's patch to fix phantom g (g++) when using mingw", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2004-01-12T13:43:49+00:00", "author_timezone": 0, "committer_date": "2004-01-12T13:43:49+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "594e5eba8fadd922c50c86c05a736ed53b59e6b5" ], "project_name": "repo_copy", "project_path": "/tmp/tmp11u1uyz6/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/mingw32_support.py", "new_path": "scipy_distutils/mingw32_support.py", "filename": "mingw32_support.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -93,7 +93,7 @@ def __init__ (self,\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n- self.compiler_cxx = 'g++'\n+ self.compiler_cxx = ['g++']\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n", "added_lines": 1, "deleted_lines": 1, "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 # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = ['g++']\n \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 export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (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 target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\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 distutils.ccompiler._default_compilers\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", "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 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 # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \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 export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n args = (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 target_lang)\n if self.gcc_version < \"3.0.0\":\n func = distutils.cygwinccompiler.CygwinCCompiler.link\n else:\n func = UnixCCompiler.link\n func(*args[:func.im_func.func_code.co_argcount])\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\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 distutils.ccompiler._default_compilers\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", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 212, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 141, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 189, "end_line": 197, "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": 199, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 33, "complexity": 2, "token_count": 112, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 141, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "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": 189, "end_line": 197, "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": 199, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 212, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 } ], "nloc": 149, "complexity": 23, "token_count": 876, "diff_parsed": { "added": [ " self.compiler_cxx = ['g++']" ], "deleted": [ " self.compiler_cxx = 'g++'" ] } } ] } ]