[ { "hash": "c550d135366cfe1f819ffe633f7453de3c50c4ab", "msg": "Cont. SourceGenerator: docs, using it scipy_base", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-23T08:26:03+00:00", "author_timezone": 0, "committer_date": "2003-10-23T08:26:03+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "8266c6003fe8037db933873842aec4e154320872" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 8, "insertions": 45, "lines": 53, "files": 5, "dmm_unit_size": 0.6896551724137931, "dmm_unit_complexity": 0.9310344827586207, "dmm_unit_interfacing": 0.9655172413793104, "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": "@@ -7,6 +7,9 @@\n import shutil\n \n def configuration(parent_package=''):\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__)\n config = default_config_dict(package,parent_package)\n@@ -17,8 +20,13 @@ def configuration(parent_package=''):\n \n # fastumath module\n # scipy_base.fastumath module\n- sources = ['fastumathmodule.c','isnan.c']\n- sources = [os.path.join(local_path,x) for x in sources]\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_BE',1))\n", "added_lines": 10, "deleted_lines": 2, "source_code": "#!/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=''):\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__)\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_BE',1))\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=''):\n package = 'scipy_base'\n local_path = get_path(__name__)\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 sources = ['fastumathmodule.c','isnan.c']\n sources = [os.path.join(local_path,x) for x in sources]\n define_macros = []\n if sys.byteorder != \"little\":\n define_macros.append(('USE_MCONF_LITE_BE',1))\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 = '' )", "filename": "setup_scipy_base.py", "nloc": 26, "complexity": 4, "token_count": 207, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 19, "complexity": 4, "token_count": 151, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 26, "complexity": 4, "token_count": 207, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "nloc": 45, "complexity": 4, "token_count": 297, "diff_parsed": { "added": [ " from scipy_distutils.misc_util import get_path,default_config_dict,\\", " dot_join,SourceGenerator", "", " umath_c_sources = ['fastumathmodule.c',", " 'fastumath_unsigned.inc','fastumath_nounsigned.inc']", " umath_c_sources = [os.path.join(local_path,x) for x in umath_c_sources]", " umath_c = SourceGenerator(func = None,", " target = os.path.join(local_path,'fastumathmodule.c'),", " sources = umath_c_sources)", " sources = [umath_c, os.path.join(local_path,'isnan.c')]" ], "deleted": [ " sources = ['fastumathmodule.c','isnan.c']", " sources = [os.path.join(local_path,x) for x in sources]" ] } }, { "old_path": "scipy_distutils/command/build_ext.py", "new_path": "scipy_distutils/command/build_ext.py", "filename": "build_ext.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -19,6 +19,10 @@ def finalize_options (self):\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n+\n+ # SourceGenerator support\n+ if hasattr(ext,'generate_sources'):\n+ ext.generate_sources()\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n@@ -113,6 +117,7 @@ def build_extension(self, ext):\n ' '.join(linker_so))\n \n # end of fortran source support\n+\n res = old_build_ext.build_extension(self,ext)\n \n if save_linker_so is not self.compiler.linker_so:\n@@ -129,7 +134,11 @@ def get_source_files (self):\n \n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n- filenames.extend(ext.sources)\n- filenames.extend(get_headers(get_directories(ext.sources)))\n+ if hasattr(ext,'get_sources'):\n+ sources = ext.get_sources()\n+ else:\n+ sources = ext.sources\n+ filenames.extend(sources)\n+ filenames.extend(get_headers(get_directories(sources)))\n \n return filenames\n", "added_lines": 11, "deleted_lines": 2, "source_code": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string, sys\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n\n # SourceGenerator support\n if hasattr(ext,'generate_sources'):\n ext.generate_sources()\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n flib_name = ext_name + '_f2py'\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(flib_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(flib_name) and \\\n flib_name not in ext.libraries:\n ext.libraries.insert(0,flib_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n d = build_flib.build_flib\n if d not in ext.library_dirs:\n ext.library_dirs.append(d)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n log.debug('replacing linker_so %r with %r',\n ' '.join(save_linker_so),\n ' '.join(linker_so))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so and save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n log.debug('replacing linker_so %r with %r',\n ' '.join(save_linker_so),\n ' '.join(linker_so))\n\n # end of fortran source support\n\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n log.debug('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n if hasattr(ext,'get_sources'):\n sources = ext.get_sources()\n else:\n sources = ext.sources\n filenames.extend(sources)\n filenames.extend(get_headers(get_directories(sources)))\n\n return filenames\n", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string, sys\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util, log\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n flib_name = ext_name + '_f2py'\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(flib_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(flib_name) and \\\n flib_name not in ext.libraries:\n ext.libraries.insert(0,flib_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n d = build_flib.build_flib\n if d not in ext.library_dirs:\n ext.library_dirs.append(d)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n log.debug('replacing linker_so %r with %r',\n ' '.join(save_linker_so),\n ' '.join(linker_so))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so and save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n log.debug('replacing linker_so %r with %r',\n ' '.join(save_linker_so),\n ' '.join(linker_so))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n log.debug('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 78, "complexity": 29, "token_count": 566, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 109, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 11, "complexity": 3, "token_count": 66, "parameters": [ "self" ], "start_line": 131, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "methods_before": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 76, "complexity": 28, "token_count": 553, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 104, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 126, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 78, "complexity": 29, "token_count": 566, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 109, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 11, "complexity": 3, "token_count": 66, "parameters": [ "self" ], "start_line": 131, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "nloc": 102, "complexity": 33, "token_count": 712, "diff_parsed": { "added": [ "", " # SourceGenerator support", " if hasattr(ext,'generate_sources'):", " ext.generate_sources()", "", " if hasattr(ext,'get_sources'):", " sources = ext.get_sources()", " else:", " sources = ext.sources", " filenames.extend(sources)", " filenames.extend(get_headers(get_directories(sources)))" ], "deleted": [ " filenames.extend(ext.sources)", " filenames.extend(get_headers(get_directories(ext.sources)))" ] } }, { "old_path": "scipy_distutils/command/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -225,7 +225,7 @@ def fortran_sources_to_flib(self, ext):\n f_files = []\n \n for file in ext.sources:\n- if fortran_ext_re(file):\n+ if fortran_ext_re(str(file)):\n f_files.append(file)\n else:\n sources.append(file)\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text,SourceGenerator\nfrom scipy_distutils import log\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n log.info('using F2PY %s', f2py2e.f2py2e.f2py_version)\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n if isinstance(source,SourceGenerator):\n (base, source_ext) = os.path.splitext(str(source))\n (source_dir, base) = os.path.split(base)\n else:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n if isinstance(source,SourceGenerator):\n source = source.generate()\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n log.warn('%s provides %s but this extension is %s',\n source,`base`,`ext_name`)\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n if isinstance(source,SourceGenerator):\n source = source.generate()\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n log.debug(\"f2py %s\",\n string.join(fortran_sources + f2py_opts2,' '))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n log.warn('Only one .pyf file can be used per Extension'\\\n ' but got %s.', len(f2py_sources))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n log.debug(\"f2py %s\",\n string.join(f2py_options+[source],' '))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(str(file)):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name+'_f2py'\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n\n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text,SourceGenerator\nfrom scipy_distutils import log\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n log.info('using F2PY %s', f2py2e.f2py2e.f2py_version)\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n if isinstance(source,SourceGenerator):\n (base, source_ext) = os.path.splitext(str(source))\n (source_dir, base) = os.path.split(base)\n else:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n if isinstance(source,SourceGenerator):\n source = source.generate()\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n log.warn('%s provides %s but this extension is %s',\n source,`base`,`ext_name`)\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n if isinstance(source,SourceGenerator):\n source = source.generate()\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n log.debug(\"f2py %s\",\n string.join(fortran_sources + f2py_opts2,' '))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n log.warn('Only one .pyf file can be used per Extension'\\\n ' but got %s.', len(f2py_sources))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n log.debug(\"f2py %s\",\n string.join(f2py_options+[source],' '))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name+'_f2py'\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n\n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 48, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 62, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 109, "complexity": 31, "token_count": 772, "parameters": [ "self", "sources", "ext" ], "start_line": 74, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 142, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 201, "parameters": [ "self", "ext" ], "start_line": 219, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 48, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 62, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 109, "complexity": 31, "token_count": 772, "parameters": [ "self", "sources", "ext" ], "start_line": 74, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 142, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 198, "parameters": [ "self", "ext" ], "start_line": 219, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 201, "parameters": [ "self", "ext" ], "start_line": 219, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "nloc": 184, "complexity": 46, "token_count": 1259, "diff_parsed": { "added": [ " if fortran_ext_re(str(file)):" ], "deleted": [ " if fortran_ext_re(file):" ] } }, { "old_path": "scipy_distutils/extension.py", "new_path": "scipy_distutils/extension.py", "filename": "extension.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,7 +3,7 @@\n Provides the Extension class, used to describe C/C++ extension\n modules in setup scripts.\n \n-Overridden to support f2py.\n+Overridden to support f2py and SourceGenerator.\n \"\"\"\n \n # created 2000/05/30, Greg Ward\n@@ -11,6 +11,7 @@\n __revision__ = \"$Id$\"\n \n from distutils.extension import Extension as old_Extension\n+from scipy_distutils.misc_util import SourceGenerator\n \n import re\n cxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\n@@ -58,4 +59,18 @@ def has_f2py_sources(self):\n return 1\n return 0\n \n+ def generate_sources(self):\n+ for i in range(len(self.sources)):\n+ if isinstance(self.sources[i],SourceGenerator):\n+ self.sources[i] = self.sources[i].generate()\n+\n+ def get_sources(self):\n+ sources = []\n+ for source in self.sources:\n+ if isinstance(source,SourceGenerator):\n+ sources.extend(source.sources)\n+ else:\n+ sources.append(source)\n+ return sources\n+\n # class Extension\n", "added_lines": 16, "deleted_lines": 1, "source_code": "\"\"\"distutils.extension\n\nProvides the Extension class, used to describe C/C++ extension\nmodules in setup scripts.\n\nOverridden to support f2py and SourceGenerator.\n\"\"\"\n\n# created 2000/05/30, Greg Ward\n\n__revision__ = \"$Id$\"\n\nfrom distutils.extension import Extension as old_Extension\nfrom scipy_distutils.misc_util import SourceGenerator\n\nimport re\ncxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_pyf_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\\Z',re.I).match\n\nclass Extension(old_Extension):\n def __init__ (self, name, sources,\n include_dirs=None,\n define_macros=None,\n undef_macros=None,\n library_dirs=None,\n libraries=None,\n runtime_library_dirs=None,\n extra_objects=None,\n extra_compile_args=None,\n extra_link_args=None,\n export_symbols=None,\n f2py_options=None\n ):\n old_Extension.__init__(self,name, [],\n include_dirs,\n define_macros,\n undef_macros,\n library_dirs,\n libraries,\n runtime_library_dirs,\n extra_objects,\n extra_compile_args,\n extra_link_args,\n export_symbols)\n # Avoid assert statements checking that sources contains strings:\n self.sources = sources\n \n self.f2py_options = f2py_options or []\n\n def has_cxx_sources(self):\n for source in self.sources:\n if cxx_ext_re(str(source)):\n return 1\n return 0\n\n def has_f2py_sources(self):\n for source in self.sources:\n if fortran_pyf_ext_re(str(source)):\n return 1\n return 0\n\n def generate_sources(self):\n for i in range(len(self.sources)):\n if isinstance(self.sources[i],SourceGenerator):\n self.sources[i] = self.sources[i].generate()\n\n def get_sources(self):\n sources = []\n for source in self.sources:\n if isinstance(source,SourceGenerator):\n sources.extend(source.sources)\n else:\n sources.append(source)\n return sources\n\n# class Extension\n", "source_code_before": "\"\"\"distutils.extension\n\nProvides the Extension class, used to describe C/C++ extension\nmodules in setup scripts.\n\nOverridden to support f2py.\n\"\"\"\n\n# created 2000/05/30, Greg Ward\n\n__revision__ = \"$Id$\"\n\nfrom distutils.extension import Extension as old_Extension\n\nimport re\ncxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_pyf_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\\Z',re.I).match\n\nclass Extension(old_Extension):\n def __init__ (self, name, sources,\n include_dirs=None,\n define_macros=None,\n undef_macros=None,\n library_dirs=None,\n libraries=None,\n runtime_library_dirs=None,\n extra_objects=None,\n extra_compile_args=None,\n extra_link_args=None,\n export_symbols=None,\n f2py_options=None\n ):\n old_Extension.__init__(self,name, [],\n include_dirs,\n define_macros,\n undef_macros,\n library_dirs,\n libraries,\n runtime_library_dirs,\n extra_objects,\n extra_compile_args,\n extra_link_args,\n export_symbols)\n # Avoid assert statements checking that sources contains strings:\n self.sources = sources\n \n self.f2py_options = f2py_options or []\n\n def has_cxx_sources(self):\n for source in self.sources:\n if cxx_ext_re(str(source)):\n return 1\n return 0\n\n def has_f2py_sources(self):\n for source in self.sources:\n if fortran_pyf_ext_re(str(source)):\n return 1\n return 0\n\n# class Extension\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , sources , include_dirs = None , define_macros = None , undef_macros = None , library_dirs = None , libraries = None , runtime_library_dirs = None , extra_objects = None , extra_compile_args = None , extra_link_args = None , export_symbols = None , f2py_options = None )", "filename": "extension.py", "nloc": 26, "complexity": 2, "token_count": 97, "parameters": [ "self", "name", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options" ], "start_line": 21, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( self )", "filename": "extension.py", "nloc": 5, "complexity": 3, "token_count": 25, "parameters": [ "self" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "extension.py", "nloc": 5, "complexity": 3, "token_count": 25, "parameters": [ "self" ], "start_line": 56, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self )", "filename": "extension.py", "nloc": 4, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_sources", "long_name": "get_sources( self )", "filename": "extension.py", "nloc": 8, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , sources , include_dirs = None , define_macros = None , undef_macros = None , library_dirs = None , libraries = None , runtime_library_dirs = None , extra_objects = None , extra_compile_args = None , extra_link_args = None , export_symbols = None , f2py_options = None )", "filename": "extension.py", "nloc": 26, "complexity": 2, "token_count": 97, "parameters": [ "self", "name", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options" ], "start_line": 20, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( self )", "filename": "extension.py", "nloc": 5, "complexity": 3, "token_count": 25, "parameters": [ "self" ], "start_line": 49, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "extension.py", "nloc": 5, "complexity": 3, "token_count": 25, "parameters": [ "self" ], "start_line": 55, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "generate_sources", "long_name": "generate_sources( self )", "filename": "extension.py", "nloc": 4, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_sources", "long_name": "get_sources( self )", "filename": "extension.py", "nloc": 8, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "nloc": 62, "complexity": 14, "token_count": 298, "diff_parsed": { "added": [ "Overridden to support f2py and SourceGenerator.", "from scipy_distutils.misc_util import SourceGenerator", " def generate_sources(self):", " for i in range(len(self.sources)):", " if isinstance(self.sources[i],SourceGenerator):", " self.sources[i] = self.sources[i].generate()", "", " def get_sources(self):", " sources = []", " for source in self.sources:", " if isinstance(source,SourceGenerator):", " sources.extend(source.sources)", " else:", " sources.append(source)", " return sources", "" ], "deleted": [ "Overridden to support f2py." ] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -216,7 +216,7 @@ def get_build_temp():\n return os.path.join('build','temp'+plat_specifier)\n \n class SourceGenerator:\n- def __init__(self,func,target,sources=[]):\n+ def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target):\n caller_dir = os.path.dirname(sys._getframe(1).f_globals['__file__'])\n prefix = os.path.commonprefix([caller_dir,os.getcwd()])\n@@ -225,6 +225,7 @@ def __init__(self,func,target,sources=[]):\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@@ -232,6 +233,10 @@ def generate(self):\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- self.func(self.target,self.sources)\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", "added_lines": 7, "deleted_lines": 2, "source_code": "import os,sys,string\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):\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 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 def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target):\n caller_dir = os.path.dirname(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", "source_code_before": "import os,sys,string\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):\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 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 def __init__(self,func,target,sources=[]):\n if not os.path.isabs(target):\n caller_dir = os.path.dirname(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 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 self.func(self.target,self.sources)\n assert os.path.exists(self.target),`self.target`\n return self.target\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": 5, "end_line": 19, "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": 40, "end_line": 42, "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": 43, "end_line": 44, "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 )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 46, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "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": 63, "end_line": 65, "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": 67, "end_line": 70, "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": 72, "end_line": 73, "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": 75, "end_line": 89, "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": 91, "end_line": 101, "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": 103, "end_line": 115, "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": 122, "end_line": 160, "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": 162, "end_line": 169, "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": 171, "end_line": 178, "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": 180, "end_line": 185, "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": 187, "end_line": 188, "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": 190, "end_line": 205, "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": 207, "end_line": 211, "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": 213, "end_line": 216, "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": 10, "complexity": 2, "token_count": 114, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 219, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 229, "end_line": 230, "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": 231, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 5, "end_line": 19, "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": 40, "end_line": 42, "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": 43, "end_line": 44, "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 )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 46, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "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": 63, "end_line": 65, "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": 67, "end_line": 70, "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": 72, "end_line": 73, "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": 75, "end_line": 89, "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": 91, "end_line": 101, "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": 103, "end_line": 115, "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": 122, "end_line": 160, "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": 162, "end_line": 169, "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": 171, "end_line": 178, "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": 180, "end_line": 185, "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": 187, "end_line": 188, "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": 190, "end_line": 205, "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": 207, "end_line": 211, "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": 213, "end_line": 216, "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 = [ ] )", "filename": "misc_util.py", "nloc": 9, "complexity": 2, "token_count": 106, "parameters": [ "self", "func", "target", "sources" ], "start_line": 219, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 228, "end_line": 229, "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": 8, "complexity": 2, "token_count": 83, "parameters": [ "self" ], "start_line": 230, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "generate", "long_name": "generate( self )", "filename": "misc_util.py", "nloc": 11, "complexity": 3, "token_count": 107, "parameters": [ "self" ], "start_line": 231, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] )", "filename": "misc_util.py", "nloc": 9, "complexity": 2, "token_count": 106, "parameters": [ "self", "func", "target", "sources" ], "start_line": 219, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , func , target , sources = [ ] , * args )", "filename": "misc_util.py", "nloc": 10, "complexity": 2, "token_count": 114, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 219, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "nloc": 176, "complexity": 61, "token_count": 1431, "diff_parsed": { "added": [ " def __init__(self,func,target,sources=[],*args):", " self.args = args", " if self.func is None:", " # Touch target", " os.utime(self.target,None)", " else:", " self.func(self.target,self.sources,*self.args)" ], "deleted": [ " def __init__(self,func,target,sources=[]):", " self.func(self.target,self.sources)" ] } } ] }, { "hash": "ef5e7ba2d2137f50a9cb74688a21334d46f6bb85", "msg": "Removed .build_py_ignore files: the feature didn't work properly, e.g. building binaries failed. Added sample_site.cfg to data_files. Emptied MANIFEST.in (later we can consider removing it).", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-23T08:57:55+00:00", "author_timezone": 0, "committer_date": "2003-10-23T08:57:55+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c550d135366cfe1f819ffe633f7453de3c50c4ab" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 9, "insertions": 2, "lines": 11, "files": 5, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "MANIFEST.in", "new_path": "MANIFEST.in", "filename": "MANIFEST.in", "extension": "in", "change_type": "MODIFY", "diff": "@@ -1,5 +0,0 @@\n-include scipy_base/*.inc\n-include scipy_distutils/sample_site.cfg\n-include scipy_base/setup_scipy_base.py\n-include scipy_distutils/setup_scipy_distutils.py\n-include scipy_test/setup_scipy_test.py\n", "added_lines": 0, "deleted_lines": 5, "source_code": null, "source_code_before": "include scipy_base/*.inc\ninclude scipy_distutils/sample_site.cfg\ninclude scipy_base/setup_scipy_base.py\ninclude scipy_distutils/setup_scipy_distutils.py\ninclude scipy_test/setup_scipy_test.py\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "include scipy_base/*.inc", "include scipy_distutils/sample_site.cfg", "include scipy_base/setup_scipy_base.py", "include scipy_distutils/setup_scipy_distutils.py", "include scipy_test/setup_scipy_test.py" ] } }, { "old_path": "scipy_base/.build_py_ignore", "new_path": null, "filename": ".build_py_ignore", "extension": "build_py_ignore", "change_type": "DELETE", "diff": "@@ -1 +0,0 @@\n-setup_scipy_base.py\n", "added_lines": 0, "deleted_lines": 1, "source_code": null, "source_code_before": "setup_scipy_base.py\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "setup_scipy_base.py" ] } }, { "old_path": "scipy_distutils/.build_py_ignore", "new_path": null, "filename": ".build_py_ignore", "extension": "build_py_ignore", "change_type": "DELETE", "diff": "@@ -1,2 +0,0 @@\n-setup.py\n-setup_scipy_distutils.py\n\\ No newline at end of file\n", "added_lines": 0, "deleted_lines": 2, "source_code": null, "source_code_before": "setup.py\nsetup_scipy_distutils.py", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "setup.py", "setup_scipy_distutils.py" ] } }, { "old_path": "scipy_distutils/setup_scipy_distutils.py", "new_path": "scipy_distutils/setup_scipy_distutils.py", "filename": "setup_scipy_distutils.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -11,6 +11,8 @@ def configuration(parent_package=''):\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n+\n+ config['data_files'].append((package,[os.path.join(local_path,'sample_site.cfg')]))\n return config\n \n if __name__ == '__main__':\n", "added_lines": 2, "deleted_lines": 0, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n package = 'scipy_distutils'\n local_path = get_path(__name__)\n config = default_config_dict(package,parent_package)\n\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n\n config['data_files'].append((package,[os.path.join(local_path,'sample_site.cfg')]))\n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n for k,v in config.items():\n if not v:\n del config[k]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **config\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n package = 'scipy_distutils'\n local_path = get_path(__name__)\n config = default_config_dict(package,parent_package)\n\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n for k,v in config.items():\n if not v:\n del config[k]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **config\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 9, "complexity": 1, "token_count": 90, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 8, "complexity": 1, "token_count": 66, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 9, "complexity": 1, "token_count": 90, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "nloc": 28, "complexity": 1, "token_count": 176, "diff_parsed": { "added": [ "", " config['data_files'].append((package,[os.path.join(local_path,'sample_site.cfg')]))" ], "deleted": [] } }, { "old_path": "scipy_test/.build_py_ignore", "new_path": null, "filename": ".build_py_ignore", "extension": "build_py_ignore", "change_type": "DELETE", "diff": "@@ -1 +0,0 @@\n-setup_scipy_test.py\n", "added_lines": 0, "deleted_lines": 1, "source_code": null, "source_code_before": "setup_scipy_test.py\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "setup_scipy_test.py" ] } } ] }, { "hash": "4ee67dfe60ec73696b37b1304bfb0f96e0324506", "msg": "Fixed vectorize for scalar inputs. Added new test.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-10-23T18:22:40+00:00", "author_timezone": 0, "committer_date": "2003-10-23T18:22:40+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ef5e7ba2d2137f50a9cb74688a21334d46f6bb85" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 0, "insertions": 26, "lines": 26, "files": 2, "dmm_unit_size": 0.38461538461538464, "dmm_unit_complexity": 0.38461538461538464, "dmm_unit_interfacing": 0.38461538461538464, "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": "@@ -243,6 +243,23 @@ static int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays\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", "added_lines": 17, "deleted_lines": 0, "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_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; 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 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 == 0) { /* turn into 1-d array */", " /* convert to rank-1 array */", " if ((ain->dimensions = (int *)malloc(sizeof(int))) == NULL) {", " PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");", " cleanup_arrays(inputarrays,i);", " return -1;", " }", " if ((ain->strides = (int *)malloc(sizeof(int))) == NULL) {", " PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");", " cleanup_arrays(inputarrays,i);", " free(ain->dimensions);", " return -1;", " }", " ain->nd = 1;", " ain->dimensions[0] = 1;", " ain->strides[0] = ain->descr->elsize;", " }" ], "deleted": [] } }, { "old_path": "scipy_base/tests/test_function_base.py", "new_path": "scipy_base/tests/test_function_base.py", "filename": "test_function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -227,6 +227,15 @@ def addsubtract(a,b):\n f = vectorize(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n+ def check_scalar(self):\n+ def addsubtract(a,b):\n+ if a > b:\n+ return a - b\n+ else:\n+ return a + b\n+ f = vectorize(addsubtract)\n+ r = f([0,3,6,9],5)\n+ assert_array_equal(r,[5,8,1,4])\n \n \n def compare_results(res,desired):\n", "added_lines": 9, "deleted_lines": 0, "source_code": "\nimport unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal, rand\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\nclass test_any(unittest.TestCase):\n def check_basic(self):\n y1 = [0,0,1,0]\n y2 = [0,0,0,0]\n y3 = [1,0,1,0]\n assert(any(y1))\n assert(any(y3))\n assert(not any(y2))\n\n def check_nd(self):\n y1 = [[0,0,0],[0,1,0],[1,1,0]]\n assert(any(y1))\n assert_array_equal(sometrue(y1),[1,1,0])\n assert_array_equal(sometrue(y1,axis=1),[0,1,1])\n \nclass test_all(unittest.TestCase):\n def check_basic(self):\n y1 = [0,1,1,0]\n y2 = [0,0,0,0]\n y3 = [1,1,1,1]\n assert(not all(y1))\n assert(all(y3))\n assert(not all(y2))\n assert(all(~array(y2)))\n\n def check_nd(self):\n y1 = [[0,0,1],[0,1,1],[1,1,1]]\n assert(not all(y1))\n assert_array_equal(alltrue(y1),[0,0,1])\n assert_array_equal(alltrue(y1,axis=1),[0,0,1])\n\nclass test_logspace(unittest.TestCase):\n def check_basic(self):\n y = logspace(0,6)\n assert(len(y)==50)\n y = logspace(0,6,num=100)\n assert(y[-1] == 10**6)\n y = logspace(0,6,endpoint=0)\n assert(y[-1] < 10**6)\n y = logspace(0,6,num=7)\n assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])\n\nclass test_linspace(unittest.TestCase):\n def check_basic(self):\n y = linspace(0,10)\n assert(len(y)==50)\n y = linspace(2,10,num=100)\n assert(y[-1] == 10)\n y = linspace(2,10,endpoint=0)\n assert(y[-1] < 10)\n y,st = linspace(2,10,retstep=1)\n assert_almost_equal(st,8/49.0)\n assert_array_almost_equal(y,mgrid[2:10:50j],13)\n\nclass test_amax(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amax(a),10.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amax(b),[8.0,10.0,9.0])\n assert_equal(amax(b,axis=1),[9.0,10.0,8.0])\n \nclass test_amin(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amin(a),-5.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amin(b),[3.0,3.0,2.0])\n assert_equal(amin(b,axis=1),[3.0,4.0,2.0])\n\nclass test_ptp(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(ptp(a),15.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])\n assert_equal(ptp(b),[6.0,6.0,6.0])\n\nclass test_cumsum(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n assert_array_equal(cumsum(a), array([1,3,13,24,30,35,39],ctype))\n assert_array_equal(cumsum(a2,axis=0), array([[1,2,3,4],[6,8,10,13],\n [16,11,14,18]],ctype))\n assert_array_equal(cumsum(a2,axis=1),\n array([[1,3,6,10],\n [5,11,18,27],\n [10,13,17,22]],ctype))\n\nclass test_prod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, prod, a)\n self.failUnlessRaises(ArithmeticError, prod, a2, 1)\n self.failUnlessRaises(ArithmeticError, prod, a)\n else: \n assert_equal(prod(a),26400)\n assert_array_equal(prod(a2,axis=0), \n array([50,36,84,180],ctype))\n assert_array_equal(prod(a2),array([24, 1890, 600],ctype))\n\nclass test_cumprod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n self.failUnlessRaises(ArithmeticError, cumprod, a2, 1)\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n else: \n assert_array_equal(cumprod(a),\n array([1, 2, 20, 220,\n 1320, 6600, 26400],ctype))\n assert_array_equal(cumprod(a2,axis=0),\n array([[ 1, 2, 3, 4],\n [ 5, 12, 21, 36],\n [50, 36, 84, 180]],ctype))\n assert_array_equal(cumprod(a2),\n array([[ 1, 2, 6, 24],\n [ 5, 30, 210, 1890],\n [10, 30, 120, 600]],ctype))\n\nclass test_diff(unittest.TestCase):\n def check_basic(self):\n x = [1,4,6,7,12]\n out = array([3,2,1,5])\n out2 = array([-1,-1,4])\n out3 = array([0,5])\n assert_array_equal(diff(x),out)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,n=3),out3)\n\n def check_nd(self):\n x = 20*rand(10,20,30)\n out1 = x[:,:,1:] - x[:,:,:-1]\n out2 = out1[:,:,1:] - out1[:,:,:-1]\n out3 = x[1:,:,:] - x[:-1,:,:]\n out4 = out3[1:,:,:] - out3[:-1,:,:]\n assert_array_equal(diff(x),out1)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,axis=0),out3)\n assert_array_equal(diff(x,n=2,axis=0),out4)\n\nclass test_angle(unittest.TestCase):\n def check_basic(self):\n x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]\n y = angle(x)\n yo = [arctan(3.0/1.0),arctan(1.0),0,pi/2,pi,-pi/2.0,\n -arctan(3.0/1.0),pi-arctan(3.0/1.0)]\n z = angle(x,deg=1)\n zo = array(yo)*180/pi\n assert_array_almost_equal(y,yo,11)\n assert_array_almost_equal(z,zo,11)\n\nclass test_trim_zeros(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_basic(self):\n a= array([0,0,1,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,2,3,4]))\n def check_leading_skip(self):\n a= array([0,0,1,0,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,4]))\n def check_trailing_skip(self):\n a= array([0,0,1,0,2,3,0,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,0,4]))\n\n\nclass test_extins(unittest.TestCase):\n def check_basic(self):\n a = array([1,3,2,1,2,3,3])\n b = extract(a>1,a)\n assert_array_equal(b,[3,2,2,3,3])\n def check_insert(self):\n a = array([1,4,3,2,5,8,7])\n insert(a,[0,1,0,1,0,1,0],[2,4,6])\n assert_array_equal(a,[1,2,3,4,5,6,7])\n def check_both(self):\n a = rand(10)\n mask = a > 0.5\n ac = a.copy()\n c = extract(mask, a)\n insert(a,mask,0)\n insert(a,mask,c)\n assert_array_equal(a,ac)\n \nclass test_vectorize(unittest.TestCase):\n def check_simple(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n def check_scalar(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],5)\n assert_array_equal(r,[5,8,1,4])\n \n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\n\n\n#-----------------------------------------------------------------------------\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_linspace,'check_') )\n suites.append( unittest.makeSuite(test_logspace,'check_') )\n suites.append( unittest.makeSuite(test_all,'check_') )\n suites.append( unittest.makeSuite(test_any,'check_') )\n\n suites.append( unittest.makeSuite(test_amax,'check_') )\n suites.append( unittest.makeSuite(test_amin,'check_') )\n suites.append( unittest.makeSuite(test_ptp,'check_') ) \n\n suites.append( unittest.makeSuite(test_cumsum,'check_') )\n suites.append( unittest.makeSuite(test_prod,'check_') )\n suites.append( unittest.makeSuite(test_cumprod,'check_') )\n suites.append( unittest.makeSuite(test_diff,'check_') )\n\n suites.append( unittest.makeSuite(test_angle,'check_') )\n \n suites.append( unittest.makeSuite(test_trim_zeros,'check_') )\n suites.append( unittest.makeSuite(test_vectorize,'check_') )\n suites.append( unittest.makeSuite(test_extins,'check_'))\n\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "source_code_before": "\nimport unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal, rand\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\nclass test_any(unittest.TestCase):\n def check_basic(self):\n y1 = [0,0,1,0]\n y2 = [0,0,0,0]\n y3 = [1,0,1,0]\n assert(any(y1))\n assert(any(y3))\n assert(not any(y2))\n\n def check_nd(self):\n y1 = [[0,0,0],[0,1,0],[1,1,0]]\n assert(any(y1))\n assert_array_equal(sometrue(y1),[1,1,0])\n assert_array_equal(sometrue(y1,axis=1),[0,1,1])\n \nclass test_all(unittest.TestCase):\n def check_basic(self):\n y1 = [0,1,1,0]\n y2 = [0,0,0,0]\n y3 = [1,1,1,1]\n assert(not all(y1))\n assert(all(y3))\n assert(not all(y2))\n assert(all(~array(y2)))\n\n def check_nd(self):\n y1 = [[0,0,1],[0,1,1],[1,1,1]]\n assert(not all(y1))\n assert_array_equal(alltrue(y1),[0,0,1])\n assert_array_equal(alltrue(y1,axis=1),[0,0,1])\n\nclass test_logspace(unittest.TestCase):\n def check_basic(self):\n y = logspace(0,6)\n assert(len(y)==50)\n y = logspace(0,6,num=100)\n assert(y[-1] == 10**6)\n y = logspace(0,6,endpoint=0)\n assert(y[-1] < 10**6)\n y = logspace(0,6,num=7)\n assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])\n\nclass test_linspace(unittest.TestCase):\n def check_basic(self):\n y = linspace(0,10)\n assert(len(y)==50)\n y = linspace(2,10,num=100)\n assert(y[-1] == 10)\n y = linspace(2,10,endpoint=0)\n assert(y[-1] < 10)\n y,st = linspace(2,10,retstep=1)\n assert_almost_equal(st,8/49.0)\n assert_array_almost_equal(y,mgrid[2:10:50j],13)\n\nclass test_amax(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amax(a),10.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amax(b),[8.0,10.0,9.0])\n assert_equal(amax(b,axis=1),[9.0,10.0,8.0])\n \nclass test_amin(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amin(a),-5.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amin(b),[3.0,3.0,2.0])\n assert_equal(amin(b,axis=1),[3.0,4.0,2.0])\n\nclass test_ptp(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(ptp(a),15.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])\n assert_equal(ptp(b),[6.0,6.0,6.0])\n\nclass test_cumsum(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n assert_array_equal(cumsum(a), array([1,3,13,24,30,35,39],ctype))\n assert_array_equal(cumsum(a2,axis=0), array([[1,2,3,4],[6,8,10,13],\n [16,11,14,18]],ctype))\n assert_array_equal(cumsum(a2,axis=1),\n array([[1,3,6,10],\n [5,11,18,27],\n [10,13,17,22]],ctype))\n\nclass test_prod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, prod, a)\n self.failUnlessRaises(ArithmeticError, prod, a2, 1)\n self.failUnlessRaises(ArithmeticError, prod, a)\n else: \n assert_equal(prod(a),26400)\n assert_array_equal(prod(a2,axis=0), \n array([50,36,84,180],ctype))\n assert_array_equal(prod(a2),array([24, 1890, 600],ctype))\n\nclass test_cumprod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n self.failUnlessRaises(ArithmeticError, cumprod, a2, 1)\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n else: \n assert_array_equal(cumprod(a),\n array([1, 2, 20, 220,\n 1320, 6600, 26400],ctype))\n assert_array_equal(cumprod(a2,axis=0),\n array([[ 1, 2, 3, 4],\n [ 5, 12, 21, 36],\n [50, 36, 84, 180]],ctype))\n assert_array_equal(cumprod(a2),\n array([[ 1, 2, 6, 24],\n [ 5, 30, 210, 1890],\n [10, 30, 120, 600]],ctype))\n\nclass test_diff(unittest.TestCase):\n def check_basic(self):\n x = [1,4,6,7,12]\n out = array([3,2,1,5])\n out2 = array([-1,-1,4])\n out3 = array([0,5])\n assert_array_equal(diff(x),out)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,n=3),out3)\n\n def check_nd(self):\n x = 20*rand(10,20,30)\n out1 = x[:,:,1:] - x[:,:,:-1]\n out2 = out1[:,:,1:] - out1[:,:,:-1]\n out3 = x[1:,:,:] - x[:-1,:,:]\n out4 = out3[1:,:,:] - out3[:-1,:,:]\n assert_array_equal(diff(x),out1)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,axis=0),out3)\n assert_array_equal(diff(x,n=2,axis=0),out4)\n\nclass test_angle(unittest.TestCase):\n def check_basic(self):\n x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]\n y = angle(x)\n yo = [arctan(3.0/1.0),arctan(1.0),0,pi/2,pi,-pi/2.0,\n -arctan(3.0/1.0),pi-arctan(3.0/1.0)]\n z = angle(x,deg=1)\n zo = array(yo)*180/pi\n assert_array_almost_equal(y,yo,11)\n assert_array_almost_equal(z,zo,11)\n\nclass test_trim_zeros(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_basic(self):\n a= array([0,0,1,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,2,3,4]))\n def check_leading_skip(self):\n a= array([0,0,1,0,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,4]))\n def check_trailing_skip(self):\n a= array([0,0,1,0,2,3,0,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,0,4]))\n\n\nclass test_extins(unittest.TestCase):\n def check_basic(self):\n a = array([1,3,2,1,2,3,3])\n b = extract(a>1,a)\n assert_array_equal(b,[3,2,2,3,3])\n def check_insert(self):\n a = array([1,4,3,2,5,8,7])\n insert(a,[0,1,0,1,0,1,0],[2,4,6])\n assert_array_equal(a,[1,2,3,4,5,6,7])\n def check_both(self):\n a = rand(10)\n mask = a > 0.5\n ac = a.copy()\n c = extract(mask, a)\n insert(a,mask,0)\n insert(a,mask,c)\n assert_array_equal(a,ac)\n \nclass test_vectorize(unittest.TestCase):\n def check_simple(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n \n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\n\n\n#-----------------------------------------------------------------------------\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_linspace,'check_') )\n suites.append( unittest.makeSuite(test_logspace,'check_') )\n suites.append( unittest.makeSuite(test_all,'check_') )\n suites.append( unittest.makeSuite(test_any,'check_') )\n\n suites.append( unittest.makeSuite(test_amax,'check_') )\n suites.append( unittest.makeSuite(test_amin,'check_') )\n suites.append( unittest.makeSuite(test_ptp,'check_') ) \n\n suites.append( unittest.makeSuite(test_cumsum,'check_') )\n suites.append( unittest.makeSuite(test_prod,'check_') )\n suites.append( unittest.makeSuite(test_cumprod,'check_') )\n suites.append( unittest.makeSuite(test_diff,'check_') )\n\n suites.append( unittest.makeSuite(test_angle,'check_') )\n \n suites.append( unittest.makeSuite(test_trim_zeros,'check_') )\n suites.append( unittest.makeSuite(test_vectorize,'check_') )\n suites.append( unittest.makeSuite(test_extins,'check_'))\n\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 7, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 14, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 22, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 29, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 38, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 45, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 56, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 68, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 123, "parameters": [ "self" ], "start_line": 78, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 88, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 13, "complexity": 2, "token_count": 218, "parameters": [ "self" ], "start_line": 98, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 15, "complexity": 3, "token_count": 192, "parameters": [ "self" ], "start_line": 113, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 22, "complexity": 3, "token_count": 257, "parameters": [ "self" ], "start_line": 130, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 154, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 157, "parameters": [ "self" ], "start_line": 163, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 152, "parameters": [ "self" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 188, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_leading_skip", "long_name": "check_leading_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_trailing_skip", "long_name": "check_trailing_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 196, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 203, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_both", "long_name": "check_both( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 211, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 222, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 221, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_scalar.addsubtract", "long_name": "check_scalar.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_function_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 241, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_function_base.py", "nloc": 20, "complexity": 2, "token_count": 221, "parameters": [ "level" ], "start_line": 250, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 277, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 7, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 14, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 22, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 29, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 38, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 45, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 56, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 68, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 123, "parameters": [ "self" ], "start_line": 78, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 88, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 13, "complexity": 2, "token_count": 218, "parameters": [ "self" ], "start_line": 98, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 15, "complexity": 3, "token_count": 192, "parameters": [ "self" ], "start_line": 113, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 22, "complexity": 3, "token_count": 257, "parameters": [ "self" ], "start_line": 130, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 154, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 157, "parameters": [ "self" ], "start_line": 163, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 152, "parameters": [ "self" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 188, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_leading_skip", "long_name": "check_leading_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_trailing_skip", "long_name": "check_trailing_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 196, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 203, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_both", "long_name": "check_both( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 211, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 222, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 221, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_function_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 232, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_function_base.py", "nloc": 20, "complexity": 2, "token_count": 221, "parameters": [ "level" ], "start_line": 241, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 268, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_scalar.addsubtract", "long_name": "check_scalar.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 } ], "nloc": 251, "complexity": 37, "token_count": 2901, "diff_parsed": { "added": [ " def check_scalar(self):", " def addsubtract(a,b):", " if a > b:", " return a - b", " else:", " return a + b", " f = vectorize(addsubtract)", " r = f([0,3,6,9],5)", " assert_array_equal(r,[5,8,1,4])" ], "deleted": [] } } ] }, { "hash": "7122588549dd1606dce2360ff275c9b13a776e0d", "msg": "Only TestCase instances with test_ suffix are put to test suite list.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-23T21:01:00+00:00", "author_timezone": 0, "committer_date": "2003-10-23T21:01:00+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4ee67dfe60ec73696b37b1304bfb0f96e0324506" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 1, "insertions": 2, "lines": 3, "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": "@@ -175,7 +175,8 @@ def _get_module_tests(self,module,level):\n obj = getattr(test_module, name)\n \n if type(obj) is not type(unittest.TestCase) \\\n- or not issubclass(obj, unittest.TestCase):\n+ or not issubclass(obj, unittest.TestCase) \\\n+ or obj.__name__[:5] != 'test_':\n continue\n \n for mthname in dir(obj):\n", "added_lines": 2, "deleted_lines": 1, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n short_module_name = module.__name__.split('.')[-1]\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 sys.path.insert(0,test_dir)\n try:\n exec 'import test_%s as test_module' % (short_module_name)\n reload(test_module)\n except:\n test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n del sys.path[0]\n\n if test_module is None:\n return []\n\n if not hasattr(test_module,'test_suite_list'):\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\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:5] != 'test_':\n continue\n\n for mthname in dir(obj):\n if mthname[:6] not in ['bench_','check_'] \\\n and mthname[:5] not in ['test_']:\n continue\n mth = getattr(obj, mthname)\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 suite_list.append((obj,mthname))\n return [unittest.makeSuite(*args) for args in suite_list]\n try:\n suite_list = test_module.test_suite_list(level)\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return [unittest.makeSuite(*args) for args in suite_list]\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\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 suites = []\n for name, module in sys.modules.items():\n if package_name!=name[:len(package_name)] \\\n or module is None:\n continue\n suites.extend(self._get_module_tests(module, level))\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\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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n short_module_name = module.__name__.split('.')[-1]\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 sys.path.insert(0,test_dir)\n try:\n exec 'import test_%s as test_module' % (short_module_name)\n reload(test_module)\n except:\n test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n del sys.path[0]\n\n if test_module is None:\n return []\n\n if not hasattr(test_module,'test_suite_list'):\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\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase):\n continue\n\n for mthname in dir(obj):\n if mthname[:6] not in ['bench_','check_'] \\\n and mthname[:5] not in ['test_']:\n continue\n mth = getattr(obj, mthname)\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 suite_list.append((obj,mthname))\n return [unittest.makeSuite(*args) for args in suite_list]\n try:\n suite_list = test_module.test_suite_list(level)\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return [unittest.makeSuite(*args) for args in suite_list]\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\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 suites = []\n for name, module in sys.modules.items():\n if package_name!=name[:len(package_name)] \\\n or module is None:\n continue\n suites.extend(self._get_module_tests(module, level))\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": 17, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "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": 49, "end_line": 50, "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": 61, "end_line": 70, "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": 75, "end_line": 78, "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": 80, "end_line": 82, "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": 87, "end_line": 102, "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": 127, "end_line": 128, "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": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 60, "complexity": 19, "token_count": 402, "parameters": [ "self", "module", "level" ], "start_line": 136, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 204, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 17, "complexity": 5, "token_count": 127, "parameters": [ "self", "level", "verbosity" ], "start_line": 215, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 237, "end_line": 259, "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": 263, "end_line": 269, "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": 271, "end_line": 290, "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": 293, "end_line": 329, "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": 332, "end_line": 366, "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": 369, "end_line": 375, "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": 378, "end_line": 413, "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": 416, "end_line": 443, "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": 446, "end_line": 468, "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": 478, "end_line": 492, "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": 495, "end_line": 509, "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": 512, "end_line": 539, "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": 543, "end_line": 554, "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": 557, "end_line": 571, "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": 574, "end_line": 583, "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": 585, "end_line": 595, "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": 17, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "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": 49, "end_line": 50, "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": 61, "end_line": 70, "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": 75, "end_line": 78, "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": 80, "end_line": 82, "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": 87, "end_line": 102, "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": 127, "end_line": 128, "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": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 59, "complexity": 18, "token_count": 391, "parameters": [ "self", "module", "level" ], "start_line": 136, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 203, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 17, "complexity": 5, "token_count": 127, "parameters": [ "self", "level", "verbosity" ], "start_line": 214, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 236, "end_line": 258, "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": 262, "end_line": 268, "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": 270, "end_line": 289, "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": 292, "end_line": 328, "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": 331, "end_line": 365, "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": 368, "end_line": 374, "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": 377, "end_line": 412, "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": 415, "end_line": 442, "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": 445, "end_line": 467, "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": 477, "end_line": 491, "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": 494, "end_line": 508, "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": 511, "end_line": 538, "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": 542, "end_line": 553, "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": 556, "end_line": 570, "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": 573, "end_line": 582, "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": 584, "end_line": 594, "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": 60, "complexity": 19, "token_count": 402, "parameters": [ "self", "module", "level" ], "start_line": 136, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 } ], "nloc": 413, "complexity": 95, "token_count": 2795, "diff_parsed": { "added": [ " or not issubclass(obj, unittest.TestCase) \\", " or obj.__name__[:5] != 'test_':" ], "deleted": [ " or not issubclass(obj, unittest.TestCase):" ] } } ] }, { "hash": "3ea118c7253d6d9a8e967f8431e73a157cee7c56", "msg": "Introduced parent_path argument to get_path; when not None and the beggining of path matches with parent_path, then return only remaining of the path.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-24T09:54:32+00:00", "author_timezone": 0, "committer_date": "2003-10-24T09:54:32+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "7122588549dd1606dce2360ff275c9b13a776e0d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 3, "insertions": 9, "lines": 12, "files": 2, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.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": "@@ -216,8 +216,9 @@ def get_source_files (self):\n # Gets source files specified and any \"*.h\" header files in\n # those directories. \n for ext in self.libraries:\n- filenames.extend(ext[1]['sources'])\n- filenames.extend(get_headers(get_directories(ext[1]['sources'])))\n+ sources = ext[1]['sources']\n+ filenames.extend(sources)\n+ filenames.extend(get_headers(get_directories(sources)))\n \n return filenames\n \n", "added_lines": 3, "deleted_lines": 2, "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 %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", "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 filenames.extend(ext[1]['sources'])\n filenames.extend(get_headers(get_directories(ext[1]['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": 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 } ], "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": 7, "complexity": 2, "token_count": 56, "parameters": [ "self" ], "start_line": 212, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "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": 224, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "changed_methods": [ { "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 } ], "nloc": 159, "complexity": 40, "token_count": 945, "diff_parsed": { "added": [ " sources = ext[1]['sources']", " filenames.extend(sources)", " filenames.extend(get_headers(get_directories(sources)))" ], "deleted": [ " filenames.extend(ext[1]['sources'])", " filenames.extend(get_headers(get_directories(ext[1]['sources'])))" ] } }, { "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,4 +1,5 @@\n import os,sys,string\n+import types\n \n # Hooks for colored terminal output.\n # See also http://www.livinglogic.de/Python/ansistyle\n@@ -43,7 +44,7 @@ def __init__(self):\n def __getattr__(self,name):\n raise self._info[0],self._info[1]\n \n-def get_path(mod_name):\n+def 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@@ -58,6 +59,10 @@ def get_path(mod_name):\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 \n def add_local_to_path(mod_name):\n", "added_lines": 6, "deleted_lines": 1, "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 def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target):\n caller_dir = os.path.dirname(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", "source_code_before": "import os,sys,string\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):\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 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 def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target):\n caller_dir = os.path.dirname(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", "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": 10, "complexity": 2, "token_count": 114, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 224, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 234, "end_line": 235, "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": 236, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 5, "end_line": 19, "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": 40, "end_line": 42, "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": 43, "end_line": 44, "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 )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 46, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "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": 63, "end_line": 65, "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": 67, "end_line": 70, "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": 72, "end_line": 73, "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": 75, "end_line": 89, "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": 91, "end_line": 101, "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": 103, "end_line": 115, "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": 122, "end_line": 160, "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": 162, "end_line": 169, "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": 171, "end_line": 178, "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": 180, "end_line": 185, "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": 187, "end_line": 188, "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": 190, "end_line": 205, "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": 207, "end_line": 211, "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": 213, "end_line": 216, "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": 10, "complexity": 2, "token_count": 114, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 219, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 229, "end_line": 230, "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": 231, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 } ], "changed_methods": [ { "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": "get_path", "long_name": "get_path( mod_name )", "filename": "misc_util.py", "nloc": 10, "complexity": 3, "token_count": 80, "parameters": [ "mod_name" ], "start_line": 46, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 } ], "nloc": 181, "complexity": 63, "token_count": 1477, "diff_parsed": { "added": [ "import types", "def get_path(mod_name,parent_path=None):", " if parent_path is not None:", " pd = os.path.abspath(parent_path)", " if pd==d[:len(pd)]:", " d = d[len(pd)+1:]" ], "deleted": [ "def get_path(mod_name):" ] } } ] }, { "hash": "ddda876cdca29fdc8cdf96eeedae2d46c85e2b6c", "msg": "scipy_base clean up.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-24T10:38:27+00:00", "author_timezone": 0, "committer_date": "2003-10-24T10:38:27+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3ea118c7253d6d9a8e967f8431e73a157cee7c56" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 311, "insertions": 18, "lines": 329, "files": 15, "dmm_unit_size": 0.3254437869822485, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -38,19 +38,5 @@\n except AttributeError:\n NaN = NAN = nan = fastumath.PINF/fastumath.PINF\n \n-#---- testing ----#\n-\n-def test(level=10):\n- import unittest\n- runner = unittest.TextTestRunner()\n- runner.run(test_suite())\n- return runner\n-\n-def test_suite(level=1):\n- import scipy_test.testing\n- import scipy_base\n- this_mod = scipy_base\n- # testing is the module that actually does all the testing...\n- ignore = ['testing']\n- return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n- level=level)\n+from scipy_test.testing import ScipyTest\n+test = ScipyTest('scipy_base').test\n", "added_lines": 2, "deleted_lines": 16, "source_code": "\nfrom info_scipy_base import __doc__\nfrom scipy_base_version import scipy_base_version as __version__\n\nfrom ppimport import ppimport, ppimport_attr\n\n# The following statement is equivalent to\n#\n# from Matrix import Matrix as mat\n#\n# but avoids expensive LinearAlgebra import when\n# Matrix is not used.\nmat = ppimport_attr(ppimport('Matrix'), 'Matrix')\n\n# Force Numeric to use scipy_base.fastumath instead of Numeric.umath.\nimport fastumath # no need to use scipy_base.fastumath\nimport sys as _sys\n_sys.modules['umath'] = fastumath\n\nimport Numeric\nfrom Numeric import *\n\nimport limits\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\nfrom machar import *\nfrom pexec import *\n\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF/fastumath.PINF\n\nfrom scipy_test.testing import ScipyTest\ntest = ScipyTest('scipy_base').test\n", "source_code_before": "\nfrom info_scipy_base import __doc__\nfrom scipy_base_version import scipy_base_version as __version__\n\nfrom ppimport import ppimport, ppimport_attr\n\n# The following statement is equivalent to\n#\n# from Matrix import Matrix as mat\n#\n# but avoids expensive LinearAlgebra import when\n# Matrix is not used.\nmat = ppimport_attr(ppimport('Matrix'), 'Matrix')\n\n# Force Numeric to use scipy_base.fastumath instead of Numeric.umath.\nimport fastumath # no need to use scipy_base.fastumath\nimport sys as _sys\n_sys.modules['umath'] = fastumath\n\nimport Numeric\nfrom Numeric import *\n\nimport limits\nfrom type_check import *\nfrom index_tricks import *\nfrom function_base import *\nfrom shape_base import *\nfrom matrix_base import *\n\nfrom polynomial import *\nfrom scimath import *\nfrom machar import *\nfrom pexec import *\n\nInf = inf = fastumath.PINF\ntry:\n NAN = NaN = nan = fastumath.NAN\nexcept AttributeError:\n NaN = NAN = nan = fastumath.PINF/fastumath.PINF\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite())\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import scipy_base\n this_mod = scipy_base\n # testing is the module that actually does all the testing...\n ignore = ['testing']\n return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n", "methods": [], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 43, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 49, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 7, "complexity": 1, "token_count": 38, "parameters": [ "level" ], "start_line": 49, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 43, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 26, "complexity": 0, "token_count": 133, "diff_parsed": { "added": [ "from scipy_test.testing import ScipyTest", "test = ScipyTest('scipy_base').test" ], "deleted": [ "#---- testing ----#", "", "def test(level=10):", " import unittest", " runner = unittest.TextTestRunner()", " runner.run(test_suite())", " return runner", "", "def test_suite(level=1):", " import scipy_test.testing", " import scipy_base", " this_mod = scipy_base", " # testing is the module that actually does all the testing...", " ignore = ['testing']", " return scipy_test.testing.harvest_test_suites(this_mod,ignore = ignore,", " level=level)" ] } }, { "old_path": "scipy_base/function_base.py", "new_path": "scipy_base/function_base.py", "filename": "function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -440,17 +440,3 @@ def zerocall(self,args):\n else:\n return (zeros((0,),'d'),)*len(res)\n \n-#-----------------------------------------------------------------------------\n-# Test Routines\n-#-----------------------------------------------------------------------------\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n-if __name__ == '__main__':\n- test()\n", "added_lines": 0, "deleted_lines": 14, "source_code": "\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\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 putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n 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 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 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", "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\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 putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n 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 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 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#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()\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": 146, "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": 40, "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": 40, "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 } ], "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": 146, "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": 40, "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": 40, "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 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 447, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 451, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 451, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 447, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 287, "complexity": 81, "token_count": 2088, "diff_parsed": { "added": [], "deleted": [ "#-----------------------------------------------------------------------------", "# Test Routines", "#-----------------------------------------------------------------------------", "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "", "if __name__ == '__main__':", " test()" ] } }, { "old_path": "scipy_base/index_tricks.py", "new_path": "scipy_base/index_tricks.py", "filename": "index_tricks.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -202,12 +202,3 @@ def __getslice__(self, start, stop):\n \n # End contribution from Konrad.\n \n-#-----------------------------------------------------------------------------\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n", "added_lines": 0, "deleted_lines": 9, "source_code": "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", "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#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , 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 } ], "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 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "index_tricks.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "index_tricks.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 211, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "index_tricks.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 211, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "index_tricks.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 207, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 165, "complexity": 40, "token_count": 986, "diff_parsed": { "added": [], "deleted": [ "#-----------------------------------------------------------------------------", "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)" ] } }, { "old_path": "scipy_base/limits.py", "new_path": "scipy_base/limits.py", "filename": "limits.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -22,14 +22,6 @@\n double_precision = machar_double.precision\n double_resolution = machar_double.resolution\n \n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n if __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n", "added_lines": 0, "deleted_lines": 8, "source_code": "\"\"\" Machine limits for Float32 and Float64.\n\"\"\"\n\n__all__ = ['float_epsilon','float_tiny','float_min',\n 'float_max','float_precision','float_resolution',\n 'double_epsilon','double_tiny','double_min','double_max',\n 'double_precision','double_resolution']\n\nfrom machar import machar_double, machar_single\n\nfloat_epsilon = machar_single.epsilon\nfloat_tiny = machar_single.tiny\nfloat_max = machar_single.huge\nfloat_min = -float_max\nfloat_precision = machar_single.precision\nfloat_resolution = machar_single.resolution\n\ndouble_epsilon = machar_double.epsilon\ndouble_tiny = machar_double.tiny\ndouble_max = machar_double.huge\ndouble_min = -double_max\ndouble_precision = machar_double.precision\ndouble_resolution = machar_double.resolution\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\n", "source_code_before": "\"\"\" Machine limits for Float32 and Float64.\n\"\"\"\n\n__all__ = ['float_epsilon','float_tiny','float_min',\n 'float_max','float_precision','float_resolution',\n 'double_epsilon','double_tiny','double_min','double_max',\n 'double_precision','double_resolution']\n\nfrom machar import machar_double, machar_single\n\nfloat_epsilon = machar_single.epsilon\nfloat_tiny = machar_single.tiny\nfloat_max = machar_single.huge\nfloat_min = -float_max\nfloat_precision = machar_single.precision\nfloat_resolution = machar_single.resolution\n\ndouble_epsilon = machar_double.epsilon\ndouble_tiny = machar_double.tiny\ndouble_max = machar_double.huge\ndouble_min = -double_max\ndouble_precision = machar_double.precision\ndouble_resolution = machar_double.resolution\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\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\n", "methods": [], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "limits.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "limits.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 29, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "limits.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 29, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "limits.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 25, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 24, "complexity": 0, "token_count": 113, "diff_parsed": { "added": [], "deleted": [ "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "" ] } }, { "old_path": "scipy_base/matrix_base.py", "new_path": "scipy_base/matrix_base.py", "filename": "matrix_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -133,14 +133,3 @@ def bmat(obj,gdict=None,ldict=None):\n if isinstance(obj, ArrayType):\n return Matrix.Matrix(obj)\n \n-#-----------------------------------------------------------------------------\n-# Test Routines\n-#-----------------------------------------------------------------------------\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n", "added_lines": 0, "deleted_lines": 11, "source_code": "\"\"\" 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", "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#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "fliplr", "long_name": "fliplr( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "m" ], "start_line": 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 } ], "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 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 144, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 144, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 140, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 91, "complexity": 32, "token_count": 696, "diff_parsed": { "added": [], "deleted": [ "#-----------------------------------------------------------------------------", "# Test Routines", "#-----------------------------------------------------------------------------", "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)" ] } }, { "old_path": "scipy_base/shape_base.py", "new_path": "scipy_base/shape_base.py", "filename": "shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -530,17 +530,3 @@ def dsplit(ary,indices_or_sections):\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n \n-#-----------------------------------------------------------------------------\n-# Test Routines\n-#-----------------------------------------------------------------------------\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n-if __name__ == '__main__':\n- test()\n", "added_lines": 0, "deleted_lines": 14, "source_code": "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", "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#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()\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 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 541, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "shape_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 537, "end_line": 539, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 191, "complexity": 55, "token_count": 1442, "diff_parsed": { "added": [], "deleted": [ "#-----------------------------------------------------------------------------", "# Test Routines", "#-----------------------------------------------------------------------------", "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "", "if __name__ == '__main__':", " test()" ] } }, { "old_path": "scipy_base/tests/test_fastumath.py", "new_path": "scipy_base/tests/test_fastumath.py", "filename": "test_fastumath.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,10 +1,6 @@\n import unittest\n-from scipy_test.testing import assert_array_equal, assert_equal, rand\n-from scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n-\n import sys\n-from scipy_test.testing import set_package_path\n-from scipy_test.testing import ScipyTestCase\n+from scipy_test.testing import *\n set_package_path()\n import scipy_base;reload(scipy_base)\n from scipy_base import fastumath;reload(fastumath)\n@@ -21,24 +17,5 @@ def check_reduce_complex(self):\n x = [1,2]\n assert_equal(fastumath.minimum.reduce([1,2j]),2j)\n \n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_maximum,'check_') )\n- suites.append( unittest.makeSuite(test_minimum,'check_') )\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10,verbosity=2):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner(verbosity=verbosity)\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- if len(sys.argv)>1:\n- level = eval(sys.argv[1])\n- else:\n- level = 1\n- test(level)\n+ ScipyTest('scipy_base.fastumath').run()\n", "added_lines": 2, "deleted_lines": 25, "source_code": "import unittest\nimport sys\nfrom scipy_test.testing import *\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import fastumath;reload(fastumath)\ndel sys.path[0]\n\n\nclass test_maximum(ScipyTestCase):\n def check_reduce_complex(self):\n x = [1,2]\n assert_equal(fastumath.maximum.reduce([1,2j]),1)\n\nclass test_minimum(ScipyTestCase):\n def check_reduce_complex(self):\n x = [1,2]\n assert_equal(fastumath.minimum.reduce([1,2j]),2j)\n\nif __name__ == \"__main__\":\n ScipyTest('scipy_base.fastumath').run()\n", "source_code_before": "import unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal, rand\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n\nimport sys\nfrom scipy_test.testing import set_package_path\nfrom scipy_test.testing import ScipyTestCase\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import fastumath;reload(fastumath)\ndel sys.path[0]\n\n\nclass test_maximum(ScipyTestCase):\n def check_reduce_complex(self):\n x = [1,2]\n assert_equal(fastumath.maximum.reduce([1,2j]),1)\n\nclass test_minimum(ScipyTestCase):\n def check_reduce_complex(self):\n x = [1,2]\n assert_equal(fastumath.minimum.reduce([1,2j]),2j)\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_maximum,'check_') )\n suites.append( unittest.makeSuite(test_minimum,'check_') )\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbosity=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "check_reduce_complex", "long_name": "check_reduce_complex( self )", "filename": "test_fastumath.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 11, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_reduce_complex", "long_name": "check_reduce_complex( self )", "filename": "test_fastumath.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 16, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_reduce_complex", "long_name": "check_reduce_complex( self )", "filename": "test_fastumath.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 15, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_reduce_complex", "long_name": "check_reduce_complex( self )", "filename": "test_fastumath.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 20, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_fastumath.py", "nloc": 7, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 24, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbosity = 2 )", "filename": "test_fastumath.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbosity" ], "start_line": 33, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_fastumath.py", "nloc": 7, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 24, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbosity = 2 )", "filename": "test_fastumath.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbosity" ], "start_line": 33, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 17, "complexity": 2, "token_count": 121, "diff_parsed": { "added": [ "from scipy_test.testing import *", " ScipyTest('scipy_base.fastumath').run()" ], "deleted": [ "from scipy_test.testing import assert_array_equal, assert_equal, rand", "from scipy_test.testing import assert_almost_equal, assert_array_almost_equal", "", "from scipy_test.testing import set_package_path", "from scipy_test.testing import ScipyTestCase", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_maximum,'check_') )", " suites.append( unittest.makeSuite(test_minimum,'check_') )", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbosity=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbosity)", " runner.run(all_tests)", " return runner", "", " if len(sys.argv)>1:", " level = eval(sys.argv[1])", " else:", " level = 1", " test(level)" ] } }, { "old_path": "scipy_base/tests/test_function_base.py", "new_path": "scipy_base/tests/test_function_base.py", "filename": "test_function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,10 +1,8 @@\n \n import unittest\n-from scipy_test.testing import assert_array_equal, assert_equal, rand\n-from scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n \n import sys\n-from scipy_test.testing import set_package_path\n+from scipy_test.testing import *\n set_package_path()\n import scipy_base;reload(scipy_base)\n from scipy_base import *\n@@ -242,47 +240,5 @@ def compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n \n-\n-\n-\n-#-----------------------------------------------------------------------------\n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_linspace,'check_') )\n- suites.append( unittest.makeSuite(test_logspace,'check_') )\n- suites.append( unittest.makeSuite(test_all,'check_') )\n- suites.append( unittest.makeSuite(test_any,'check_') )\n-\n- suites.append( unittest.makeSuite(test_amax,'check_') )\n- suites.append( unittest.makeSuite(test_amin,'check_') )\n- suites.append( unittest.makeSuite(test_ptp,'check_') ) \n-\n- suites.append( unittest.makeSuite(test_cumsum,'check_') )\n- suites.append( unittest.makeSuite(test_prod,'check_') )\n- suites.append( unittest.makeSuite(test_cumprod,'check_') )\n- suites.append( unittest.makeSuite(test_diff,'check_') )\n-\n- suites.append( unittest.makeSuite(test_angle,'check_') )\n- \n- suites.append( unittest.makeSuite(test_trim_zeros,'check_') )\n- suites.append( unittest.makeSuite(test_vectorize,'check_') )\n- suites.append( unittest.makeSuite(test_extins,'check_'))\n-\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- if len(sys.argv)>1:\n- level = eval(sys.argv[1])\n- else:\n- level = 1\n- test(level)\n+ ScipyTest('scipy_base.function_base').run()\n", "added_lines": 2, "deleted_lines": 46, "source_code": "\nimport unittest\n\nimport sys\nfrom scipy_test.testing import *\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\nclass test_any(unittest.TestCase):\n def check_basic(self):\n y1 = [0,0,1,0]\n y2 = [0,0,0,0]\n y3 = [1,0,1,0]\n assert(any(y1))\n assert(any(y3))\n assert(not any(y2))\n\n def check_nd(self):\n y1 = [[0,0,0],[0,1,0],[1,1,0]]\n assert(any(y1))\n assert_array_equal(sometrue(y1),[1,1,0])\n assert_array_equal(sometrue(y1,axis=1),[0,1,1])\n \nclass test_all(unittest.TestCase):\n def check_basic(self):\n y1 = [0,1,1,0]\n y2 = [0,0,0,0]\n y3 = [1,1,1,1]\n assert(not all(y1))\n assert(all(y3))\n assert(not all(y2))\n assert(all(~array(y2)))\n\n def check_nd(self):\n y1 = [[0,0,1],[0,1,1],[1,1,1]]\n assert(not all(y1))\n assert_array_equal(alltrue(y1),[0,0,1])\n assert_array_equal(alltrue(y1,axis=1),[0,0,1])\n\nclass test_logspace(unittest.TestCase):\n def check_basic(self):\n y = logspace(0,6)\n assert(len(y)==50)\n y = logspace(0,6,num=100)\n assert(y[-1] == 10**6)\n y = logspace(0,6,endpoint=0)\n assert(y[-1] < 10**6)\n y = logspace(0,6,num=7)\n assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])\n\nclass test_linspace(unittest.TestCase):\n def check_basic(self):\n y = linspace(0,10)\n assert(len(y)==50)\n y = linspace(2,10,num=100)\n assert(y[-1] == 10)\n y = linspace(2,10,endpoint=0)\n assert(y[-1] < 10)\n y,st = linspace(2,10,retstep=1)\n assert_almost_equal(st,8/49.0)\n assert_array_almost_equal(y,mgrid[2:10:50j],13)\n\nclass test_amax(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amax(a),10.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amax(b),[8.0,10.0,9.0])\n assert_equal(amax(b,axis=1),[9.0,10.0,8.0])\n \nclass test_amin(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amin(a),-5.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amin(b),[3.0,3.0,2.0])\n assert_equal(amin(b,axis=1),[3.0,4.0,2.0])\n\nclass test_ptp(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(ptp(a),15.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])\n assert_equal(ptp(b),[6.0,6.0,6.0])\n\nclass test_cumsum(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n assert_array_equal(cumsum(a), array([1,3,13,24,30,35,39],ctype))\n assert_array_equal(cumsum(a2,axis=0), array([[1,2,3,4],[6,8,10,13],\n [16,11,14,18]],ctype))\n assert_array_equal(cumsum(a2,axis=1),\n array([[1,3,6,10],\n [5,11,18,27],\n [10,13,17,22]],ctype))\n\nclass test_prod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, prod, a)\n self.failUnlessRaises(ArithmeticError, prod, a2, 1)\n self.failUnlessRaises(ArithmeticError, prod, a)\n else: \n assert_equal(prod(a),26400)\n assert_array_equal(prod(a2,axis=0), \n array([50,36,84,180],ctype))\n assert_array_equal(prod(a2),array([24, 1890, 600],ctype))\n\nclass test_cumprod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n self.failUnlessRaises(ArithmeticError, cumprod, a2, 1)\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n else: \n assert_array_equal(cumprod(a),\n array([1, 2, 20, 220,\n 1320, 6600, 26400],ctype))\n assert_array_equal(cumprod(a2,axis=0),\n array([[ 1, 2, 3, 4],\n [ 5, 12, 21, 36],\n [50, 36, 84, 180]],ctype))\n assert_array_equal(cumprod(a2),\n array([[ 1, 2, 6, 24],\n [ 5, 30, 210, 1890],\n [10, 30, 120, 600]],ctype))\n\nclass test_diff(unittest.TestCase):\n def check_basic(self):\n x = [1,4,6,7,12]\n out = array([3,2,1,5])\n out2 = array([-1,-1,4])\n out3 = array([0,5])\n assert_array_equal(diff(x),out)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,n=3),out3)\n\n def check_nd(self):\n x = 20*rand(10,20,30)\n out1 = x[:,:,1:] - x[:,:,:-1]\n out2 = out1[:,:,1:] - out1[:,:,:-1]\n out3 = x[1:,:,:] - x[:-1,:,:]\n out4 = out3[1:,:,:] - out3[:-1,:,:]\n assert_array_equal(diff(x),out1)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,axis=0),out3)\n assert_array_equal(diff(x,n=2,axis=0),out4)\n\nclass test_angle(unittest.TestCase):\n def check_basic(self):\n x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]\n y = angle(x)\n yo = [arctan(3.0/1.0),arctan(1.0),0,pi/2,pi,-pi/2.0,\n -arctan(3.0/1.0),pi-arctan(3.0/1.0)]\n z = angle(x,deg=1)\n zo = array(yo)*180/pi\n assert_array_almost_equal(y,yo,11)\n assert_array_almost_equal(z,zo,11)\n\nclass test_trim_zeros(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_basic(self):\n a= array([0,0,1,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,2,3,4]))\n def check_leading_skip(self):\n a= array([0,0,1,0,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,4]))\n def check_trailing_skip(self):\n a= array([0,0,1,0,2,3,0,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,0,4]))\n\n\nclass test_extins(unittest.TestCase):\n def check_basic(self):\n a = array([1,3,2,1,2,3,3])\n b = extract(a>1,a)\n assert_array_equal(b,[3,2,2,3,3])\n def check_insert(self):\n a = array([1,4,3,2,5,8,7])\n insert(a,[0,1,0,1,0,1,0],[2,4,6])\n assert_array_equal(a,[1,2,3,4,5,6,7])\n def check_both(self):\n a = rand(10)\n mask = a > 0.5\n ac = a.copy()\n c = extract(mask, a)\n insert(a,mask,0)\n insert(a,mask,c)\n assert_array_equal(a,ac)\n \nclass test_vectorize(unittest.TestCase):\n def check_simple(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n def check_scalar(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],5)\n assert_array_equal(r,[5,8,1,4])\n \n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\nif __name__ == \"__main__\":\n ScipyTest('scipy_base.function_base').run()\n", "source_code_before": "\nimport unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal, rand\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\nclass test_any(unittest.TestCase):\n def check_basic(self):\n y1 = [0,0,1,0]\n y2 = [0,0,0,0]\n y3 = [1,0,1,0]\n assert(any(y1))\n assert(any(y3))\n assert(not any(y2))\n\n def check_nd(self):\n y1 = [[0,0,0],[0,1,0],[1,1,0]]\n assert(any(y1))\n assert_array_equal(sometrue(y1),[1,1,0])\n assert_array_equal(sometrue(y1,axis=1),[0,1,1])\n \nclass test_all(unittest.TestCase):\n def check_basic(self):\n y1 = [0,1,1,0]\n y2 = [0,0,0,0]\n y3 = [1,1,1,1]\n assert(not all(y1))\n assert(all(y3))\n assert(not all(y2))\n assert(all(~array(y2)))\n\n def check_nd(self):\n y1 = [[0,0,1],[0,1,1],[1,1,1]]\n assert(not all(y1))\n assert_array_equal(alltrue(y1),[0,0,1])\n assert_array_equal(alltrue(y1,axis=1),[0,0,1])\n\nclass test_logspace(unittest.TestCase):\n def check_basic(self):\n y = logspace(0,6)\n assert(len(y)==50)\n y = logspace(0,6,num=100)\n assert(y[-1] == 10**6)\n y = logspace(0,6,endpoint=0)\n assert(y[-1] < 10**6)\n y = logspace(0,6,num=7)\n assert_array_equal(y,[1,10,100,1e3,1e4,1e5,1e6])\n\nclass test_linspace(unittest.TestCase):\n def check_basic(self):\n y = linspace(0,10)\n assert(len(y)==50)\n y = linspace(2,10,num=100)\n assert(y[-1] == 10)\n y = linspace(2,10,endpoint=0)\n assert(y[-1] < 10)\n y,st = linspace(2,10,retstep=1)\n assert_almost_equal(st,8/49.0)\n assert_array_almost_equal(y,mgrid[2:10:50j],13)\n\nclass test_amax(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amax(a),10.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amax(b),[8.0,10.0,9.0])\n assert_equal(amax(b,axis=1),[9.0,10.0,8.0])\n \nclass test_amin(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(amin(a),-5.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(amin(b),[3.0,3.0,2.0])\n assert_equal(amin(b,axis=1),[3.0,4.0,2.0])\n\nclass test_ptp(unittest.TestCase):\n def check_basic(self):\n a = [3,4,5,10,-3,-5,6.0]\n assert_equal(ptp(a),15.0)\n b = [[3,6.0, 9.0],\n [4,10.0,5.0],\n [8,3.0,2.0]]\n assert_equal(ptp(b,axis=0),[5.0,7.0,7.0])\n assert_equal(ptp(b),[6.0,6.0,6.0])\n\nclass test_cumsum(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n assert_array_equal(cumsum(a), array([1,3,13,24,30,35,39],ctype))\n assert_array_equal(cumsum(a2,axis=0), array([[1,2,3,4],[6,8,10,13],\n [16,11,14,18]],ctype))\n assert_array_equal(cumsum(a2,axis=1),\n array([[1,3,6,10],\n [5,11,18,27],\n [10,13,17,22]],ctype))\n\nclass test_prod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, prod, a)\n self.failUnlessRaises(ArithmeticError, prod, a2, 1)\n self.failUnlessRaises(ArithmeticError, prod, a)\n else: \n assert_equal(prod(a),26400)\n assert_array_equal(prod(a2,axis=0), \n array([50,36,84,180],ctype))\n assert_array_equal(prod(a2),array([24, 1890, 600],ctype))\n\nclass test_cumprod(unittest.TestCase):\n def check_basic(self):\n ba = [1,2,10,11,6,5,4]\n ba2 = [[1,2,3,4],[5,6,7,9],[10,3,4,5]]\n for ctype in ['1','b','s','i','l','f','d','F','D']:\n a = array(ba,ctype)\n a2 = array(ba2,ctype)\n if ctype in ['1', 'b']:\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n self.failUnlessRaises(ArithmeticError, cumprod, a2, 1)\n self.failUnlessRaises(ArithmeticError, cumprod, a)\n else: \n assert_array_equal(cumprod(a),\n array([1, 2, 20, 220,\n 1320, 6600, 26400],ctype))\n assert_array_equal(cumprod(a2,axis=0),\n array([[ 1, 2, 3, 4],\n [ 5, 12, 21, 36],\n [50, 36, 84, 180]],ctype))\n assert_array_equal(cumprod(a2),\n array([[ 1, 2, 6, 24],\n [ 5, 30, 210, 1890],\n [10, 30, 120, 600]],ctype))\n\nclass test_diff(unittest.TestCase):\n def check_basic(self):\n x = [1,4,6,7,12]\n out = array([3,2,1,5])\n out2 = array([-1,-1,4])\n out3 = array([0,5])\n assert_array_equal(diff(x),out)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,n=3),out3)\n\n def check_nd(self):\n x = 20*rand(10,20,30)\n out1 = x[:,:,1:] - x[:,:,:-1]\n out2 = out1[:,:,1:] - out1[:,:,:-1]\n out3 = x[1:,:,:] - x[:-1,:,:]\n out4 = out3[1:,:,:] - out3[:-1,:,:]\n assert_array_equal(diff(x),out1)\n assert_array_equal(diff(x,n=2),out2)\n assert_array_equal(diff(x,axis=0),out3)\n assert_array_equal(diff(x,n=2,axis=0),out4)\n\nclass test_angle(unittest.TestCase):\n def check_basic(self):\n x = [1+3j,sqrt(2)/2.0+1j*sqrt(2)/2,1,1j,-1,-1j,1-3j,-1+3j]\n y = angle(x)\n yo = [arctan(3.0/1.0),arctan(1.0),0,pi/2,pi,-pi/2.0,\n -arctan(3.0/1.0),pi-arctan(3.0/1.0)]\n z = angle(x,deg=1)\n zo = array(yo)*180/pi\n assert_array_almost_equal(y,yo,11)\n assert_array_almost_equal(z,zo,11)\n\nclass test_trim_zeros(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_basic(self):\n a= array([0,0,1,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,2,3,4]))\n def check_leading_skip(self):\n a= array([0,0,1,0,2,3,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,4]))\n def check_trailing_skip(self):\n a= array([0,0,1,0,2,3,0,4,0])\n res = trim_zeros(a)\n assert_array_equal(res,array([1,0,2,3,0,4]))\n\n\nclass test_extins(unittest.TestCase):\n def check_basic(self):\n a = array([1,3,2,1,2,3,3])\n b = extract(a>1,a)\n assert_array_equal(b,[3,2,2,3,3])\n def check_insert(self):\n a = array([1,4,3,2,5,8,7])\n insert(a,[0,1,0,1,0,1,0],[2,4,6])\n assert_array_equal(a,[1,2,3,4,5,6,7])\n def check_both(self):\n a = rand(10)\n mask = a > 0.5\n ac = a.copy()\n c = extract(mask, a)\n insert(a,mask,0)\n insert(a,mask,c)\n assert_array_equal(a,ac)\n \nclass test_vectorize(unittest.TestCase):\n def check_simple(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n def check_scalar(self):\n def addsubtract(a,b):\n if a > b:\n return a - b\n else:\n return a + b\n f = vectorize(addsubtract)\n r = f([0,3,6,9],5)\n assert_array_equal(r,[5,8,1,4])\n \n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\n\n\n#-----------------------------------------------------------------------------\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_linspace,'check_') )\n suites.append( unittest.makeSuite(test_logspace,'check_') )\n suites.append( unittest.makeSuite(test_all,'check_') )\n suites.append( unittest.makeSuite(test_any,'check_') )\n\n suites.append( unittest.makeSuite(test_amax,'check_') )\n suites.append( unittest.makeSuite(test_amin,'check_') )\n suites.append( unittest.makeSuite(test_ptp,'check_') ) \n\n suites.append( unittest.makeSuite(test_cumsum,'check_') )\n suites.append( unittest.makeSuite(test_prod,'check_') )\n suites.append( unittest.makeSuite(test_cumprod,'check_') )\n suites.append( unittest.makeSuite(test_diff,'check_') )\n\n suites.append( unittest.makeSuite(test_angle,'check_') )\n \n suites.append( unittest.makeSuite(test_trim_zeros,'check_') )\n suites.append( unittest.makeSuite(test_vectorize,'check_') )\n suites.append( unittest.makeSuite(test_extins,'check_'))\n\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 7, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 27, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 36, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 43, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 54, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 66, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 123, "parameters": [ "self" ], "start_line": 76, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 86, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 13, "complexity": 2, "token_count": 218, "parameters": [ "self" ], "start_line": 96, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 15, "complexity": 3, "token_count": 192, "parameters": [ "self" ], "start_line": 111, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 22, "complexity": 3, "token_count": 257, "parameters": [ "self" ], "start_line": 128, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 152, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 157, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 152, "parameters": [ "self" ], "start_line": 173, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 186, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_leading_skip", "long_name": "check_leading_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 190, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_trailing_skip", "long_name": "check_trailing_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 194, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 201, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 205, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_both", "long_name": "check_both( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 209, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 220, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 219, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_scalar.addsubtract", "long_name": "check_scalar.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 229, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 228, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_function_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 239, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 7, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 14, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 22, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 29, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 38, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 45, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 56, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 68, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 123, "parameters": [ "self" ], "start_line": 78, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 122, "parameters": [ "self" ], "start_line": 88, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 13, "complexity": 2, "token_count": 218, "parameters": [ "self" ], "start_line": 98, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 15, "complexity": 3, "token_count": 192, "parameters": [ "self" ], "start_line": 113, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 22, "complexity": 3, "token_count": 257, "parameters": [ "self" ], "start_line": 130, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 154, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 157, "parameters": [ "self" ], "start_line": 163, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 9, "complexity": 1, "token_count": 152, "parameters": [ "self" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 188, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_leading_skip", "long_name": "check_leading_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 192, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_trailing_skip", "long_name": "check_trailing_skip( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 196, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 203, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_function_base.py", "nloc": 4, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 207, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_both", "long_name": "check_both( self )", "filename": "test_function_base.py", "nloc": 8, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 211, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 222, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 221, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_scalar.addsubtract", "long_name": "check_scalar.addsubtract( a , b )", "filename": "test_function_base.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 230, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_function_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 241, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_function_base.py", "nloc": 20, "complexity": 2, "token_count": 221, "parameters": [ "level" ], "start_line": 250, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 277, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_function_base.py", "nloc": 20, "complexity": 2, "token_count": 221, "parameters": [ "level" ], "start_line": 250, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 277, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 220, "complexity": 34, "token_count": 2610, "diff_parsed": { "added": [ "from scipy_test.testing import *", " ScipyTest('scipy_base.function_base').run()" ], "deleted": [ "from scipy_test.testing import assert_array_equal, assert_equal, rand", "from scipy_test.testing import assert_almost_equal, assert_array_almost_equal", "from scipy_test.testing import set_package_path", "", "", "", "#-----------------------------------------------------------------------------", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_linspace,'check_') )", " suites.append( unittest.makeSuite(test_logspace,'check_') )", " suites.append( unittest.makeSuite(test_all,'check_') )", " suites.append( unittest.makeSuite(test_any,'check_') )", "", " suites.append( unittest.makeSuite(test_amax,'check_') )", " suites.append( unittest.makeSuite(test_amin,'check_') )", " suites.append( unittest.makeSuite(test_ptp,'check_') )", "", " suites.append( unittest.makeSuite(test_cumsum,'check_') )", " suites.append( unittest.makeSuite(test_prod,'check_') )", " suites.append( unittest.makeSuite(test_cumprod,'check_') )", " suites.append( unittest.makeSuite(test_diff,'check_') )", "", " suites.append( unittest.makeSuite(test_angle,'check_') )", "", " suites.append( unittest.makeSuite(test_trim_zeros,'check_') )", " suites.append( unittest.makeSuite(test_vectorize,'check_') )", " suites.append( unittest.makeSuite(test_extins,'check_'))", "", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", " if len(sys.argv)>1:", " level = eval(sys.argv[1])", " else:", " level = 1", " test(level)" ] } }, { "old_path": "scipy_base/tests/test_index_tricks.py", "new_path": "scipy_base/tests/test_index_tricks.py", "filename": "test_index_tricks.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,9 +1,7 @@\n import unittest\n-from scipy_test.testing import assert_array_equal, assert_equal, rand\n-from scipy_test.testing import assert_almost_equal, assert_array_almost_equal\n \n import sys\n-from scipy_test.testing import set_package_path\n+from scipy_test.testing import *\n set_package_path()\n import scipy_base;reload(scipy_base)\n from scipy_base import *\n@@ -55,26 +53,5 @@ def check_2d(self):\n assert_array_equal(d[:5,:],b)\n assert_array_equal(d[5:,:],c)\n \n-#-----------------------------------------------------------------------------\n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_grid,'check_') )\n- suites.append( unittest.makeSuite(test_concatenator,'check_') )\n- \n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- if len(sys.argv)>1:\n- level = eval(sys.argv[1])\n- else:\n- level = 1\n- test(level)\n+ ScipyTest('scipy_base.index_tricks').run()\n", "added_lines": 2, "deleted_lines": 25, "source_code": "import unittest\n\nimport sys\nfrom scipy_test.testing import *\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\nclass test_grid(unittest.TestCase):\n def check_basic(self):\n a = mgrid[-1:1:10j]\n b = mgrid[-1:1:0.1]\n assert(a.shape == (10,))\n assert(b.shape == (20,))\n assert(a[0] == -1)\n assert_almost_equal(a[-1],1)\n assert(b[0] == -1)\n assert_almost_equal(b[1]-b[0],0.1,11)\n assert_almost_equal(b[-1],b[0]+19*0.1,11)\n assert_almost_equal(a[1]-a[0],2.0/9.0,11)\n\n def check_nd(self):\n c = mgrid[-1:1:10j,-2:2:10j]\n d = mgrid[-1:1:0.1,-2:2:0.2]\n assert(c.shape == (2,10,10))\n assert(d.shape == (2,20,20))\n assert_array_equal(c[0][0,:],-ones(10,'d'))\n assert_array_equal(c[1][:,0],-2*ones(10,'d'))\n assert_array_almost_equal(c[0][-1,:],ones(10,'d'),11)\n assert_array_almost_equal(c[1][:,-1],2*ones(10,'d'),11)\n assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11)\n assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11)\n\nclass test_concatenator(unittest.TestCase):\n def check_1d(self):\n assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6]))\n b = ones(5)\n c = r_[b,0,0,b]\n assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])\n c = c_[b,0,0,b]\n assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])\n\n def check_2d(self):\n b = rand(5,5)\n c = rand(5,5)\n d = c_[b,c] # append columns\n assert(d.shape == (5,10))\n assert_array_equal(d[:,:5],b)\n assert_array_equal(d[:,5:],c)\n d = r_[b,c]\n assert(d.shape == (10,5))\n assert_array_equal(d[:5,:],b)\n assert_array_equal(d[5:,:],c)\n\nif __name__ == \"__main__\":\n ScipyTest('scipy_base.index_tricks').run()\n", "source_code_before": "import unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal, rand\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal\n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\nclass test_grid(unittest.TestCase):\n def check_basic(self):\n a = mgrid[-1:1:10j]\n b = mgrid[-1:1:0.1]\n assert(a.shape == (10,))\n assert(b.shape == (20,))\n assert(a[0] == -1)\n assert_almost_equal(a[-1],1)\n assert(b[0] == -1)\n assert_almost_equal(b[1]-b[0],0.1,11)\n assert_almost_equal(b[-1],b[0]+19*0.1,11)\n assert_almost_equal(a[1]-a[0],2.0/9.0,11)\n\n def check_nd(self):\n c = mgrid[-1:1:10j,-2:2:10j]\n d = mgrid[-1:1:0.1,-2:2:0.2]\n assert(c.shape == (2,10,10))\n assert(d.shape == (2,20,20))\n assert_array_equal(c[0][0,:],-ones(10,'d'))\n assert_array_equal(c[1][:,0],-2*ones(10,'d'))\n assert_array_almost_equal(c[0][-1,:],ones(10,'d'),11)\n assert_array_almost_equal(c[1][:,-1],2*ones(10,'d'),11)\n assert_array_almost_equal(d[0,1,:]-d[0,0,:], 0.1*ones(20,'d'),11)\n assert_array_almost_equal(d[1,:,1]-d[1,:,0], 0.2*ones(20,'d'),11)\n\nclass test_concatenator(unittest.TestCase):\n def check_1d(self):\n assert_array_equal(r_[1,2,3,4,5,6],array([1,2,3,4,5,6]))\n b = ones(5)\n c = r_[b,0,0,b]\n assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])\n c = c_[b,0,0,b]\n assert_array_equal(c,[1,1,1,1,1,0,0,1,1,1,1,1])\n\n def check_2d(self):\n b = rand(5,5)\n c = rand(5,5)\n d = c_[b,c] # append columns\n assert(d.shape == (5,10))\n assert_array_equal(d[:,:5],b)\n assert_array_equal(d[:,5:],c)\n d = r_[b,c]\n assert(d.shape == (10,5))\n assert_array_equal(d[:5,:],b)\n assert_array_equal(d[5:,:],c)\n\n#-----------------------------------------------------------------------------\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_grid,'check_') )\n suites.append( unittest.makeSuite(test_concatenator,'check_') )\n \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_index_tricks.py", "nloc": 11, "complexity": 1, "token_count": 142, "parameters": [ "self" ], "start_line": 11, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_index_tricks.py", "nloc": 11, "complexity": 1, "token_count": 227, "parameters": [ "self" ], "start_line": 23, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_1d", "long_name": "check_1d( self )", "filename": "test_index_tricks.py", "nloc": 7, "complexity": 1, "token_count": 129, "parameters": [ "self" ], "start_line": 36, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2d", "long_name": "check_2d( self )", "filename": "test_index_tricks.py", "nloc": 11, "complexity": 1, "token_count": 109, "parameters": [ "self" ], "start_line": 44, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_index_tricks.py", "nloc": 11, "complexity": 1, "token_count": 142, "parameters": [ "self" ], "start_line": 13, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_nd", "long_name": "check_nd( self )", "filename": "test_index_tricks.py", "nloc": 11, "complexity": 1, "token_count": 227, "parameters": [ "self" ], "start_line": 25, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_1d", "long_name": "check_1d( self )", "filename": "test_index_tricks.py", "nloc": 7, "complexity": 1, "token_count": 129, "parameters": [ "self" ], "start_line": 38, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2d", "long_name": "check_2d( self )", "filename": "test_index_tricks.py", "nloc": 11, "complexity": 1, "token_count": 109, "parameters": [ "self" ], "start_line": 46, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_index_tricks.py", "nloc": 7, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 60, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_index_tricks.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 69, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_index_tricks.py", "nloc": 7, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 60, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_index_tricks.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 69, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 51, "complexity": 4, "token_count": 671, "diff_parsed": { "added": [ "from scipy_test.testing import *", " ScipyTest('scipy_base.index_tricks').run()" ], "deleted": [ "from scipy_test.testing import assert_array_equal, assert_equal, rand", "from scipy_test.testing import assert_almost_equal, assert_array_almost_equal", "from scipy_test.testing import set_package_path", "#-----------------------------------------------------------------------------", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_grid,'check_') )", " suites.append( unittest.makeSuite(test_concatenator,'check_') )", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", " if len(sys.argv)>1:", " level = eval(sys.argv[1])", " else:", " level = 1", " test(level)" ] } }, { "old_path": "scipy_base/tests/test_limits.py", "new_path": "scipy_base/tests/test_limits.py", "filename": "test_limits.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -7,7 +7,7 @@\n import unittest\n \n import sys\n-from scipy_test.testing import set_package_path\n+from scipy_test.testing import *\n set_package_path()\n import scipy_base;reload(scipy_base)\n from scipy_base import *\n@@ -24,28 +24,6 @@ class test_double(unittest.TestCase):\n def check_nothing(self):\n pass\n \n-##################################################\n-\n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_float,'check_') )\n- suites.append( unittest.makeSuite(test_double,'check_') )\n- \n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n-\n if __name__ == \"__main__\":\n- if len(sys.argv)>1:\n- level = eval(sys.argv[1])\n- else:\n- level = 1\n- test(level)\n+ ScipyTest('scipy_base.limits').run()\n+\n", "added_lines": 3, "deleted_lines": 25, "source_code": "\"\"\" Test functions for limits module.\n\n Currently empty -- not sure how to test these values\n and routines as they are machine dependent. Suggestions?\n\"\"\"\n\nimport unittest\n\nimport sys\nfrom scipy_test.testing import *\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\n##################################################\n### Test for sum\n\nclass test_float(unittest.TestCase):\n def check_nothing(self):\n pass\n\nclass test_double(unittest.TestCase):\n def check_nothing(self):\n pass\n\nif __name__ == \"__main__\":\n ScipyTest('scipy_base.limits').run()\n\n", "source_code_before": "\"\"\" Test functions for limits module.\n\n Currently empty -- not sure how to test these values\n and routines as they are machine dependent. Suggestions?\n\"\"\"\n\nimport unittest\n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\n##################################################\n### Test for sum\n\nclass test_float(unittest.TestCase):\n def check_nothing(self):\n pass\n\nclass test_double(unittest.TestCase):\n def check_nothing(self):\n pass\n\n##################################################\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_float,'check_') )\n suites.append( unittest.makeSuite(test_double,'check_') )\n \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "check_nothing", "long_name": "check_nothing( self )", "filename": "test_limits.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_nothing", "long_name": "check_nothing( self )", "filename": "test_limits.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 24, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_nothing", "long_name": "check_nothing( self )", "filename": "test_limits.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 20, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_nothing", "long_name": "check_nothing( self )", "filename": "test_limits.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 24, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_limits.py", "nloc": 7, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 30, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_limits.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_limits.py", "nloc": 7, "complexity": 2, "token_count": 52, "parameters": [ "level" ], "start_line": 30, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_limits.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 39, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 20, "complexity": 2, "token_count": 75, "diff_parsed": { "added": [ "from scipy_test.testing import *", " ScipyTest('scipy_base.limits').run()", "" ], "deleted": [ "from scipy_test.testing import set_package_path", "##################################################", "", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_float,'check_') )", " suites.append( unittest.makeSuite(test_double,'check_') )", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", "", " if len(sys.argv)>1:", " level = eval(sys.argv[1])", " else:", " level = 1", " test(level)" ] } }, { "old_path": "scipy_base/tests/test_matrix_base.py", "new_path": "scipy_base/tests/test_matrix_base.py", "filename": "test_matrix_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,11 +3,9 @@\n \"\"\"\n \n import unittest\n-from scipy_test.testing import assert_array_equal, assert_equal\n-from scipy_test.testing import assert_almost_equal, assert_array_almost_equal\n \n import sys\n-from scipy_test.testing import set_package_path\n+from scipy_test.testing import *\n set_package_path()\n import scipy_base;reload(scipy_base)\n from scipy_base import *\n@@ -141,31 +139,5 @@ def check_basic(self):\n for k in range(0,13,4):\n assert_equal(rot90(a,k=k),b4)\n \n- \n-#-----------------------------------------------------------------------------\n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_eye,'check_') )\n- suites.append( unittest.makeSuite(test_diag,'check_') )\n- suites.append( unittest.makeSuite(test_fliplr,'check_') )\n- suites.append( unittest.makeSuite(test_flipud,'check_') )\n- suites.append( unittest.makeSuite(test_rot90,'check_') )\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n-\n if __name__ == \"__main__\":\n- if len(sys.argv)>1:\n- level = eval(sys.argv[1])\n- else:\n- level = 1\n- test(level)\n+ ScipyTest('scipy_base.matrix_base').run()\n", "added_lines": 2, "deleted_lines": 30, "source_code": "\"\"\" Test functions for basic module\n\n\"\"\"\n\nimport unittest\n\nimport sys\nfrom scipy_test.testing import *\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\n##################################################\n\nval = limits.double_resolution\n\n\ndef get_mat(n):\n data = arange(n)\n data = add.outer(data,data)\n return data\n\nclass test_eye(unittest.TestCase):\n def check_basic(self):\n assert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]]))\n assert_equal(eye(4,typecode='f'),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]],'f'))\n def check_diag(self):\n assert_equal(eye(4,k=1),array([[0,1,0,0],\n [0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,k=-1),array([[0,0,0,0],\n [1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]]))\n def check_2d(self):\n assert_equal(eye(4,3),array([[1,0,0],\n [0,1,0],\n [0,0,1],\n [0,0,0]]))\n assert_equal(eye(3,4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]])) \n def check_diag2d(self):\n assert_equal(eye(3,4,k=2),array([[0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,3,k=-2),array([[0,0,0],\n [0,0,0],\n [1,0,0],\n [0,1,0]]))\n\nclass test_diag(unittest.TestCase):\n def check_vector(self):\n vals = (100*arange(5)).astype('l')\n b = zeros((5,5))\n for k in range(5):\n b[k,k] = vals[k]\n assert_equal(diag(vals),b)\n b = zeros((7,7))\n c = b.copy()\n for k in range(5):\n b[k,k+2] = vals[k]\n c[k+2,k] = vals[k]\n assert_equal(diag(vals,k=2), b)\n assert_equal(diag(vals,k=-2), c)\n\n def check_matrix(self):\n vals = (100*get_mat(5)+1).astype('l')\n b = zeros((5,))\n for k in range(5):\n b[k] = vals[k,k]\n assert_equal(diag(vals),b)\n b = b*0\n for k in range(3):\n b[k] = vals[k,k+2]\n assert_equal(diag(vals,2),b[:3])\n for k in range(3):\n b[k] = vals[k+2,k]\n assert_equal(diag(vals,-2),b[:3])\n\nclass test_fliplr(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, fliplr, ones(4)) \n self.failUnlessRaises(ValueError, fliplr, ones((4,3,2)))\n a = get_mat(4)\n b = a[:,::-1]\n assert_equal(fliplr(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[2,1,0],\n [5,4,3]]\n assert_equal(fliplr(a),b)\n\nclass test_flipud(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, flipud, ones(4))\n self.failUnlessRaises(ValueError, flipud, ones((4,3,2)))\n a = get_mat(4)\n b = a[::-1,:]\n assert_equal(flipud(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[3,4,5],\n [0,1,2]]\n assert_equal(flipud(a),b)\n\nclass test_rot90(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, rot90, ones(4))\n self.failUnlessRaises(ValueError, rot90, ones((4,3,2)))\n\n a = [[0,1,2],\n [3,4,5]]\n b1 = [[2,5],\n [1,4],\n [0,3]]\n b2 = [[5,4,3],\n [2,1,0]]\n b3 = [[3,0],\n [4,1],\n [5,2]]\n b4 = [[0,1,2],\n [3,4,5]]\n\n for k in range(-3,13,4):\n assert_equal(rot90(a,k=k),b1)\n for k in range(-2,13,4):\n assert_equal(rot90(a,k=k),b2)\n for k in range(-1,13,4):\n assert_equal(rot90(a,k=k),b3)\n for k in range(0,13,4):\n assert_equal(rot90(a,k=k),b4)\n\nif __name__ == \"__main__\":\n ScipyTest('scipy_base.matrix_base').run()\n", "source_code_before": "\"\"\" Test functions for basic module\n\n\"\"\"\n\nimport unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal\n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\n##################################################\n\nval = limits.double_resolution\n\n\ndef get_mat(n):\n data = arange(n)\n data = add.outer(data,data)\n return data\n\nclass test_eye(unittest.TestCase):\n def check_basic(self):\n assert_equal(eye(4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]]))\n assert_equal(eye(4,typecode='f'),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0],\n [0,0,0,1]],'f'))\n def check_diag(self):\n assert_equal(eye(4,k=1),array([[0,1,0,0],\n [0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,k=-1),array([[0,0,0,0],\n [1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]]))\n def check_2d(self):\n assert_equal(eye(4,3),array([[1,0,0],\n [0,1,0],\n [0,0,1],\n [0,0,0]]))\n assert_equal(eye(3,4),array([[1,0,0,0],\n [0,1,0,0],\n [0,0,1,0]])) \n def check_diag2d(self):\n assert_equal(eye(3,4,k=2),array([[0,0,1,0],\n [0,0,0,1],\n [0,0,0,0]]))\n assert_equal(eye(4,3,k=-2),array([[0,0,0],\n [0,0,0],\n [1,0,0],\n [0,1,0]]))\n\nclass test_diag(unittest.TestCase):\n def check_vector(self):\n vals = (100*arange(5)).astype('l')\n b = zeros((5,5))\n for k in range(5):\n b[k,k] = vals[k]\n assert_equal(diag(vals),b)\n b = zeros((7,7))\n c = b.copy()\n for k in range(5):\n b[k,k+2] = vals[k]\n c[k+2,k] = vals[k]\n assert_equal(diag(vals,k=2), b)\n assert_equal(diag(vals,k=-2), c)\n\n def check_matrix(self):\n vals = (100*get_mat(5)+1).astype('l')\n b = zeros((5,))\n for k in range(5):\n b[k] = vals[k,k]\n assert_equal(diag(vals),b)\n b = b*0\n for k in range(3):\n b[k] = vals[k,k+2]\n assert_equal(diag(vals,2),b[:3])\n for k in range(3):\n b[k] = vals[k+2,k]\n assert_equal(diag(vals,-2),b[:3])\n\nclass test_fliplr(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, fliplr, ones(4)) \n self.failUnlessRaises(ValueError, fliplr, ones((4,3,2)))\n a = get_mat(4)\n b = a[:,::-1]\n assert_equal(fliplr(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[2,1,0],\n [5,4,3]]\n assert_equal(fliplr(a),b)\n\nclass test_flipud(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, flipud, ones(4))\n self.failUnlessRaises(ValueError, flipud, ones((4,3,2)))\n a = get_mat(4)\n b = a[::-1,:]\n assert_equal(flipud(a),b)\n a = [[0,1,2],\n [3,4,5]]\n b = [[3,4,5],\n [0,1,2]]\n assert_equal(flipud(a),b)\n\nclass test_rot90(unittest.TestCase):\n def check_basic(self):\n self.failUnlessRaises(ValueError, rot90, ones(4))\n self.failUnlessRaises(ValueError, rot90, ones((4,3,2)))\n\n a = [[0,1,2],\n [3,4,5]]\n b1 = [[2,5],\n [1,4],\n [0,3]]\n b2 = [[5,4,3],\n [2,1,0]]\n b3 = [[3,0],\n [4,1],\n [5,2]]\n b4 = [[0,1,2],\n [3,4,5]]\n\n for k in range(-3,13,4):\n assert_equal(rot90(a,k=k),b1)\n for k in range(-2,13,4):\n assert_equal(rot90(a,k=k),b2)\n for k in range(-1,13,4):\n assert_equal(rot90(a,k=k),b3)\n for k in range(0,13,4):\n assert_equal(rot90(a,k=k),b4)\n\n \n#-----------------------------------------------------------------------------\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_eye,'check_') )\n suites.append( unittest.makeSuite(test_diag,'check_') )\n suites.append( unittest.makeSuite(test_fliplr,'check_') )\n suites.append( unittest.makeSuite(test_flipud,'check_') )\n suites.append( unittest.makeSuite(test_rot90,'check_') )\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "get_mat", "long_name": "get_mat( n )", "filename": "test_matrix_base.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "n" ], "start_line": 19, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 9, "complexity": 1, "token_count": 115, "parameters": [ "self" ], "start_line": 25, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_diag", "long_name": "check_diag( self )", "filename": "test_matrix_base.py", "nloc": 9, "complexity": 1, "token_count": 118, "parameters": [ "self" ], "start_line": 34, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_2d", "long_name": "check_2d( self )", "filename": "test_matrix_base.py", "nloc": 8, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 43, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_diag2d", "long_name": "check_diag2d( self )", "filename": "test_matrix_base.py", "nloc": 8, "complexity": 1, "token_count": 104, "parameters": [ "self" ], "start_line": 51, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_vector", "long_name": "check_vector( self )", "filename": "test_matrix_base.py", "nloc": 13, "complexity": 3, "token_count": 136, "parameters": [ "self" ], "start_line": 61, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_matrix", "long_name": "check_matrix( self )", "filename": "test_matrix_base.py", "nloc": 13, "complexity": 4, "token_count": 137, "parameters": [ "self" ], "start_line": 75, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 11, "complexity": 1, "token_count": 109, "parameters": [ "self" ], "start_line": 90, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 11, "complexity": 1, "token_count": 109, "parameters": [ "self" ], "start_line": 103, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 23, "complexity": 5, "token_count": 239, "parameters": [ "self" ], "start_line": 116, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_mat", "long_name": "get_mat( n )", "filename": "test_matrix_base.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "n" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 9, "complexity": 1, "token_count": 115, "parameters": [ "self" ], "start_line": 27, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_diag", "long_name": "check_diag( self )", "filename": "test_matrix_base.py", "nloc": 9, "complexity": 1, "token_count": 118, "parameters": [ "self" ], "start_line": 36, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_2d", "long_name": "check_2d( self )", "filename": "test_matrix_base.py", "nloc": 8, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 45, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_diag2d", "long_name": "check_diag2d( self )", "filename": "test_matrix_base.py", "nloc": 8, "complexity": 1, "token_count": 104, "parameters": [ "self" ], "start_line": 53, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_vector", "long_name": "check_vector( self )", "filename": "test_matrix_base.py", "nloc": 13, "complexity": 3, "token_count": 136, "parameters": [ "self" ], "start_line": 63, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_matrix", "long_name": "check_matrix( self )", "filename": "test_matrix_base.py", "nloc": 13, "complexity": 4, "token_count": 137, "parameters": [ "self" ], "start_line": 77, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 11, "complexity": 1, "token_count": 109, "parameters": [ "self" ], "start_line": 92, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 11, "complexity": 1, "token_count": 109, "parameters": [ "self" ], "start_line": 105, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_matrix_base.py", "nloc": 23, "complexity": 5, "token_count": 239, "parameters": [ "self" ], "start_line": 118, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_matrix_base.py", "nloc": 10, "complexity": 2, "token_count": 91, "parameters": [ "level" ], "start_line": 147, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_matrix_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 159, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_matrix_base.py", "nloc": 10, "complexity": 2, "token_count": 91, "parameters": [ "level" ], "start_line": 147, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_matrix_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 159, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 127, "complexity": 19, "token_count": 1285, "diff_parsed": { "added": [ "from scipy_test.testing import *", " ScipyTest('scipy_base.matrix_base').run()" ], "deleted": [ "from scipy_test.testing import assert_array_equal, assert_equal", "from scipy_test.testing import assert_almost_equal, assert_array_almost_equal", "from scipy_test.testing import set_package_path", "", "#-----------------------------------------------------------------------------", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_eye,'check_') )", " suites.append( unittest.makeSuite(test_diag,'check_') )", " suites.append( unittest.makeSuite(test_fliplr,'check_') )", " suites.append( unittest.makeSuite(test_flipud,'check_') )", " suites.append( unittest.makeSuite(test_rot90,'check_') )", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", "", " if len(sys.argv)>1:", " level = eval(sys.argv[1])", " else:", " level = 1", " test(level)" ] } }, { "old_path": "scipy_base/tests/test_shape_base.py", "new_path": "scipy_base/tests/test_shape_base.py", "filename": "test_shape_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,9 +1,7 @@\n import unittest\n-from scipy_test.testing import assert_array_equal, assert_equal, rand\n-from scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n \n import sys\n-from scipy_test.testing import set_package_path\n+from scipy_test.testing import *\n set_package_path()\n import scipy_base;reload(scipy_base)\n from scipy_base import *\n@@ -355,37 +353,5 @@ def compare_results(res,desired):\n assert_array_equal(res[i],desired[i])\n \n \n-#-----------------------------------------------------------------------------\n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_array_split,'check_') )\n- suites.append( unittest.makeSuite(test_split,'check_') )\n- suites.append( unittest.makeSuite(test_atleast_1d,'check_') )\n- suites.append( unittest.makeSuite(test_atleast_2d,'check_') )\n- suites.append( unittest.makeSuite(test_atleast_3d,'check_') )\n- suites.append( unittest.makeSuite(test_hstack,'check_') )\n- suites.append( unittest.makeSuite(test_vstack,'check_') )\n- suites.append( unittest.makeSuite(test_dstack,'check_') )\n- suites.append( unittest.makeSuite(test_hsplit,'check_') ) \n- suites.append( unittest.makeSuite(test_vsplit,'check_') )\n- suites.append( unittest.makeSuite(test_dsplit,'check_') )\n- suites.append( unittest.makeSuite(test_squeeze,'check_') )\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n-\n if __name__ == \"__main__\":\n- if len(sys.argv)>1:\n- level = eval(sys.argv[1])\n- else:\n- level = 1\n- test(level)\n+ ScipyTest('scipy_base.shape_base').run()\n", "added_lines": 2, "deleted_lines": 36, "source_code": "import unittest\n\nimport sys\nfrom scipy_test.testing import *\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\n\nclass test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(unittest.TestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(unittest.TestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\nif __name__ == \"__main__\":\n ScipyTest('scipy_base.shape_base').run()\n", "source_code_before": "import unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal, rand\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n\n\nclass test_array_split(unittest.TestCase):\n def check_integer_0_split(self):\n a = arange(10)\n try:\n res = array_split(a,0)\n assert(0) # it should have thrown a value error\n except ValueError:\n pass\n def check_integer_split(self):\n a = arange(10)\n res = array_split(a,1)\n desired = [arange(10)]\n compare_results(res,desired)\n\n res = array_split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n res = array_split(a,3)\n desired = [arange(4),arange(4,7),arange(7,10)]\n compare_results(res,desired)\n\n res = array_split(a,4)\n desired = [arange(3),arange(3,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,5)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,10)]\n compare_results(res,desired)\n\n res = array_split(a,6)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,8),arange(8,9),\n arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,7)\n desired = [arange(2),arange(2,4),arange(4,6),arange(6,7),arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,8)\n desired = [arange(2),arange(2,4),arange(4,5),arange(5,6),arange(6,7),\n arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,9)\n desired = [arange(2),arange(2,3),arange(3,4),arange(4,5),arange(5,6),\n arange(6,7), arange(7,8), arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,10)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10)]\n compare_results(res,desired)\n\n res = array_split(a,11)\n desired = [arange(1),arange(1,2),arange(2,3),arange(3,4),\n arange(4,5),arange(5,6), arange(6,7), arange(7,8),\n arange(8,9), arange(9,10),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_rows(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=0)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n def check_integer_split_2D_cols(self):\n a = array([arange(10),arange(10)])\n res = array_split(a,3,axis=-1)\n desired = [array([arange(4),arange(4)]),\n array([arange(4,7),arange(4,7)]),\n array([arange(7,10),arange(7,10)])]\n compare_results(res,desired)\n def check_integer_split_2D_default(self):\n \"\"\" This will fail if we change default axis\n \"\"\"\n a = array([arange(10),arange(10)])\n res = array_split(a,3)\n desired = [array([arange(10)]),array([arange(10)]),array([])]\n compare_results(res,desired)\n #perhaps should check higher dimensions\n\n def check_index_split_simple(self):\n a = arange(10)\n indices = [1,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [arange(0,1),arange(1,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n\n def check_index_split_low_bound(self):\n a = arange(10)\n indices = [0,5,7]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10)]\n compare_results(res,desired)\n def check_index_split_high_bound(self):\n a = arange(10)\n indices = [0,5,7,10,12]\n res = array_split(a,indices,axis=-1)\n desired = [array([]),arange(0,5),arange(5,7),arange(7,10),\n array([]),array([])]\n compare_results(res,desired)\n \nclass test_split(unittest.TestCase):\n \"\"\"* This function is essentially the same as array_split,\n except that it test if splitting will result in an\n equal split. Only test for this case.\n *\"\"\"\n def check_equal_split(self):\n a = arange(10)\n res = split(a,2)\n desired = [arange(5),arange(5,10)]\n compare_results(res,desired)\n\n def check_unequal_split(self):\n a = arange(10) \n try:\n res = split(a,3)\n assert(0) # should raise an error\n except ValueError:\n pass\n\nclass test_atleast_1d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_1d,[a,b])\n desired = [array([1]),array([2])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_1d,[a,b])\n desired = [array([1,2]),array([2,3])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_1d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r1array(self):\n \"\"\" Test to make sure equivalent Travis O's r1array function\n \"\"\"\n assert(atleast_1d(3).shape == (1,))\n assert(atleast_1d(3j).shape == (1,))\n assert(atleast_1d(3L).shape == (1,))\n assert(atleast_1d(3.0).shape == (1,))\n assert(atleast_1d([[2,3],[4,5]]).shape == (2,2))\n\nclass test_atleast_2d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_2d,[a,b])\n desired = [array([[1]]),array([[2]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_2d,[a,b])\n desired = [array([[1,2]]),array([[2,3]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_2d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n def check_r2array(self):\n \"\"\" Test to make sure equivalent Travis O's r2array function\n \"\"\"\n assert(atleast_2d(3).shape == (1,1))\n assert(atleast_2d([3j,1]).shape == (1,2))\n assert(atleast_2d([[[3,1],[4,5]],[[3,5],[1,2]]]).shape == (2,2,2))\n\nclass test_atleast_3d(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1]]]),array([[[2]]])]\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1,2]); b = array([2,3]);\n res=map(atleast_3d,[a,b])\n desired = [array([[[1],[2]]]),array([[[2],[3]]])]\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n res=map(atleast_3d,[a,b])\n desired = [a[:,:,NewAxis],b[:,:,NewAxis]]\n assert_array_equal(res,desired)\n def check_3D_array(self):\n a = array([[1,2],[1,2]]); b = array([[2,3],[2,3]]);\n a = array([a,a]);b = array([b,b]);\n res=map(atleast_3d,[a,b])\n desired = [a,b]\n assert_array_equal(res,desired)\n\nclass test_hstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=hstack([a,b])\n desired = array([1,2])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=hstack([a,b])\n desired = array([[1,1],[2,2]])\n assert_array_equal(res,desired)\n\nclass test_vstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=vstack([a,b])\n desired = array([[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=vstack([a,b])\n desired = array([[1],[2],[1],[2]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=vstack([a,b])\n desired = array([[1,2],[1,2]])\n assert_array_equal(res,desired)\n\nclass test_dstack(unittest.TestCase):\n def check_0D_array(self):\n a = array(1); b = array(2);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_1D_array(self):\n a = array([1]); b = array([2]);\n res=dstack([a,b])\n desired = array([[[1,2]]])\n assert_array_equal(res,desired)\n def check_2D_array(self):\n a = array([[1],[2]]); b = array([[1],[2]]);\n res=dstack([a,b])\n desired = array([[[1,1]],[[2,2,]]])\n assert_array_equal(res,desired)\n def check_2D_array2(self):\n a = array([1,2]); b = array([1,2]);\n res=dstack([a,b])\n desired = array([[[1,1],[2,2]]])\n assert_array_equal(res,desired)\n\n\"\"\" array_split has more comprehensive test of splitting.\n only do simple test on hsplit, vsplit, and dsplit\n\"\"\"\nclass test_hsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_0D_array(self):\n a= array(1)\n try:\n hsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_1D_array(self):\n a= array([1,2,3,4])\n res = hsplit(a,2)\n desired = [array([1,2]),array([3,4])]\n compare_results(res,desired)\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = hsplit(a,2)\n desired = [array([[1,2],[1,2]]),array([[3,4],[3,4]])]\n compare_results(res,desired)\n\nclass test_vsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_1D_array(self):\n a= array([1,2,3,4])\n try:\n vsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n res = vsplit(a,2)\n desired = [array([[1,2,3,4]]),array([[1,2,3,4]])]\n compare_results(res,desired)\n\nclass test_dsplit(unittest.TestCase):\n \"\"\" only testing for integer splits.\n \"\"\"\n def check_2D_array(self):\n a= array([[1,2,3,4],\n [1,2,3,4]])\n try:\n dsplit(a,2)\n assert(0)\n except ValueError:\n pass\n def check_3D_array(self):\n a= array([[[1,2,3,4],\n [1,2,3,4]],\n [[1,2,3,4],\n [1,2,3,4]]])\n res = dsplit(a,2)\n desired = [array([[[1,2],[1,2]],[[1,2],[1,2]]]),\n array([[[3,4],[3,4]],[[3,4],[3,4]]])]\n compare_results(res,desired)\n\nclass test_squeeze(unittest.TestCase):\n def check_basic(self):\n a = rand(20,10,10,1,1)\n b = rand(20,1,10,1,20)\n c = rand(1,1,20,10)\n assert_array_equal(squeeze(a),reshape(a,(20,10,10)))\n assert_array_equal(squeeze(b),reshape(b,(20,10,20)))\n assert_array_equal(squeeze(c),reshape(c,(20,10)))\n \n# Utility\n\ndef compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n\n\n#-----------------------------------------------------------------------------\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_array_split,'check_') )\n suites.append( unittest.makeSuite(test_split,'check_') )\n suites.append( unittest.makeSuite(test_atleast_1d,'check_') )\n suites.append( unittest.makeSuite(test_atleast_2d,'check_') )\n suites.append( unittest.makeSuite(test_atleast_3d,'check_') )\n suites.append( unittest.makeSuite(test_hstack,'check_') )\n suites.append( unittest.makeSuite(test_vstack,'check_') )\n suites.append( unittest.makeSuite(test_dstack,'check_') )\n suites.append( unittest.makeSuite(test_hsplit,'check_') ) \n suites.append( unittest.makeSuite(test_vsplit,'check_') )\n suites.append( unittest.makeSuite(test_dsplit,'check_') )\n suites.append( unittest.makeSuite(test_squeeze,'check_') )\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "check_integer_0_split", "long_name": "check_integer_0_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 12, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split", "long_name": "check_integer_split( self )", "filename": "test_shape_base.py", "nloc": 43, "complexity": 1, "token_count": 637, "parameters": [ "self" ], "start_line": 19, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_rows", "long_name": "check_integer_split_2D_rows( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 72, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_cols", "long_name": "check_integer_split_2D_cols( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 96, "parameters": [ "self" ], "start_line": 77, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_default", "long_name": "check_integer_split_2D_default( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 65, "parameters": [ "self" ], "start_line": 84, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_index_split_simple", "long_name": "check_index_split_simple( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 93, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_low_bound", "long_name": "check_index_split_low_bound( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 100, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_high_bound", "long_name": "check_index_split_high_bound( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 106, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_equal_split", "long_name": "check_equal_split( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 119, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_unequal_split", "long_name": "check_unequal_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 125, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 134, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 139, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 144, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 149, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r1array", "long_name": "check_r1array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 155, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 165, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 170, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 175, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 180, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r2array", "long_name": "check_r2array( self )", "filename": "test_shape_base.py", "nloc": 4, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 186, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 62, "parameters": [ "self" ], "start_line": 194, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 199, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 204, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 209, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 217, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 222, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 227, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 234, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 239, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 244, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 249, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 256, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 261, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 266, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 271, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 283, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 290, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 295, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 305, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 312, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 322, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 9, "complexity": 1, "token_count": 138, "parameters": [ "self" ], "start_line": 330, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 103, "parameters": [ "self" ], "start_line": 341, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 351, "end_line": 353, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "check_integer_0_split", "long_name": "check_integer_0_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 14, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split", "long_name": "check_integer_split( self )", "filename": "test_shape_base.py", "nloc": 43, "complexity": 1, "token_count": 637, "parameters": [ "self" ], "start_line": 21, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_rows", "long_name": "check_integer_split_2D_rows( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 74, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_cols", "long_name": "check_integer_split_2D_cols( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 96, "parameters": [ "self" ], "start_line": 79, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_integer_split_2D_default", "long_name": "check_integer_split_2D_default( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 65, "parameters": [ "self" ], "start_line": 86, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_index_split_simple", "long_name": "check_index_split_simple( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 95, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_low_bound", "long_name": "check_index_split_low_bound( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 102, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_index_split_high_bound", "long_name": "check_index_split_high_bound( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 108, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_equal_split", "long_name": "check_equal_split( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 121, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_unequal_split", "long_name": "check_unequal_split( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 127, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 136, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 141, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 146, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 151, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r1array", "long_name": "check_r1array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 91, "parameters": [ "self" ], "start_line": 157, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 58, "parameters": [ "self" ], "start_line": 167, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 172, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 177, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 182, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_r2array", "long_name": "check_r2array( self )", "filename": "test_shape_base.py", "nloc": 4, "complexity": 1, "token_count": 85, "parameters": [ "self" ], "start_line": 188, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 62, "parameters": [ "self" ], "start_line": 196, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 201, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 206, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 90, "parameters": [ "self" ], "start_line": 211, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 219, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 224, "end_line": 228, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 229, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 236, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 73, "parameters": [ "self" ], "start_line": 246, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 251, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 258, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 263, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 268, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array2", "long_name": "check_2D_array2( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 273, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_0D_array", "long_name": "check_0D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 27, "parameters": [ "self" ], "start_line": 285, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 292, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 297, "end_line": 302, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_1D_array", "long_name": "check_1D_array( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 2, "token_count": 35, "parameters": [ "self" ], "start_line": 307, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 6, "complexity": 1, "token_count": 78, "parameters": [ "self" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_2D_array", "long_name": "check_2D_array( self )", "filename": "test_shape_base.py", "nloc": 8, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 324, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_3D_array", "long_name": "check_3D_array( self )", "filename": "test_shape_base.py", "nloc": 9, "complexity": 1, "token_count": 138, "parameters": [ "self" ], "start_line": 332, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_shape_base.py", "nloc": 7, "complexity": 1, "token_count": 103, "parameters": [ "self" ], "start_line": 343, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "compare_results", "long_name": "compare_results( res , desired )", "filename": "test_shape_base.py", "nloc": 3, "complexity": 2, "token_count": 30, "parameters": [ "res", "desired" ], "start_line": 353, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_shape_base.py", "nloc": 17, "complexity": 2, "token_count": 182, "parameters": [ "level" ], "start_line": 360, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 379, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_shape_base.py", "nloc": 17, "complexity": 2, "token_count": 182, "parameters": [ "level" ], "start_line": 360, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_shape_base.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 379, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 318, "complexity": 50, "token_count": 3661, "diff_parsed": { "added": [ "from scipy_test.testing import *", " ScipyTest('scipy_base.shape_base').run()" ], "deleted": [ "from scipy_test.testing import assert_array_equal, assert_equal, rand", "from scipy_test.testing import assert_almost_equal, assert_array_almost_equal", "from scipy_test.testing import set_package_path", "#-----------------------------------------------------------------------------", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_array_split,'check_') )", " suites.append( unittest.makeSuite(test_split,'check_') )", " suites.append( unittest.makeSuite(test_atleast_1d,'check_') )", " suites.append( unittest.makeSuite(test_atleast_2d,'check_') )", " suites.append( unittest.makeSuite(test_atleast_3d,'check_') )", " suites.append( unittest.makeSuite(test_hstack,'check_') )", " suites.append( unittest.makeSuite(test_vstack,'check_') )", " suites.append( unittest.makeSuite(test_dstack,'check_') )", " suites.append( unittest.makeSuite(test_hsplit,'check_') )", " suites.append( unittest.makeSuite(test_vsplit,'check_') )", " suites.append( unittest.makeSuite(test_dsplit,'check_') )", " suites.append( unittest.makeSuite(test_squeeze,'check_') )", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", "", " if len(sys.argv)>1:", " level = eval(sys.argv[1])", " else:", " level = 1", " test(level)" ] } }, { "old_path": "scipy_base/tests/test_type_check.py", "new_path": "scipy_base/tests/test_type_check.py", "filename": "test_type_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,10 +1,7 @@\n \n import unittest\n-from scipy_test.testing import assert_array_equal, assert_equal, rand\n-from scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n-\n import sys\n-from scipy_test.testing import set_package_path\n+from scipy_test.testing import *\n set_package_path()\n import scipy_base;reload(scipy_base)\n from scipy_base import *\n@@ -185,40 +182,5 @@ def check_basic(self):\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert(isrealobj(b))\n \n-\n-#-----------------------------------------------------------------------------\n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_isscalar,'check_') )\n- suites.append( unittest.makeSuite(test_real_if_close,'check_') )\n- suites.append( unittest.makeSuite(test_real,'check_') )\n- suites.append( unittest.makeSuite(test_imag,'check_') )\n- suites.append( unittest.makeSuite(test_iscomplexobj,'check_') )\n- suites.append( unittest.makeSuite(test_isrealobj,'check_') ) \n- suites.append( unittest.makeSuite(test_iscomplex,'check_') )\n- suites.append( unittest.makeSuite(test_isreal,'check_') ) \n- suites.append( unittest.makeSuite(test_isnan,'check_') )\n- suites.append( unittest.makeSuite(test_isfinite,'check_') )\n- suites.append( unittest.makeSuite(test_isinf,'check_') )\n- suites.append( unittest.makeSuite(test_isposinf,'check_') ) \n- suites.append( unittest.makeSuite(test_isneginf,'check_') )\n- suites.append( unittest.makeSuite(test_nan_to_num,'check_') )\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n-\n if __name__ == \"__main__\":\n- if len(sys.argv)>1:\n- level = eval(sys.argv[1])\n- else:\n- level = 1\n- test(level)\n+ ScipyTest('scipy_base.type_check').run()\n", "added_lines": 2, "deleted_lines": 40, "source_code": "\nimport unittest\nimport sys\nfrom scipy_test.testing import *\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n \nclass test_isscalar(unittest.TestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(unittest.TestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(unittest.TestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert(alltrue(res)) \n def check_posinf(self): \n assert(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert(isnan(1) == 0)\n def check_complex(self):\n assert(isnan(1+1j) == 0)\n def check_complex1(self):\n assert(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert(alltrue(res)) \n def check_posinf(self): \n assert(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert(isfinite(1) == 1)\n def check_complex(self):\n assert(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert(alltrue(res)) \n def check_posinf(self): \n assert(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert(isinf(log(-1.)) == 0)\n # assert(isnan(log(-1.)) == 1)\n\nclass test_isposinf(unittest.TestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(unittest.TestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(unittest.TestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert(vals[0] < -1e10 and isfinite(vals[0]))\n assert(vals[1] == 0)\n assert(vals[2] > 1e10 and isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert(vals.imag > 1e10 and isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert(isfinite(vals)) \n #assert(vals.imag > 1e10 and isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert(vals.real < -1e10 and isfinite(vals)) \n\n\nclass test_real_if_close(unittest.TestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert(isrealobj(b))\n\nif __name__ == \"__main__\":\n ScipyTest('scipy_base.type_check').run()\n", "source_code_before": "\nimport unittest\nfrom scipy_test.testing import assert_array_equal, assert_equal, rand\nfrom scipy_test.testing import assert_almost_equal, assert_array_almost_equal \n\nimport sys\nfrom scipy_test.testing import set_package_path\nset_package_path()\nimport scipy_base;reload(scipy_base)\nfrom scipy_base import *\ndel sys.path[0]\n \nclass test_isscalar(unittest.TestCase):\n def check_basic(self):\n assert(isscalar(3))\n assert(not isscalar([3]))\n assert(not isscalar((3,)))\n assert(isscalar(3j))\n assert(isscalar(10L))\n assert(isscalar(4.0))\n\nclass test_real(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(y,real(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.real,real(y))\n\nclass test_imag(unittest.TestCase):\n def check_real(self):\n y = rand(10,)\n assert_array_equal(0,imag(y))\n\n def check_cmplx(self):\n y = rand(10,)+1j*rand(10,)\n assert_array_equal(y.imag,imag(y))\n\nclass test_iscomplex(unittest.TestCase):\n def check_fail(self):\n z = array([-1,0,1])\n res = iscomplex(z)\n assert(not sometrue(res))\n def check_pass(self):\n z = array([-1j,1,0])\n res = iscomplex(z)\n assert_array_equal(res,[1,0,0])\n\nclass test_isreal(unittest.TestCase):\n def check_pass(self):\n z = array([-1,0,1j])\n res = isreal(z)\n assert_array_equal(res,[1,1,0])\n def check_fail(self):\n z = array([-1j,1,0])\n res = isreal(z)\n assert_array_equal(res,[0,1,1])\n\nclass test_iscomplexobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(not iscomplexobj(z))\n z = array([-1j,0,-1])\n assert(iscomplexobj(z))\n\nclass test_isrealobj(unittest.TestCase):\n def check_basic(self):\n z = array([-1,0,1])\n assert(isrealobj(z))\n z = array([-1j,0,-1])\n assert(not isrealobj(z))\n\nclass test_isnan(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isnan(z) == 0\n assert(alltrue(res)) \n def check_posinf(self): \n assert(isnan(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert(isnan(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert(isnan(array((0.,))/0.) == 1)\n #def check_qnan(self): log(-1) return pi*j now\n # assert(isnan(log(-1.)) == 1)\n def check_integer(self):\n assert(isnan(1) == 0)\n def check_complex(self):\n assert(isnan(1+1j) == 0)\n def check_complex1(self):\n assert(isnan(array(0+0j)/0.) == 1)\n \nclass test_isfinite(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isfinite(z) == 1\n assert(alltrue(res)) \n def check_posinf(self): \n assert(isfinite(array((1.,))/0.) == 0)\n def check_neginf(self): \n assert(isfinite(array((-1.,))/0.) == 0)\n def check_ind(self): \n assert(isfinite(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert(isfinite(log(-1.)) == 0)\n def check_integer(self):\n assert(isfinite(1) == 1)\n def check_complex(self):\n assert(isfinite(1+1j) == 1)\n def check_complex1(self):\n assert(isfinite(array(1+1j)/0.) == 0)\n \nclass test_isinf(unittest.TestCase):\n def check_goodvalues(self):\n z = array((-1.,0.,1.))\n res = isinf(z) == 0\n assert(alltrue(res)) \n def check_posinf(self): \n assert(isinf(array((1.,))/0.) == 1)\n def check_posinf_scalar(self): \n assert(isinf(array(1.,)/0.) == 1)\n def check_neginf(self): \n assert(isinf(array((-1.,))/0.) == 1)\n def check_neginf_scalar(self): \n assert(isinf(array(-1.)/0.) == 1)\n def check_ind(self): \n assert(isinf(array((0.,))/0.) == 0)\n #def check_qnan(self): \n # assert(isinf(log(-1.)) == 0)\n # assert(isnan(log(-1.)) == 1)\n\nclass test_isposinf(unittest.TestCase):\n def check_generic(self):\n vals = isposinf(array((-1.,0,1))/0.)\n assert(vals[0] == 0)\n assert(vals[1] == 0)\n assert(vals[2] == 1)\n\nclass test_isneginf(unittest.TestCase):\n def check_generic(self):\n vals = isneginf(array((-1.,0,1))/0.)\n assert(vals[0] == 1)\n assert(vals[1] == 0)\n assert(vals[2] == 0)\n\nclass test_nan_to_num(unittest.TestCase):\n def check_generic(self):\n vals = nan_to_num(array((-1.,0,1))/0.)\n assert(vals[0] < -1e10 and isfinite(vals[0]))\n assert(vals[1] == 0)\n assert(vals[2] > 1e10 and isfinite(vals[2]))\n def check_integer(self):\n vals = nan_to_num(1)\n assert(vals == 1)\n def check_complex_good(self):\n vals = nan_to_num(1+1j)\n assert(vals == 1+1j)\n def check_complex_bad(self):\n v = 1+1j\n v += array(0+1.j)/0.\n vals = nan_to_num(v)\n # !! This is actually (unexpectedly) zero\n assert(vals.imag > 1e10 and isfinite(vals))\n def check_complex_bad2(self):\n v = 1+1j\n v += array(-1+1.j)/0.\n vals = nan_to_num(v)\n assert(isfinite(vals)) \n #assert(vals.imag > 1e10 and isfinite(vals)) \n # !! This is actually (unexpectedly) positive\n # !! inf. Comment out for now, and see if it\n # !! changes\n #assert(vals.real < -1e10 and isfinite(vals)) \n\n\nclass test_real_if_close(unittest.TestCase):\n def check_basic(self):\n a = rand(10)\n b = real_if_close(a+1e-15j)\n assert(isrealobj(b))\n assert_array_equal(a,b)\n b = real_if_close(a+1e-7j)\n assert(iscomplexobj(b))\n b = real_if_close(a+1e-7j,tol=1e-6)\n assert(isrealobj(b))\n\n\n#-----------------------------------------------------------------------------\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_isscalar,'check_') )\n suites.append( unittest.makeSuite(test_real_if_close,'check_') )\n suites.append( unittest.makeSuite(test_real,'check_') )\n suites.append( unittest.makeSuite(test_imag,'check_') )\n suites.append( unittest.makeSuite(test_iscomplexobj,'check_') )\n suites.append( unittest.makeSuite(test_isrealobj,'check_') ) \n suites.append( unittest.makeSuite(test_iscomplex,'check_') )\n suites.append( unittest.makeSuite(test_isreal,'check_') ) \n suites.append( unittest.makeSuite(test_isnan,'check_') )\n suites.append( unittest.makeSuite(test_isfinite,'check_') )\n suites.append( unittest.makeSuite(test_isinf,'check_') )\n suites.append( unittest.makeSuite(test_isposinf,'check_') ) \n suites.append( unittest.makeSuite(test_isneginf,'check_') )\n suites.append( unittest.makeSuite(test_nan_to_num,'check_') )\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == \"__main__\":\n if len(sys.argv)>1:\n level = eval(sys.argv[1])\n else:\n level = 1\n test(level)\n", "methods": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 11, "end_line": 17, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 20, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 24, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 29, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 33, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 42, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 48, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 52, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 58, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 72, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 76, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "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": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 80, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "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": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 86, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 88, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 98, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 100, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "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": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 106, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "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": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 112, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "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": "check_posinf_scalar", "long_name": "check_posinf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "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": "check_neginf_scalar", "long_name": "check_neginf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 122, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "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": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 131, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 138, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 145, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 150, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_good", "long_name": "check_complex_good( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 153, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_bad", "long_name": "check_complex_bad( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 2, "token_count": 42, "parameters": [ "self" ], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_bad2", "long_name": "check_complex_bad2( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 162, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 9, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 175, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 7, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 14, "end_line": 20, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 23, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 27, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_real", "long_name": "check_real( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 32, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_cmplx", "long_name": "check_cmplx( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 36, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 41, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_pass", "long_name": "check_pass( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 51, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_fail", "long_name": "check_fail( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 55, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 61, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 68, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 75, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "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": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 83, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "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": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 89, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 91, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 95, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 99, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 101, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 103, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 14, "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": "check_complex", "long_name": "check_complex( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 109, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_complex1", "long_name": "check_complex1( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "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": "check_goodvalues", "long_name": "check_goodvalues( self )", "filename": "test_type_check.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 115, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_posinf", "long_name": "check_posinf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 119, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_posinf_scalar", "long_name": "check_posinf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 121, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf", "long_name": "check_neginf( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 123, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_neginf_scalar", "long_name": "check_neginf_scalar( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 125, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_ind", "long_name": "check_ind( self )", "filename": "test_type_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "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": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 134, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 141, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_generic", "long_name": "check_generic( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 148, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_integer", "long_name": "check_integer( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 17, "parameters": [ "self" ], "start_line": 153, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_good", "long_name": "check_complex_good( self )", "filename": "test_type_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "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": "check_complex_bad", "long_name": "check_complex_bad( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 2, "token_count": 42, "parameters": [ "self" ], "start_line": 159, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_bad2", "long_name": "check_complex_bad2( self )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 165, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_type_check.py", "nloc": 9, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 178, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_type_check.py", "nloc": 19, "complexity": 2, "token_count": 208, "parameters": [ "level" ], "start_line": 191, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 212, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_type_check.py", "nloc": 19, "complexity": 2, "token_count": 208, "parameters": [ "level" ], "start_line": 191, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_type_check.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 212, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 154, "complexity": 42, "token_count": 1428, "diff_parsed": { "added": [ "from scipy_test.testing import *", " ScipyTest('scipy_base.type_check').run()" ], "deleted": [ "from scipy_test.testing import assert_array_equal, assert_equal, rand", "from scipy_test.testing import assert_almost_equal, assert_array_almost_equal", "", "from scipy_test.testing import set_package_path", "", "#-----------------------------------------------------------------------------", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_isscalar,'check_') )", " suites.append( unittest.makeSuite(test_real_if_close,'check_') )", " suites.append( unittest.makeSuite(test_real,'check_') )", " suites.append( unittest.makeSuite(test_imag,'check_') )", " suites.append( unittest.makeSuite(test_iscomplexobj,'check_') )", " suites.append( unittest.makeSuite(test_isrealobj,'check_') )", " suites.append( unittest.makeSuite(test_iscomplex,'check_') )", " suites.append( unittest.makeSuite(test_isreal,'check_') )", " suites.append( unittest.makeSuite(test_isnan,'check_') )", " suites.append( unittest.makeSuite(test_isfinite,'check_') )", " suites.append( unittest.makeSuite(test_isinf,'check_') )", " suites.append( unittest.makeSuite(test_isposinf,'check_') )", " suites.append( unittest.makeSuite(test_isneginf,'check_') )", " suites.append( unittest.makeSuite(test_nan_to_num,'check_') )", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", "", " if len(sys.argv)>1:", " level = eval(sys.argv[1])", " else:", " level = 1", " test(level)" ] } }, { "old_path": "scipy_base/type_check.py", "new_path": "scipy_base/type_check.py", "filename": "type_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -195,18 +195,6 @@ def common_type(*arrays):\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n \n-#-----------------------------------------------------------------------------\n-# Test Routines\n-#-----------------------------------------------------------------------------\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n if __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n", "added_lines": 0, "deleted_lines": 12, "source_code": "\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", "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\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\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": "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 } ], "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 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "type_check.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 202, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "type_check.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 206, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "type_check.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 206, "end_line": 208, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "type_check.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 202, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 127, "complexity": 22, "token_count": 1053, "diff_parsed": { "added": [], "deleted": [ "#-----------------------------------------------------------------------------", "# Test Routines", "#-----------------------------------------------------------------------------", "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "" ] } }, { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -191,6 +191,7 @@ def _get_module_tests(self,module,level):\n mthlevel = 1\n if level>=mthlevel:\n suite_list.append((obj,mthname))\n+ print ' Found',len(suite_list),'tests for',module.__name__\n return [unittest.makeSuite(*args) for args in suite_list]\n try:\n suite_list = test_module.test_suite_list(level)\n", "added_lines": 1, "deleted_lines": 0, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n short_module_name = module.__name__.split('.')[-1]\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 sys.path.insert(0,test_dir)\n try:\n exec 'import test_%s as test_module' % (short_module_name)\n reload(test_module)\n except:\n test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n del sys.path[0]\n\n if test_module is None:\n return []\n\n if not hasattr(test_module,'test_suite_list'):\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\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:5] != 'test_':\n continue\n\n for mthname in dir(obj):\n if mthname[:6] not in ['bench_','check_'] \\\n and mthname[:5] not in ['test_']:\n continue\n mth = getattr(obj, mthname)\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 suite_list.append((obj,mthname))\n print ' Found',len(suite_list),'tests for',module.__name__\n return [unittest.makeSuite(*args) for args in suite_list]\n try:\n suite_list = test_module.test_suite_list(level)\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return [unittest.makeSuite(*args) for args in suite_list]\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\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 suites = []\n for name, module in sys.modules.items():\n if package_name!=name[:len(package_name)] \\\n or module is None:\n continue\n suites.extend(self._get_module_tests(module, level))\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\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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n short_module_name = module.__name__.split('.')[-1]\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 sys.path.insert(0,test_dir)\n try:\n exec 'import test_%s as test_module' % (short_module_name)\n reload(test_module)\n except:\n test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n del sys.path[0]\n\n if test_module is None:\n return []\n\n if not hasattr(test_module,'test_suite_list'):\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\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:5] != 'test_':\n continue\n\n for mthname in dir(obj):\n if mthname[:6] not in ['bench_','check_'] \\\n and mthname[:5] not in ['test_']:\n continue\n mth = getattr(obj, mthname)\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 suite_list.append((obj,mthname))\n return [unittest.makeSuite(*args) for args in suite_list]\n try:\n suite_list = test_module.test_suite_list(level)\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return [unittest.makeSuite(*args) for args in suite_list]\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\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 suites = []\n for name, module in sys.modules.items():\n if package_name!=name[:len(package_name)] \\\n or module is None:\n continue\n suites.extend(self._get_module_tests(module, level))\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": 17, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "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": 49, "end_line": 50, "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": 61, "end_line": 70, "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": 75, "end_line": 78, "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": 80, "end_line": 82, "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": 87, "end_line": 102, "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": 127, "end_line": 128, "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": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 61, "complexity": 19, "token_count": 415, "parameters": [ "self", "module", "level" ], "start_line": 136, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 205, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 17, "complexity": 5, "token_count": 127, "parameters": [ "self", "level", "verbosity" ], "start_line": 216, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 238, "end_line": 260, "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": 264, "end_line": 270, "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": 272, "end_line": 291, "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": 294, "end_line": 330, "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": 333, "end_line": 367, "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": 370, "end_line": 376, "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": 379, "end_line": 414, "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": 417, "end_line": 444, "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": 447, "end_line": 469, "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": 479, "end_line": 493, "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": 496, "end_line": 510, "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": 513, "end_line": 540, "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": 544, "end_line": 555, "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": 558, "end_line": 572, "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": 575, "end_line": 584, "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": 586, "end_line": 596, "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": 17, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "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": 49, "end_line": 50, "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": 61, "end_line": 70, "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": 75, "end_line": 78, "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": 80, "end_line": 82, "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": 87, "end_line": 102, "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": 127, "end_line": 128, "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": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 60, "complexity": 19, "token_count": 402, "parameters": [ "self", "module", "level" ], "start_line": 136, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 67, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 204, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 17, "complexity": 5, "token_count": 127, "parameters": [ "self", "level", "verbosity" ], "start_line": 215, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 237, "end_line": 259, "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": 263, "end_line": 269, "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": 271, "end_line": 290, "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": 293, "end_line": 329, "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": 332, "end_line": 366, "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": 369, "end_line": 375, "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": 378, "end_line": 413, "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": 416, "end_line": 443, "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": 446, "end_line": 468, "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": 478, "end_line": 492, "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": 495, "end_line": 509, "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": 512, "end_line": 539, "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": 543, "end_line": 554, "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": 557, "end_line": 571, "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": 574, "end_line": 583, "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": 585, "end_line": 595, "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": 61, "complexity": 19, "token_count": 415, "parameters": [ "self", "module", "level" ], "start_line": 136, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 } ], "nloc": 414, "complexity": 95, "token_count": 2808, "diff_parsed": { "added": [ " print ' Found',len(suite_list),'tests for',module.__name__" ], "deleted": [] } } ] }, { "hash": "0e751aae2dca88ea0c458573cefb2380ec19718a", "msg": "Fixed the case when 3rd party module is imported from a python module or script", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-25T08:43:58+00:00", "author_timezone": 0, "committer_date": "2003-10-25T08:43:58+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ddda876cdca29fdc8cdf96eeedae2d46c85e2b6c" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 3, "insertions": 9, "lines": 12, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_base/ppimport.py", "new_path": "scipy_base/ppimport.py", "filename": "ppimport.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -125,11 +125,12 @@ def ppimport(name):\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n- # python module, not tested\n+ # python module\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n \n+ # module may be imported already\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n@@ -153,10 +154,15 @@ def ppimport(name):\n \n if location is None:\n # name is to be looked in python sys.path.\n- # It is OK if name does not exists. The ImportError is\n- # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n+ # Try once more if module is imported.\n+ # This covers the case when in python module\n+ module = sys.modules.get(fullname)\n+ if module is not None:\n+ return module\n+ # It is OK if name does not exists. The ImportError is\n+ # postponed until trying to use the module.\n \n return _ModuleLoader(fullname,location)\n \n", "added_lines": 9, "deleted_lines": 3, "source_code": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\nimport traceback\n\nclass PPImportError(ImportError):\n pass\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n module = self.__dict__['_ppimport_attr_module']\n if isinstance(module, _ModuleLoader):\n # in case pp module was loaded by other means\n module = sys.modules[module.__name__]\n attr = getattr(module,\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n # module may be imported already\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n fullname = name\n location = 'sys.path'\n # Try once more if module is imported.\n # This covers the case when in python module\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n from scipy_test.testing import ScipyTest\n self.__dict__['test'] = ScipyTest(self).test\n\n # get additional attributes (doc strings, etc)\n # from pre_.py file. XXX: remove this code\n # when new style packaging is implemented.\n filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\n try:\n module = sys.modules[name]\n\texcept KeyError:\n raise ImportError,self.__dict__.get('_ppimport_exc_info')[1]\n if module is not self:\n exc_info = self.__dict__.get('_ppimport_exc_info')\n if exc_info is not None:\n raise PPImportError,\\\n ''.join(traceback.format_exception(*exc_info))\n else:\n assert module is self,`(module, self)`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n try:\n module = __import__(name,None,None,['*'])\n except: # ImportError:\n self.__dict__['_ppimport_exc_info'] = sys.exc_info()\n raise\n\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n\n # XXX: Should we check the existence of module.test? Warn?\n from scipy_test.testing import ScipyTest\n module.test = ScipyTest(module).test\n\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_info'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\nimport traceback\n\nclass PPImportError(ImportError):\n pass\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n module = self.__dict__['_ppimport_attr_module']\n if isinstance(module, _ModuleLoader):\n # in case pp module was loaded by other means\n module = sys.modules[module.__name__]\n attr = getattr(module,\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module, not tested\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n fullname = name\n location = 'sys.path'\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n from scipy_test.testing import ScipyTest\n self.__dict__['test'] = ScipyTest(self).test\n\n # get additional attributes (doc strings, etc)\n # from pre_.py file. XXX: remove this code\n # when new style packaging is implemented.\n filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\n try:\n module = sys.modules[name]\n\texcept KeyError:\n raise ImportError,self.__dict__.get('_ppimport_exc_info')[1]\n if module is not self:\n exc_info = self.__dict__.get('_ppimport_exc_info')\n if exc_info is not None:\n raise PPImportError,\\\n ''.join(traceback.format_exception(*exc_info))\n else:\n assert module is self,`(module, self)`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n try:\n module = __import__(name,None,None,['*'])\n except: # ImportError:\n self.__dict__['_ppimport_exc_info'] = sys.exc_info()\n raise\n\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n\n # XXX: Should we check the existence of module.test? Warn?\n from scipy_test.testing import ScipyTest\n module.test = ScipyTest(module).test\n\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_info'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "methods": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 22, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 39, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 14, "complexity": 4, "token_count": 76, "parameters": [ "self" ], "start_line": 61, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 77, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 101, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 37, "complexity": 8, "token_count": 256, "parameters": [ "name" ], "start_line": 109, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 13, "complexity": 3, "token_count": 119, "parameters": [ "self", "name", "location" ], "start_line": 172, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 25, "complexity": 5, "token_count": 173, "parameters": [ "self" ], "start_line": 195, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 269, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 22, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 39, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 14, "complexity": 4, "token_count": 76, "parameters": [ "self" ], "start_line": 61, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 77, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 101, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 34, "complexity": 7, "token_count": 238, "parameters": [ "name" ], "start_line": 109, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 13, "complexity": 3, "token_count": 119, "parameters": [ "self", "name", "location" ], "start_line": 166, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 25, "complexity": 5, "token_count": 173, "parameters": [ "self" ], "start_line": 189, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 225, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 232, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 239, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 260, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 263, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 278, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 37, "complexity": 8, "token_count": 256, "parameters": [ "name" ], "start_line": 109, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 } ], "nloc": 216, "complexity": 59, "token_count": 1321, "diff_parsed": { "added": [ " # python module", " # module may be imported already", " # Try once more if module is imported.", " # This covers the case when in python module", " module = sys.modules.get(fullname)", " if module is not None:", " return module", " # It is OK if name does not exists. The ImportError is", " # postponed until trying to use the module." ], "deleted": [ " # python module, not tested", " # It is OK if name does not exists. The ImportError is", " # postponed until trying to use the module." ] } } ] }, { "hash": "8574b1581954cb8ba82115c45f500078764cd812", "msg": "Dropped test_suite_list feature, simplified code. Test methods are looked also from base classes. Fixed multiple inclusion of the same test file (e.g. this happend for stats.stats and stats.__init__ modules).", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-25T13:51:45+00:00", "author_timezone": 0, "committer_date": "2003-10-25T13:51:45+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0e751aae2dca88ea0c458573cefb2380ec19718a" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 43, "insertions": 43, "lines": 86, "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": "@@ -133,10 +133,32 @@ def _module_str(self, module):\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 = module.__name__.split('.')[-1]\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@@ -159,48 +181,26 @@ def _get_module_tests(self,module,level):\n if test_module is None:\n return []\n \n- if not hasattr(test_module,'test_suite_list'):\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-\n- if type(obj) is not type(unittest.TestCase) \\\n- or not issubclass(obj, unittest.TestCase) \\\n- or obj.__name__[:5] != 'test_':\n- continue\n-\n- for mthname in dir(obj):\n- if mthname[:6] not in ['bench_','check_'] \\\n- and mthname[:5] not in ['test_']:\n- continue\n- mth = getattr(obj, mthname)\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- suite_list.append((obj,mthname))\n- print ' Found',len(suite_list),'tests for',module.__name__\n- return [unittest.makeSuite(*args) for args in suite_list]\n- try:\n- suite_list = test_module.test_suite_list(level)\n- except:\n- print ' !! FAILURE building tests for ', mstr(module)\n- print ' ',\n- output_exception()\n- return []\n- return [unittest.makeSuite(*args) for args in suite_list]\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", "added_lines": 43, "deleted_lines": 43, "source_code": "\n__all__ = []\n\nimport os,sys,time,glob,string,traceback,unittest\nimport types\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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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 sys.path.insert(0,test_dir)\n try:\n exec 'import test_%s as test_module' % (short_module_name)\n reload(test_module)\n except:\n test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n del sys.path[0]\n\n if test_module is None:\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 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 suites = []\n for name, module in sys.modules.items():\n if package_name!=name[:len(package_name)] \\\n or module is None:\n continue\n suites.extend(self._get_module_tests(module, level))\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\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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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_module_tests(self,module,level):\n mstr = self._module_str\n d,f = os.path.split(module.__file__)\n short_module_name = module.__name__.split('.')[-1]\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 sys.path.insert(0,test_dir)\n try:\n exec 'import test_%s as test_module' % (short_module_name)\n reload(test_module)\n except:\n test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n del sys.path[0]\n\n if test_module is None:\n return []\n\n if not hasattr(test_module,'test_suite_list'):\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\n if type(obj) is not type(unittest.TestCase) \\\n or not issubclass(obj, unittest.TestCase) \\\n or obj.__name__[:5] != 'test_':\n continue\n\n for mthname in dir(obj):\n if mthname[:6] not in ['bench_','check_'] \\\n and mthname[:5] not in ['test_']:\n continue\n mth = getattr(obj, mthname)\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 suite_list.append((obj,mthname))\n print ' Found',len(suite_list),'tests for',module.__name__\n return [unittest.makeSuite(*args) for args in suite_list]\n try:\n suite_list = test_module.test_suite_list(level)\n except:\n print ' !! FAILURE building tests for ', mstr(module)\n print ' ',\n output_exception()\n return []\n return [unittest.makeSuite(*args) for args in suite_list]\n\n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\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 suites = []\n for name, module in sys.modules.items():\n if package_name!=name[:len(package_name)] \\\n or module is None:\n continue\n suites.extend(self._get_module_tests(module, level))\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": 17, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "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": 49, "end_line": 50, "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": 61, "end_line": 70, "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": 75, "end_line": 78, "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": 80, "end_line": 82, "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": 87, "end_line": 102, "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": 127, "end_line": 128, "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": 130, "end_line": 134, "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": 136, "end_line": 156, "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": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "module", "level" ], "start_line": 158, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 205, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 17, "complexity": 5, "token_count": 127, "parameters": [ "self", "level", "verbosity" ], "start_line": 216, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 238, "end_line": 260, "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": 264, "end_line": 270, "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": 272, "end_line": 291, "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": 294, "end_line": 330, "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": 333, "end_line": 367, "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": 370, "end_line": 376, "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": 379, "end_line": 414, "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": 417, "end_line": 444, "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": 447, "end_line": 469, "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": 479, "end_line": 493, "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": 496, "end_line": 510, "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": 513, "end_line": 540, "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": 544, "end_line": 555, "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": 558, "end_line": 572, "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": 575, "end_line": 584, "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": 586, "end_line": 596, "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": 17, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "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": 49, "end_line": 50, "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": 61, "end_line": 70, "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": 75, "end_line": 78, "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": 80, "end_line": 82, "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": 87, "end_line": 102, "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": 127, "end_line": 128, "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": 130, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "_get_module_tests", "long_name": "_get_module_tests( self , module , level )", "filename": "testing.py", "nloc": 61, "complexity": 19, "token_count": 415, "parameters": [ "self", "module", "level" ], "start_line": 136, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 68, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 205, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 17, "complexity": 5, "token_count": 127, "parameters": [ "self", "level", "verbosity" ], "start_line": 216, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 238, "end_line": 260, "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": 264, "end_line": 270, "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": 272, "end_line": 291, "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": 294, "end_line": 330, "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": 333, "end_line": 367, "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": 370, "end_line": 376, "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": 379, "end_line": 414, "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": 417, "end_line": 444, "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": 447, "end_line": 469, "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": 479, "end_line": 493, "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": 496, "end_line": 510, "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": 513, "end_line": 540, "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": 544, "end_line": 555, "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": 558, "end_line": 572, "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": 575, "end_line": 584, "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": 586, "end_line": 596, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "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": 136, "end_line": 156, "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": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "module", "level" ], "start_line": 158, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 } ], "nloc": 415, "complexity": 96, "token_count": 2824, "diff_parsed": { "added": [ " def _get_method_names(self,clsobj,level):", " names = []", " for mthname in dir(clsobj):", " if mthname[:5] not in ['bench','check'] \\", " and mthname[:4] not in ['test']:", " continue", " mth = getattr(clsobj, mthname)", " if type(mth) is not types.MethodType:", " continue", " d = mth.im_func.func_defaults", " if d is not None:", " mthlevel = d[0]", " else:", " mthlevel = 1", " if level>=mthlevel:", " names.append(mthname)", " for base in clsobj.__bases__:", " for n in self._get_method_names(base,level):", " if n not in names:", " names.append(n)", " return names", "", " short_module_name = os.path.splitext(os.path.basename(f))[0]", " if hasattr(test_module,'test_suite'):", " # Using old styled test suite", " try:", " total_suite = test_module.test_suite(level)", " return total_suite._tests", " except:", " print ' !! FAILURE building tests for ', mstr(module)", " print ' ',", " output_exception()", " return []", " suite_list = []", " for name in dir(test_module):", " obj = getattr(test_module, name)", " if type(obj) is not type(unittest.TestCase) \\", " or not issubclass(obj, unittest.TestCase) \\", " or obj.__name__[:4] != 'test':", " continue", " suite_list.extend(map(obj,self._get_method_names(obj,level)))", " print ' Found',len(suite_list),'tests for',module.__name__", " return suite_list" ], "deleted": [ " short_module_name = module.__name__.split('.')[-1]", " if not hasattr(test_module,'test_suite_list'):", " if hasattr(test_module,'test_suite'):", " # Using old styled test suite", " try:", " total_suite = test_module.test_suite(level)", " return total_suite._tests", " except:", " print ' !! FAILURE building tests for ', mstr(module)", " print ' ',", " output_exception()", " return []", " suite_list = []", " for name in dir(test_module):", " obj = getattr(test_module, name)", "", " if type(obj) is not type(unittest.TestCase) \\", " or not issubclass(obj, unittest.TestCase) \\", " or obj.__name__[:5] != 'test_':", " continue", "", " for mthname in dir(obj):", " if mthname[:6] not in ['bench_','check_'] \\", " and mthname[:5] not in ['test_']:", " continue", " mth = getattr(obj, mthname)", " d = mth.im_func.func_defaults", " if d is not None:", " mthlevel = d[0]", " else:", " mthlevel = 1", " if level>=mthlevel:", " suite_list.append((obj,mthname))", " print ' Found',len(suite_list),'tests for',module.__name__", " return [unittest.makeSuite(*args) for args in suite_list]", " try:", " suite_list = test_module.test_suite_list(level)", " except:", " print ' !! FAILURE building tests for ', mstr(module)", " print ' ',", " output_exception()", " return []", " return [unittest.makeSuite(*args) for args in suite_list]" ] } } ] }, { "hash": "f2d6d44964f0de30448a9706b3072b05f53c5557", "msg": "Made code explicit.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-25T13:53:44+00:00", "author_timezone": 0, "committer_date": "2003-10-25T13:53:44+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "8574b1581954cb8ba82115c45f500078764cd812" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 2, "insertions": 4, "lines": 6, "files": 1, "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": "@@ -28,8 +28,10 @@ def configuration(parent_package=''):\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_BE',1))\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", "added_lines": 4, "deleted_lines": 2, "source_code": "#!/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=''):\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__)\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=''):\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__)\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_BE',1))\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 = '' )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 4, "token_count": 219, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 26, "complexity": 4, "token_count": 207, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 4, "token_count": 219, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 } ], "nloc": 47, "complexity": 4, "token_count": 309, "diff_parsed": { "added": [ " if sys.byteorder == \"little\":", " define_macros.append(('USE_MCONF_LITE_LE',None))", " else:", " define_macros.append(('USE_MCONF_LITE_BE',None))" ], "deleted": [ " if sys.byteorder != \"little\":", " define_macros.append(('USE_MCONF_LITE_BE',1))" ] } } ] }, { "hash": "89425047b98a96aca9fe46e935a186acbeebcdb7", "msg": "Avoid looking for tests from test_* modules", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-25T15:14:27+00:00", "author_timezone": 0, "committer_date": "2003-10-25T15:14:27+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "f2d6d44964f0de30448a9706b3072b05f53c5557" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 9, "insertions": 11, "lines": 20, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_test/testing.py", "new_path": "scipy_test/testing.py", "filename": "testing.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,6 +3,7 @@\n \n import os,sys,time,glob,string,traceback,unittest\n import types\n+import imp\n \n try:\n # These are used by Numeric tests.\n@@ -167,18 +168,16 @@ def _get_module_tests(self,module,level):\n % (os.path.basename(test_file), mstr(module))\n return []\n \n- sys.path.insert(0,test_dir)\n try:\n- exec 'import test_%s as test_module' % (short_module_name)\n- reload(test_module)\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- test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n- del sys.path[0]\n-\n- if test_module is None:\n return []\n \n if hasattr(test_module,'test_suite'):\n@@ -224,12 +223,15 @@ def test(self,level=1,verbosity=1):\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+ 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", "added_lines": 11, "deleted_lines": 9, "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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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 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\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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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 sys.path.insert(0,test_dir)\n try:\n exec 'import test_%s as test_module' % (short_module_name)\n reload(test_module)\n except:\n test_module = None\n print ' !! FAILURE importing tests for ', mstr(module)\n print ' ',\n output_exception()\n del sys.path[0]\n\n if test_module is None:\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 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 suites = []\n for name, module in sys.modules.items():\n if package_name!=name[:len(package_name)] \\\n or module is None:\n continue\n suites.extend(self._get_module_tests(module, level))\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": "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": 50, "end_line": 51, "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": 62, "end_line": 71, "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": 76, "end_line": 79, "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": 81, "end_line": 83, "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": 88, "end_line": 103, "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": 128, "end_line": 129, "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": 131, "end_line": 135, "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": 137, "end_line": 157, "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": 159, "end_line": 202, "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": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 204, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 215, "end_line": 238, "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": 240, "end_line": 262, "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": 266, "end_line": 272, "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": 274, "end_line": 293, "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": 296, "end_line": 332, "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": 335, "end_line": 369, "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": 372, "end_line": 378, "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": 381, "end_line": 416, "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": 419, "end_line": 446, "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": 449, "end_line": 471, "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": 481, "end_line": 495, "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": 498, "end_line": 512, "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": 515, "end_line": 542, "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": 546, "end_line": 557, "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": 560, "end_line": 574, "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": 577, "end_line": 586, "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": 588, "end_line": 598, "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": 17, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "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": 49, "end_line": 50, "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": 61, "end_line": 70, "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": 75, "end_line": 78, "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": 80, "end_line": 82, "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": 87, "end_line": 102, "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": 127, "end_line": 128, "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": 130, "end_line": 134, "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": 136, "end_line": 156, "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": 41, "complexity": 10, "token_count": 294, "parameters": [ "self", "module", "level" ], "start_line": 158, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 205, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( self , level = 1 , verbosity = 1 )", "filename": "testing.py", "nloc": 17, "complexity": 5, "token_count": 127, "parameters": [ "self", "level", "verbosity" ], "start_line": 216, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "testing.py", "nloc": 20, "complexity": 2, "token_count": 104, "parameters": [ "self" ], "start_line": 238, "end_line": 260, "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": 264, "end_line": 270, "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": 272, "end_line": 291, "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": 294, "end_line": 330, "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": 333, "end_line": 367, "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": 370, "end_line": 376, "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": 379, "end_line": 414, "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": 417, "end_line": 444, "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": 447, "end_line": 469, "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": 479, "end_line": 493, "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": 496, "end_line": 510, "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": 513, "end_line": 540, "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": 544, "end_line": 555, "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": 558, "end_line": 572, "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": 575, "end_line": 584, "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": 586, "end_line": 596, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "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": 215, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "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": 159, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 } ], "nloc": 416, "complexity": 96, "token_count": 2852, "diff_parsed": { "added": [ "import imp", " f = open(test_file,'r')", " test_module = imp.load_module(\\", " module.__name__+'.test_'+short_module_name,", " f, test_file,('.py', 'r', 1))", " f.close()", "", " if package_name != name[:len(package_name)] \\", " or module is None \\", " or os.path.basename(os.path.dirname(module.__file__))=='tests':", "" ], "deleted": [ " sys.path.insert(0,test_dir)", " exec 'import test_%s as test_module' % (short_module_name)", " reload(test_module)", " test_module = None", " del sys.path[0]", "", " if test_module is None:", " if package_name!=name[:len(package_name)] \\", " or module is None:" ] } } ] }, { "hash": "a58d97f9ccdc76ccba3a214eebe9ea1492acf7fb", "msg": "Doc updates.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-25T17:21:47+00:00", "author_timezone": 0, "committer_date": "2003-10-25T17:21:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "89425047b98a96aca9fe46e935a186acbeebcdb7" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 12, "insertions": 15, "lines": 27, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 0.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": "@@ -116,14 +116,15 @@ class ScipyTest:\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 function\n- test_suite_list(level=1) that returns a list of 2-tuples\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.\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@@ -203,14 +204,16 @@ def _get_module_tests(self,module,level):\n \n def _touch_ppimported(self, module):\n from scipy_base.ppimport import _ModuleLoader\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+ 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", "added_lines": 15, "deleted_lines": 12, "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 del sys.path[0]\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\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", "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 del sys.path[0]\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\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 function\n test_suite_list(level=1) that returns a list of 2-tuples\n (,).\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.\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 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": "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": 50, "end_line": 51, "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": 62, "end_line": 71, "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": 76, "end_line": 79, "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": 81, "end_line": 83, "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": 88, "end_line": 103, "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": 129, "end_line": 130, "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": 132, "end_line": 136, "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": 138, "end_line": 158, "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": 160, "end_line": 203, "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": 205, "end_line": 216, "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": 218, "end_line": 241, "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": 243, "end_line": 265, "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": 269, "end_line": 275, "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": 277, "end_line": 296, "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": 299, "end_line": 335, "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": 338, "end_line": 372, "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": 375, "end_line": 381, "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": 384, "end_line": 419, "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": 422, "end_line": 449, "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": 452, "end_line": 474, "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": 484, "end_line": 498, "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": 501, "end_line": 515, "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": 518, "end_line": 545, "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": 549, "end_line": 560, "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": 563, "end_line": 577, "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": 580, "end_line": 589, "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": 591, "end_line": 601, "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": "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": 50, "end_line": 51, "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": 62, "end_line": 71, "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": 76, "end_line": 79, "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": 81, "end_line": 83, "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": 88, "end_line": 103, "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": 128, "end_line": 129, "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": 131, "end_line": 135, "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": 137, "end_line": 157, "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": 159, "end_line": 202, "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": 10, "complexity": 6, "token_count": 70, "parameters": [ "self", "module" ], "start_line": 204, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 215, "end_line": 238, "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": 240, "end_line": 262, "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": 266, "end_line": 272, "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": 274, "end_line": 293, "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": 296, "end_line": 332, "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": 335, "end_line": 369, "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": 372, "end_line": 378, "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": 381, "end_line": 416, "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": 419, "end_line": 446, "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": 449, "end_line": 471, "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": 481, "end_line": 495, "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": 498, "end_line": 512, "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": 515, "end_line": 542, "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": 546, "end_line": 557, "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": 560, "end_line": 574, "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": 577, "end_line": 586, "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": 588, "end_line": 598, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "_touch_ppimported", "long_name": "_touch_ppimported( self , module )", "filename": "testing.py", "nloc": 11, "complexity": 7, "token_count": 98, "parameters": [ "self", "module" ], "start_line": 205, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 } ], "nloc": 418, "complexity": 97, "token_count": 2880, "diff_parsed": { "added": [ " test_*.py files are supposed to define a classes, derived", " from ScipyTestCase or unittest.TestCase, with methods having", " names starting with test or bench or check.", " Also old styled test_suite(level=1) hooks are supported but", " soon to be removed.", " if os.path.isdir(os.path.join(os.path.dirname(module.__file__),'tests')):", " # only touching those modules that have tests/ directory", " try: module._pliuh_plauh", " except AttributeError: pass", " for name in dir(module):", " obj = getattr(module,name)", " if isinstance(obj,_ModuleLoader) \\", " and not hasattr(obj,'_ppimport_module') \\", " and not hasattr(obj,'_ppimport_exc_info'):", " self._touch_ppimported(obj)" ], "deleted": [ " test_*.py files are supposed to define a function", " test_suite_list(level=1) that returns a list of 2-tuples", " (,).", " Also old styled test_suite(level=1) hooks are supported.", " try: module._pliuh_plauh", " except AttributeError: pass", " for name in dir(module):", " obj = getattr(module,name)", " if isinstance(obj,_ModuleLoader) \\", " and not hasattr(obj,'_ppimport_module') \\", " and not hasattr(obj,'_ppimport_exc_info'):", " self._touch_ppimported(obj)" ] } } ] }, { "hash": "95a197aa0e55b64e984f36482dfc106161ab8a1d", "msg": "Introduced restor_path,set_local_path functions.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-25T21:28:12+00:00", "author_timezone": 0, "committer_date": "2003-10-25T21:28:12+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "a58d97f9ccdc76ccba3a214eebe9ea1492acf7fb" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 1, "insertions": 22, "lines": 23, "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": "@@ -31,7 +31,7 @@ def set_package_path(level=1):\n is prepended to sys.path.\n The caller is responsible for removing this path by using\n \n- del sys.path[0]\n+ restore_path()\n \"\"\"\n from distutils.util import get_platform\n from scipy_distutils.misc_util import get_frame\n@@ -46,6 +46,27 @@ def set_package_path(level=1):\n d1 = os.path.dirname(d)\n sys.path.insert(0,d1)\n \n+__all__.append('set_local_path')\n+def 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')\n+def restore_path():\n+ del sys.path[0]\n+\n if sys.platform[:5]=='linux':\n def jiffies(_proc_pid_stat = '/proc/%s/stat'%(os.getpid()),\n _load_time=time.time()):\n", "added_lines": 22, "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 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", "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 del sys.path[0]\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\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": 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 } ], "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": "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": 50, "end_line": 51, "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": 62, "end_line": 71, "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": 76, "end_line": 79, "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": 81, "end_line": 83, "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": 88, "end_line": 103, "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": 129, "end_line": 130, "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": 132, "end_line": 136, "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": 138, "end_line": 158, "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": 160, "end_line": 203, "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": 205, "end_line": 216, "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": 218, "end_line": 241, "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": 243, "end_line": 265, "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": 269, "end_line": 275, "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": 277, "end_line": 296, "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": 299, "end_line": 335, "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": 338, "end_line": 372, "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": 375, "end_line": 381, "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": 384, "end_line": 419, "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": 422, "end_line": 449, "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": 452, "end_line": 474, "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": 484, "end_line": 498, "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": 501, "end_line": 515, "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": 518, "end_line": 545, "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": 549, "end_line": 560, "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": 563, "end_line": 577, "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": 580, "end_line": 589, "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": 591, "end_line": 601, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "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": "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 } ], "nloc": 431, "complexity": 100, "token_count": 2980, "diff_parsed": { "added": [ " restore_path()", "__all__.append('set_local_path')", "def set_local_path(level=1):", " \"\"\" Prepend local directory to sys.path.", "", " The caller is responsible for removing this path by using", "", " restore_path()", " \"\"\"", " from scipy_distutils.misc_util import get_frame", " f = get_frame(level)", " if f.f_locals['__name__']=='__main__':", " testfile = sys.argv[0]", " else:", " testfile = f.f_locals['__file__']", " local_path = os.path.dirname(os.path.abspath(testfile))", " sys.path.insert(0,local_path)", "", "__all__.append('restore_path')", "def restore_path():", " del sys.path[0]", "" ], "deleted": [ " del sys.path[0]" ] } } ] }, { "hash": "4d1b593225e392072f5f684f9fcac8c9efb21916", "msg": "New import hooks are applied to weave. Clean up.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-25T21:51:46+00:00", "author_timezone": 0, "committer_date": "2003-10-25T21:51:46+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "95a197aa0e55b64e984f36482dfc106161ab8a1d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 728, "insertions": 312, "lines": 1040, "files": 30, "dmm_unit_size": 0.21846153846153846, "dmm_unit_complexity": 0.13538461538461538, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "weave/__init__.py", "new_path": "weave/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,7 +2,7 @@\n # weave - C/C++ integration\n #\n \n-from pre___init__ import __doc__\n+from info_weave import __doc__\n from weave_version import weave_version as __version__\n \n try:\n@@ -18,15 +18,5 @@\n except:\n pass\n \n-#---- testing ----#\n-\n-def test(level=10):\n- import unittest\n- runner = unittest.TextTestRunner()\n- runner.run(test_suite(level))\n- return runner\n-\n-def test_suite(level=1):\n- import scipy_test.testing\n- import weave\n- return scipy_test.testing.harvest_test_suites(weave,level=level)\n+from scipy_test.testing import ScipyTest\n+test = ScipyTest('weave').test\n", "added_lines": 3, "deleted_lines": 13, "source_code": "#\n# weave - C/C++ integration\n#\n\nfrom info_weave import __doc__\nfrom weave_version import weave_version as __version__\n\ntry:\n from blitz_tools import blitz\nexcept ImportError:\n pass # Numeric wasn't available \n \nfrom inline_tools import inline\nimport ext_tools\nfrom ext_tools import ext_module, ext_function\ntry:\n from accelerate_tools import accelerate\nexcept:\n pass\n\nfrom scipy_test.testing import ScipyTest\ntest = ScipyTest('weave').test\n", "source_code_before": "#\n# weave - C/C++ integration\n#\n\nfrom pre___init__ import __doc__\nfrom weave_version import weave_version as __version__\n\ntry:\n from blitz_tools import blitz\nexcept ImportError:\n pass # Numeric wasn't available \n \nfrom inline_tools import inline\nimport ext_tools\nfrom ext_tools import ext_module, ext_function\ntry:\n from accelerate_tools import accelerate\nexcept:\n pass\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite(level))\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import weave\n return scipy_test.testing.harvest_test_suites(weave,level=level)\n", "methods": [], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "level" ], "start_line": 23, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 29, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 29, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "level" ], "start_line": 23, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 15, "complexity": 0, "token_count": 55, "diff_parsed": { "added": [ "from info_weave import __doc__", "from scipy_test.testing import ScipyTest", "test = ScipyTest('weave').test" ], "deleted": [ "from pre___init__ import __doc__", "#---- testing ----#", "", "def test(level=10):", " import unittest", " runner = unittest.TextTestRunner()", " runner.run(test_suite(level))", " return runner", "", "def test_suite(level=1):", " import scipy_test.testing", " import weave", " return scipy_test.testing.harvest_test_suites(weave,level=level)" ] } }, { "old_path": "weave/ast_tools.py", "new_path": "weave/ast_tools.py", "filename": "ast_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -197,14 +197,7 @@ def tuples_to_lists(ast_tuple):\n new_list.append(tuples_to_lists(item))\n return new_list\n \n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n \n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n- \n \"\"\"\n A little tree I built to help me understand the parse trees.\n -----------303------------------------------\n", "added_lines": 0, "deleted_lines": 7, "source_code": "import token\nimport symbol\nimport parser\n\nfrom types import ListType, TupleType, StringType, IntType\n\ndef int_to_symbol(i):\n \"\"\" Convert numeric symbol or token to a desriptive name.\n \"\"\"\n try: \n return symbol.sym_name[i]\n except KeyError:\n return token.tok_name[i]\n \ndef translate_symbols(ast_tuple):\n \"\"\" Translate numeric grammar symbols in an ast_tuple descriptive names.\n \n This simply traverses the tree converting any integer value to values\n found in symbol.sym_name or token.tok_name.\n \"\"\" \n new_list = []\n for item in ast_tuple:\n if type(item) == IntType:\n new_list.append(int_to_symbol(item))\n elif type(item) in [TupleType,ListType]:\n new_list.append(translate_symbols(item))\n else: \n new_list.append(item)\n if type(ast_tuple) == TupleType:\n return tuple(new_list)\n else:\n return new_list\n\ndef ast_to_string(ast_seq):\n \"\"\"* Traverse an ast tree sequence, printing out all leaf nodes.\n \n This effectively rebuilds the expression the tree was built\n from. I guess its probably missing whitespace. How bout\n indent stuff and new lines? Haven't checked this since we're\n currently only dealing with simple expressions.\n *\"\"\"\n output = ''\n for item in ast_seq:\n if type(item) is StringType:\n output = output + item\n elif type(item) in [ListType,TupleType]:\n output = output + ast_to_string(item)\n return output \n\ndef build_atom(expr_string):\n \"\"\" Build an ast for an atom from the given expr string.\n \n If expr_string is not a string, it is converted to a string\n before parsing to an ast_tuple.\n \"\"\"\n # the [1][1] indexing below starts atoms at the third level\n # deep in the resulting parse tree. parser.expr will return\n # a tree rooted with eval_input -> test_list -> test ...\n # I'm considering test to be the root of atom symbols.\n # It might be a better idea to move down a little in the\n # parse tree. Any benefits? Right now, this works fine. \n if type(expr_string) == StringType:\n ast = parser.expr(expr_string).totuple()[1][1]\n else:\n ast = parser.expr(`expr_string`).totuple()[1][1]\n return ast\n\ndef atom_tuple(expr_string):\n return build_atom(expr_string)\n\ndef atom_list(expr_string):\n return tuples_to_lists(build_atom(expr_string))\n \ndef find_first_pattern(ast_tuple,pattern_list):\n \"\"\"* Find the first occurence of a pattern one of a list of patterns \n in ast_tuple.\n \n Used for testing at the moment.\n \n ast_tuple -- tuple or list created by ast.totuple() or ast.tolist().\n pattern_list -- A single pattern or list of patterns to search\n for in the ast_tuple. If a single pattern is \n used, it MUST BE A IN A TUPLE format.\n Returns:\n found -- true/false indicating whether pattern was found\n data -- dictionary of data from first matching pattern in tree.\n (see match function by Jeremy Hylton). \n *\"\"\"\n found,data = 0,{}\n \n # convert to a list if input wasn't a list\n if type(pattern_list) != ListType:\n pattern_list = [pattern_list]\n\n # look for any of the patterns in a list of patterns \n for pattern in pattern_list:\n found,data = match(pattern,ast_tuple)\n if found: \n break \n \n # if we didn't find the pattern, search sub-trees of the parse tree\n if not found: \n for item in ast_tuple: \n if type(item) in [TupleType,ListType]:\n # only search sub items if they are a list or tuple.\n found, data = find_first_pattern(item,pattern_list)\n if found: \n break \n return found,data\n\nname_pattern = (token.NAME, ['var'])\n\ndef remove_duplicates(lst):\n output = []\n for item in lst:\n if item not in output:\n output.append(item)\n return output\n\nreserved_names = ['sin']\n\ndef remove_reserved_names(lst):\n \"\"\" These are functions names -- don't create variables for them\n There is a more reobust approach, but this ought to work pretty\n well.\n \"\"\"\n output = []\n for item in lst:\n if item not in reserved_names:\n output.append(item)\n return output\n\ndef harvest_variables(ast_list): \n \"\"\" Retreive all the variables that need to be defined.\n \"\"\" \n variables = []\n if type(ast_list) in (ListType,TupleType):\n found,data = match(name_pattern,ast_list)\n if found:\n variables.append(data['var'])\n for item in ast_list:\n if type(item) in (ListType,TupleType):\n variables.extend(harvest_variables(item))\n variables = remove_duplicates(variables) \n variables = remove_reserved_names(variables) \n return variables\n\ndef match(pattern, data, vars=None):\n \"\"\"match `data' to `pattern', with variable extraction.\n\n pattern\n Pattern to match against, possibly containing variables.\n\n data\n Data to be checked and against which variables are extracted.\n\n vars\n Dictionary of variables which have already been found. If not\n provided, an empty dictionary is created.\n\n The `pattern' value may contain variables of the form ['varname'] which\n are allowed to match anything. The value that is matched is returned as\n part of a dictionary which maps 'varname' to the matched value. 'varname'\n is not required to be a string object, but using strings makes patterns\n and the code which uses them more readable.\n\n This function returns two values: a boolean indicating whether a match\n was found and a dictionary mapping variable names to their associated\n values.\n \n From the Demo/Parser/example.py file\n \"\"\"\n if vars is None:\n vars = {}\n if type(pattern) is ListType: # 'variables' are ['varname']\n vars[pattern[0]] = data\n return 1, vars\n if type(pattern) is not TupleType:\n return (pattern == data), vars\n if len(data) != len(pattern):\n return 0, vars\n for pattern, data in map(None, pattern, data):\n same, vars = match(pattern, data, vars)\n if not same:\n break\n return same, vars\n\n\ndef tuples_to_lists(ast_tuple):\n \"\"\" Convert an ast object tree in tuple form to list form.\n \"\"\"\n if type(ast_tuple) not in [ListType,TupleType]:\n return ast_tuple\n \n new_list = []\n for item in ast_tuple:\n new_list.append(tuples_to_lists(item))\n return new_list\n\n\n\"\"\"\nA little tree I built to help me understand the parse trees.\n -----------303------------------------------\n | | \n 304 -------------------------307-------------------------\n | | | | | |\n 1 'result' 9 '[' 308 12 ',' 308 10 ']'\n | |\n ---------309-------- -----309-------- \n | | | | \n 291|304 291|304 291|304 |\n | | | |\n 1 'a1' 11 ':' 1 'a2' 2 '10' 11 ':' \n\"\"\"\n", "source_code_before": "import token\nimport symbol\nimport parser\n\nfrom types import ListType, TupleType, StringType, IntType\n\ndef int_to_symbol(i):\n \"\"\" Convert numeric symbol or token to a desriptive name.\n \"\"\"\n try: \n return symbol.sym_name[i]\n except KeyError:\n return token.tok_name[i]\n \ndef translate_symbols(ast_tuple):\n \"\"\" Translate numeric grammar symbols in an ast_tuple descriptive names.\n \n This simply traverses the tree converting any integer value to values\n found in symbol.sym_name or token.tok_name.\n \"\"\" \n new_list = []\n for item in ast_tuple:\n if type(item) == IntType:\n new_list.append(int_to_symbol(item))\n elif type(item) in [TupleType,ListType]:\n new_list.append(translate_symbols(item))\n else: \n new_list.append(item)\n if type(ast_tuple) == TupleType:\n return tuple(new_list)\n else:\n return new_list\n\ndef ast_to_string(ast_seq):\n \"\"\"* Traverse an ast tree sequence, printing out all leaf nodes.\n \n This effectively rebuilds the expression the tree was built\n from. I guess its probably missing whitespace. How bout\n indent stuff and new lines? Haven't checked this since we're\n currently only dealing with simple expressions.\n *\"\"\"\n output = ''\n for item in ast_seq:\n if type(item) is StringType:\n output = output + item\n elif type(item) in [ListType,TupleType]:\n output = output + ast_to_string(item)\n return output \n\ndef build_atom(expr_string):\n \"\"\" Build an ast for an atom from the given expr string.\n \n If expr_string is not a string, it is converted to a string\n before parsing to an ast_tuple.\n \"\"\"\n # the [1][1] indexing below starts atoms at the third level\n # deep in the resulting parse tree. parser.expr will return\n # a tree rooted with eval_input -> test_list -> test ...\n # I'm considering test to be the root of atom symbols.\n # It might be a better idea to move down a little in the\n # parse tree. Any benefits? Right now, this works fine. \n if type(expr_string) == StringType:\n ast = parser.expr(expr_string).totuple()[1][1]\n else:\n ast = parser.expr(`expr_string`).totuple()[1][1]\n return ast\n\ndef atom_tuple(expr_string):\n return build_atom(expr_string)\n\ndef atom_list(expr_string):\n return tuples_to_lists(build_atom(expr_string))\n \ndef find_first_pattern(ast_tuple,pattern_list):\n \"\"\"* Find the first occurence of a pattern one of a list of patterns \n in ast_tuple.\n \n Used for testing at the moment.\n \n ast_tuple -- tuple or list created by ast.totuple() or ast.tolist().\n pattern_list -- A single pattern or list of patterns to search\n for in the ast_tuple. If a single pattern is \n used, it MUST BE A IN A TUPLE format.\n Returns:\n found -- true/false indicating whether pattern was found\n data -- dictionary of data from first matching pattern in tree.\n (see match function by Jeremy Hylton). \n *\"\"\"\n found,data = 0,{}\n \n # convert to a list if input wasn't a list\n if type(pattern_list) != ListType:\n pattern_list = [pattern_list]\n\n # look for any of the patterns in a list of patterns \n for pattern in pattern_list:\n found,data = match(pattern,ast_tuple)\n if found: \n break \n \n # if we didn't find the pattern, search sub-trees of the parse tree\n if not found: \n for item in ast_tuple: \n if type(item) in [TupleType,ListType]:\n # only search sub items if they are a list or tuple.\n found, data = find_first_pattern(item,pattern_list)\n if found: \n break \n return found,data\n\nname_pattern = (token.NAME, ['var'])\n\ndef remove_duplicates(lst):\n output = []\n for item in lst:\n if item not in output:\n output.append(item)\n return output\n\nreserved_names = ['sin']\n\ndef remove_reserved_names(lst):\n \"\"\" These are functions names -- don't create variables for them\n There is a more reobust approach, but this ought to work pretty\n well.\n \"\"\"\n output = []\n for item in lst:\n if item not in reserved_names:\n output.append(item)\n return output\n\ndef harvest_variables(ast_list): \n \"\"\" Retreive all the variables that need to be defined.\n \"\"\" \n variables = []\n if type(ast_list) in (ListType,TupleType):\n found,data = match(name_pattern,ast_list)\n if found:\n variables.append(data['var'])\n for item in ast_list:\n if type(item) in (ListType,TupleType):\n variables.extend(harvest_variables(item))\n variables = remove_duplicates(variables) \n variables = remove_reserved_names(variables) \n return variables\n\ndef match(pattern, data, vars=None):\n \"\"\"match `data' to `pattern', with variable extraction.\n\n pattern\n Pattern to match against, possibly containing variables.\n\n data\n Data to be checked and against which variables are extracted.\n\n vars\n Dictionary of variables which have already been found. If not\n provided, an empty dictionary is created.\n\n The `pattern' value may contain variables of the form ['varname'] which\n are allowed to match anything. The value that is matched is returned as\n part of a dictionary which maps 'varname' to the matched value. 'varname'\n is not required to be a string object, but using strings makes patterns\n and the code which uses them more readable.\n\n This function returns two values: a boolean indicating whether a match\n was found and a dictionary mapping variable names to their associated\n values.\n \n From the Demo/Parser/example.py file\n \"\"\"\n if vars is None:\n vars = {}\n if type(pattern) is ListType: # 'variables' are ['varname']\n vars[pattern[0]] = data\n return 1, vars\n if type(pattern) is not TupleType:\n return (pattern == data), vars\n if len(data) != len(pattern):\n return 0, vars\n for pattern, data in map(None, pattern, data):\n same, vars = match(pattern, data, vars)\n if not same:\n break\n return same, vars\n\n\ndef tuples_to_lists(ast_tuple):\n \"\"\" Convert an ast object tree in tuple form to list form.\n \"\"\"\n if type(ast_tuple) not in [ListType,TupleType]:\n return ast_tuple\n \n new_list = []\n for item in ast_tuple:\n new_list.append(tuples_to_lists(item))\n return new_list\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n \n\"\"\"\nA little tree I built to help me understand the parse trees.\n -----------303------------------------------\n | | \n 304 -------------------------307-------------------------\n | | | | | |\n 1 'result' 9 '[' 308 12 ',' 308 10 ']'\n | |\n ---------309-------- -----309-------- \n | | | | \n 291|304 291|304 291|304 |\n | | | |\n 1 'a1' 11 ':' 1 'a2' 2 '10' 11 ':' \n\"\"\"\n", "methods": [ { "name": "int_to_symbol", "long_name": "int_to_symbol( i )", "filename": "ast_tools.py", "nloc": 5, "complexity": 2, "token_count": 25, "parameters": [ "i" ], "start_line": 7, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "translate_symbols", "long_name": "translate_symbols( ast_tuple )", "filename": "ast_tools.py", "nloc": 13, "complexity": 5, "token_count": 78, "parameters": [ "ast_tuple" ], "start_line": 15, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "ast_to_string", "long_name": "ast_to_string( ast_seq )", "filename": "ast_tools.py", "nloc": 8, "complexity": 4, "token_count": 49, "parameters": [ "ast_seq" ], "start_line": 34, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "build_atom", "long_name": "build_atom( expr_string )", "filename": "ast_tools.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "expr_string" ], "start_line": 50, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "atom_tuple", "long_name": "atom_tuple( expr_string )", "filename": "ast_tools.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "expr_string" ], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "atom_list", "long_name": "atom_list( expr_string )", "filename": "ast_tools.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "expr_string" ], "start_line": 71, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_first_pattern", "long_name": "find_first_pattern( ast_tuple , pattern_list )", "filename": "ast_tools.py", "nloc": 15, "complexity": 8, "token_count": 87, "parameters": [ "ast_tuple", "pattern_list" ], "start_line": 74, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "remove_duplicates", "long_name": "remove_duplicates( lst )", "filename": "ast_tools.py", "nloc": 6, "complexity": 3, "token_count": 28, "parameters": [ "lst" ], "start_line": 113, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_reserved_names", "long_name": "remove_reserved_names( lst )", "filename": "ast_tools.py", "nloc": 6, "complexity": 3, "token_count": 29, "parameters": [ "lst" ], "start_line": 122, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "harvest_variables", "long_name": "harvest_variables( ast_list )", "filename": "ast_tools.py", "nloc": 12, "complexity": 5, "token_count": 84, "parameters": [ "ast_list" ], "start_line": 133, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "match", "long_name": "match( pattern , data , vars = None )", "filename": "ast_tools.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "pattern", "data", "vars" ], "start_line": 148, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "tuples_to_lists", "long_name": "tuples_to_lists( ast_tuple )", "filename": "ast_tools.py", "nloc": 7, "complexity": 3, "token_count": 41, "parameters": [ "ast_tuple" ], "start_line": 189, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 } ], "methods_before": [ { "name": "int_to_symbol", "long_name": "int_to_symbol( i )", "filename": "ast_tools.py", "nloc": 5, "complexity": 2, "token_count": 25, "parameters": [ "i" ], "start_line": 7, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "translate_symbols", "long_name": "translate_symbols( ast_tuple )", "filename": "ast_tools.py", "nloc": 13, "complexity": 5, "token_count": 78, "parameters": [ "ast_tuple" ], "start_line": 15, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "ast_to_string", "long_name": "ast_to_string( ast_seq )", "filename": "ast_tools.py", "nloc": 8, "complexity": 4, "token_count": 49, "parameters": [ "ast_seq" ], "start_line": 34, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "build_atom", "long_name": "build_atom( expr_string )", "filename": "ast_tools.py", "nloc": 6, "complexity": 2, "token_count": 56, "parameters": [ "expr_string" ], "start_line": 50, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "atom_tuple", "long_name": "atom_tuple( expr_string )", "filename": "ast_tools.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "expr_string" ], "start_line": 68, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "atom_list", "long_name": "atom_list( expr_string )", "filename": "ast_tools.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "expr_string" ], "start_line": 71, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "find_first_pattern", "long_name": "find_first_pattern( ast_tuple , pattern_list )", "filename": "ast_tools.py", "nloc": 15, "complexity": 8, "token_count": 87, "parameters": [ "ast_tuple", "pattern_list" ], "start_line": 74, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "remove_duplicates", "long_name": "remove_duplicates( lst )", "filename": "ast_tools.py", "nloc": 6, "complexity": 3, "token_count": 28, "parameters": [ "lst" ], "start_line": 113, "end_line": 118, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_reserved_names", "long_name": "remove_reserved_names( lst )", "filename": "ast_tools.py", "nloc": 6, "complexity": 3, "token_count": 29, "parameters": [ "lst" ], "start_line": 122, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "harvest_variables", "long_name": "harvest_variables( ast_list )", "filename": "ast_tools.py", "nloc": 12, "complexity": 5, "token_count": 84, "parameters": [ "ast_list" ], "start_line": 133, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "match", "long_name": "match( pattern , data , vars = None )", "filename": "ast_tools.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "pattern", "data", "vars" ], "start_line": 148, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "tuples_to_lists", "long_name": "tuples_to_lists( ast_tuple )", "filename": "ast_tools.py", "nloc": 7, "complexity": 3, "token_count": 41, "parameters": [ "ast_tuple" ], "start_line": 189, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ast_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 200, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ast_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 204, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ast_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 204, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ast_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 200, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 117, "complexity": 44, "token_count": 654, "diff_parsed": { "added": [], "deleted": [ "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "" ] } }, { "old_path": "weave/blitz_tools.py", "new_path": "weave/blitz_tools.py", "filename": "blitz_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -130,14 +130,3 @@ def test_function():\n hz = ones((1,1,1),typecode=Float32)\n hy = ones((1,1,1),typecode=Float32)\n blitz(expr)\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n-if __name__ == \"__main__\":\n- test_function()\n", "added_lines": 0, "deleted_lines": 11, "source_code": "import parser\nimport string\nimport copy\nimport os,sys\nimport ast_tools\nimport token,symbol\nimport slice_handler\nimport size_check\nimport converters\n\nfrom ast_tools import *\n\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n \nfrom types import *\n\nimport inline_tools\nfrom inline_tools import attempt_function_call\nfunction_catalog = inline_tools.function_catalog\nfunction_cache = inline_tools.function_cache\n \ndef blitz(expr,local_dict=None, global_dict=None,check_size=1,verbose=0,**kw):\n # this could call inline, but making a copy of the\n # code here is more efficient for several reasons.\n global function_catalog\n \n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n\n # 1. Check the sizes of the arrays and make sure they are compatible.\n # This is expensive, so unsetting the check_size flag can save a lot\n # of time. It also can cause core-dumps if the sizes of the inputs \n # aren't compatible. \n if check_size and not size_check.check_expr(expr,local_dict,global_dict):\n raise 'inputs failed to pass size check.'\n \n # 2. try local cache \n try:\n results = apply(function_cache[expr],(local_dict,global_dict))\n return results\n except: \n pass\n try:\n results = attempt_function_call(expr,local_dict,global_dict)\n # 3. build the function \n except ValueError:\n # This section is pretty much the only difference \n # between blitz and inline\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n expr_code = ast_to_blitz_expr(ast_list)\n arg_names = harvest_variables(ast_list)\n module_dir = global_dict.get('__file__',None)\n #func = inline_tools.compile_function(expr_code,arg_names,\n # local_dict,global_dict,\n # module_dir,auto_downcast = 1)\n func = inline_tools.compile_function(expr_code,arg_names,local_dict, \n global_dict,module_dir,\n compiler='gcc',auto_downcast=1,\n verbose = verbose,\n type_converters = converters.blitz,\n **kw)\n function_catalog.add_function(expr,func,module_dir)\n try: \n results = attempt_function_call(expr,local_dict,global_dict)\n except ValueError: \n print 'warning: compilation failed. Executing as python code'\n exec expr in global_dict, local_dict\n \ndef ast_to_blitz_expr(ast_seq):\n \"\"\" Convert an ast_sequence to a blitz expression.\n \"\"\"\n \n # Don't overwrite orignal sequence in call to transform slices.\n ast_seq = copy.deepcopy(ast_seq) \n slice_handler.transform_slices(ast_seq)\n \n # Build the actual program statement from ast_seq\n expr = ast_tools.ast_to_string(ast_seq)\n \n # Now find and replace specific symbols to convert this to\n # a blitz++ compatible statement.\n # I'm doing this with string replacement here. It could\n # also be done on the actual ast tree (and probably should from\n # a purest standpoint...).\n \n # this one isn't necessary but it helps code readability\n # and compactness. It requires that \n # Range _all = blitz::Range::all();\n # be included in the generated code. \n # These could all alternatively be done to the ast in\n # build_slice_atom()\n expr = string.replace(expr,'slice(_beg,_end)', '_all' ) \n expr = string.replace(expr,'slice', 'blitz::Range' )\n expr = string.replace(expr,'[','(')\n expr = string.replace(expr,']', ')' )\n expr = string.replace(expr,'_stp', '1' )\n \n # Instead of blitz::fromStart and blitz::toEnd. This requires\n # the following in the generated code.\n # Range _beg = blitz::fromStart;\n # Range _end = blitz::toEnd;\n #expr = string.replace(expr,'_beg', 'blitz::fromStart' )\n #expr = string.replace(expr,'_end', 'blitz::toEnd' )\n \n return expr + ';\\n'\n\ndef test_function():\n expr = \"ex[:,1:,1:] = k + ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n #ast = parser.suite('a = (b + c) * sin(d)')\n ast = parser.suite(expr)\n k = 1.\n ex = ones((1,1,1),typecode=Float32)\n ca_x = ones((1,1,1),typecode=Float32)\n cb_y_x = ones((1,1,1),typecode=Float32)\n cb_z_x = ones((1,1,1),typecode=Float32)\n hz = ones((1,1,1),typecode=Float32)\n hy = ones((1,1,1),typecode=Float32)\n blitz(expr)\n", "source_code_before": "import parser\nimport string\nimport copy\nimport os,sys\nimport ast_tools\nimport token,symbol\nimport slice_handler\nimport size_check\nimport converters\n\nfrom ast_tools import *\n\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n \nfrom types import *\n\nimport inline_tools\nfrom inline_tools import attempt_function_call\nfunction_catalog = inline_tools.function_catalog\nfunction_cache = inline_tools.function_cache\n \ndef blitz(expr,local_dict=None, global_dict=None,check_size=1,verbose=0,**kw):\n # this could call inline, but making a copy of the\n # code here is more efficient for several reasons.\n global function_catalog\n \n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n\n # 1. Check the sizes of the arrays and make sure they are compatible.\n # This is expensive, so unsetting the check_size flag can save a lot\n # of time. It also can cause core-dumps if the sizes of the inputs \n # aren't compatible. \n if check_size and not size_check.check_expr(expr,local_dict,global_dict):\n raise 'inputs failed to pass size check.'\n \n # 2. try local cache \n try:\n results = apply(function_cache[expr],(local_dict,global_dict))\n return results\n except: \n pass\n try:\n results = attempt_function_call(expr,local_dict,global_dict)\n # 3. build the function \n except ValueError:\n # This section is pretty much the only difference \n # between blitz and inline\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n expr_code = ast_to_blitz_expr(ast_list)\n arg_names = harvest_variables(ast_list)\n module_dir = global_dict.get('__file__',None)\n #func = inline_tools.compile_function(expr_code,arg_names,\n # local_dict,global_dict,\n # module_dir,auto_downcast = 1)\n func = inline_tools.compile_function(expr_code,arg_names,local_dict, \n global_dict,module_dir,\n compiler='gcc',auto_downcast=1,\n verbose = verbose,\n type_converters = converters.blitz,\n **kw)\n function_catalog.add_function(expr,func,module_dir)\n try: \n results = attempt_function_call(expr,local_dict,global_dict)\n except ValueError: \n print 'warning: compilation failed. Executing as python code'\n exec expr in global_dict, local_dict\n \ndef ast_to_blitz_expr(ast_seq):\n \"\"\" Convert an ast_sequence to a blitz expression.\n \"\"\"\n \n # Don't overwrite orignal sequence in call to transform slices.\n ast_seq = copy.deepcopy(ast_seq) \n slice_handler.transform_slices(ast_seq)\n \n # Build the actual program statement from ast_seq\n expr = ast_tools.ast_to_string(ast_seq)\n \n # Now find and replace specific symbols to convert this to\n # a blitz++ compatible statement.\n # I'm doing this with string replacement here. It could\n # also be done on the actual ast tree (and probably should from\n # a purest standpoint...).\n \n # this one isn't necessary but it helps code readability\n # and compactness. It requires that \n # Range _all = blitz::Range::all();\n # be included in the generated code. \n # These could all alternatively be done to the ast in\n # build_slice_atom()\n expr = string.replace(expr,'slice(_beg,_end)', '_all' ) \n expr = string.replace(expr,'slice', 'blitz::Range' )\n expr = string.replace(expr,'[','(')\n expr = string.replace(expr,']', ')' )\n expr = string.replace(expr,'_stp', '1' )\n \n # Instead of blitz::fromStart and blitz::toEnd. This requires\n # the following in the generated code.\n # Range _beg = blitz::fromStart;\n # Range _end = blitz::toEnd;\n #expr = string.replace(expr,'_beg', 'blitz::fromStart' )\n #expr = string.replace(expr,'_end', 'blitz::toEnd' )\n \n return expr + ';\\n'\n\ndef test_function():\n expr = \"ex[:,1:,1:] = k + ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n #ast = parser.suite('a = (b + c) * sin(d)')\n ast = parser.suite(expr)\n k = 1.\n ex = ones((1,1,1),typecode=Float32)\n ca_x = ones((1,1,1),typecode=Float32)\n cb_y_x = ones((1,1,1),typecode=Float32)\n cb_z_x = ones((1,1,1),typecode=Float32)\n hz = ones((1,1,1),typecode=Float32)\n hy = ones((1,1,1),typecode=Float32)\n blitz(expr)\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n test_function()\n", "methods": [ { "name": "blitz", "long_name": "blitz( expr , local_dict = None , global_dict = None , check_size = 1 , verbose = 0 , ** kw )", "filename": "blitz_tools.py", "nloc": 34, "complexity": 8, "token_count": 216, "parameters": [ "expr", "local_dict", "global_dict", "check_size", "verbose", "kw" ], "start_line": 27, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ast_to_blitz_expr", "long_name": "ast_to_blitz_expr( ast_seq )", "filename": "blitz_tools.py", "nloc": 10, "complexity": 1, "token_count": 92, "parameters": [ "ast_seq" ], "start_line": 81, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "test_function", "long_name": "test_function( )", "filename": "blitz_tools.py", "nloc": 13, "complexity": 1, "token_count": 123, "parameters": [], "start_line": 119, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "methods_before": [ { "name": "blitz", "long_name": "blitz( expr , local_dict = None , global_dict = None , check_size = 1 , verbose = 0 , ** kw )", "filename": "blitz_tools.py", "nloc": 34, "complexity": 8, "token_count": 216, "parameters": [ "expr", "local_dict", "global_dict", "check_size", "verbose", "kw" ], "start_line": 27, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 53, "top_nesting_level": 0 }, { "name": "ast_to_blitz_expr", "long_name": "ast_to_blitz_expr( ast_seq )", "filename": "blitz_tools.py", "nloc": 10, "complexity": 1, "token_count": 92, "parameters": [ "ast_seq" ], "start_line": 81, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 }, { "name": "test_function", "long_name": "test_function( )", "filename": "blitz_tools.py", "nloc": 13, "complexity": 1, "token_count": 123, "parameters": [], "start_line": 119, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "blitz_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "blitz_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "blitz_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "blitz_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 134, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 77, "complexity": 10, "token_count": 495, "diff_parsed": { "added": [], "deleted": [ "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "", "if __name__ == \"__main__\":", " test_function()" ] } }, { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -609,13 +609,3 @@ def build_import_library():\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n-\n-\n", "added_lines": 0, "deleted_lines": 10, "source_code": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n \n # The following line is a HACK to fix a problem with building the\n # freetype shared library under Mac OS X:\n ld += ' -framework AppKit'\n \n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n\n\ndef create_extension(module_path, **kw):\n \"\"\" Create an Extension that can be buil by setup.py\n \n See build_extension for information on keyword arguments.\n \"\"\"\n # some (most?) platforms will fail to link C++ correctly\n # unless scipy_distutils is used.\n try:\n from scipy_distutils.core import Extension\n except ImportError:\n from distutils.core import Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # the business end of the function\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n return ext \n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n try:\n from scipy_distutils.core import setup, Extension\n except ImportError:\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n ext = create_extension(module_path,**kw)\n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # 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, # export_symbols, we do this in our def-file\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 \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n \n # The following line is a HACK to fix a problem with building the\n # freetype shared library under Mac OS X:\n ld += ' -framework AppKit'\n \n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n\n\ndef create_extension(module_path, **kw):\n \"\"\" Create an Extension that can be buil by setup.py\n \n See build_extension for information on keyword arguments.\n \"\"\"\n # some (most?) platforms will fail to link C++ correctly\n # unless scipy_distutils is used.\n try:\n from scipy_distutils.core import Extension\n except ImportError:\n from distutils.core import Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # the business end of the function\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n return ext \n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n try:\n from scipy_distutils.core import setup, Extension\n except ImportError:\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n ext = create_extension(module_path,**kw)\n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # 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, # export_symbols, we do this in our def-file\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 \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "methods": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 13, "complexity": 3, "token_count": 95, "parameters": [], "start_line": 33, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "create_extension", "long_name": "create_extension( module_path , ** kw )", "filename": "build_tools.py", "nloc": 30, "complexity": 7, "token_count": 258, "parameters": [ "module_path", "kw" ], "start_line": 71, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 50, "complexity": 8, "token_count": 330, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 127, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 293, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 305, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 308, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 316, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 339, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 361, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 381, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 391, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 407, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 37, "complexity": 8, "token_count": 212, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 450, "end_line": 513, "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": "build_tools.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": 517, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 571, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 581, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_init_posix", "long_name": "_init_posix( )", "filename": "build_tools.py", "nloc": 13, "complexity": 3, "token_count": 95, "parameters": [], "start_line": 33, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 }, { "name": "create_extension", "long_name": "create_extension( module_path , ** kw )", "filename": "build_tools.py", "nloc": 30, "complexity": 7, "token_count": 258, "parameters": [ "module_path", "kw" ], "start_line": 71, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 0 }, { "name": "build_extension", "long_name": "build_extension( module_path , compiler_name = '' , build_dir = None , temp_dir = None , verbose = 0 , ** kw )", "filename": "build_tools.py", "nloc": 50, "complexity": 8, "token_count": 330, "parameters": [ "module_path", "compiler_name", "build_dir", "temp_dir", "verbose", "kw" ], "start_line": 127, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 164, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name , temp_dir , build_dir )", "filename": "build_tools.py", "nloc": 9, "complexity": 3, "token_count": 68, "parameters": [ "compiler_name", "temp_dir", "build_dir" ], "start_line": 293, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "build_tools.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 305, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "configure_python_path", "long_name": "configure_python_path( build_dir )", "filename": "build_tools.py", "nloc": 4, "complexity": 3, "token_count": 51, "parameters": [ "build_dir" ], "start_line": 308, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "build_tools.py", "nloc": 13, "complexity": 7, "token_count": 55, "parameters": [ "compiler_name" ], "start_line": 316, "end_line": 337, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "build_tools.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 339, "end_line": 359, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "build_tools.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 361, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_tools.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 381, "end_line": 386, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "configure_temp_dir", "long_name": "configure_temp_dir( temp_dir = None )", "filename": "build_tools.py", "nloc": 13, "complexity": 5, "token_count": 82, "parameters": [ "temp_dir" ], "start_line": 391, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "configure_build_dir", "long_name": "configure_build_dir( build_dir = None )", "filename": "build_tools.py", "nloc": 18, "complexity": 7, "token_count": 112, "parameters": [ "build_dir" ], "start_line": 407, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_tools.py", "nloc": 37, "complexity": 8, "token_count": 212, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 450, "end_line": 513, "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": "build_tools.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": 517, "end_line": 560, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 571, "end_line": 579, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 581, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 612, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 616, "end_line": 618, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 616, "end_line": 618, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 612, "end_line": 614, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 334, "complexity": 67, "token_count": 1955, "diff_parsed": { "added": [], "deleted": [ "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "", "", "" ] } }, { "old_path": "weave/c_spec.py", "new_path": "weave/c_spec.py", "filename": "c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -451,14 +451,6 @@ def init_info(self):\n def type_match(self,value):\n return 1\n \n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n if __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n", "added_lines": 0, "deleted_lines": 8, "source_code": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\n#----------------------------------------------------------------------------\n# speed note\n# the convert_to_int macro below takes about 25 ns per conversion on my\n# 850 MHz PIII. A slightly more sophisticated macro version can trim this\n# to 20 ns, but this savings is dang near useless because the other \n# overhead swamps it...\n#----------------------------------------------------------------------------\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(return_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(return_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.extra_compile_args = []\n self.extra_link_args = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.return_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n for arg in self.extra_compile_args:\n info.add_extra_compile_args(arg)\n for arg in self.extra_link_args:\n info.add_extra_link_args(arg)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['return_type'] = self.return_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.return_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n \n def declaration_code(self,templatize = 0,inline=0):\n # since wstring doesn't seem to work everywhere, we need to provide\n # the length variable Nxxx for the unicode string xxx.\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' \\\n 'int N%(name)s = PyUnicode_GET_SIZE(%(py_var)s);\\n' \\\n % self.template_vars(inline=inline)\n\n\n return code \n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['w'] = 'unsigned short'\nnum_to_c_types['i'] = 'int'\nnum_to_c_types['u'] = 'unsigned int'\n\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.return_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.return_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/dict.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.return_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.return_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.return_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#\n# catch all now handles callable objects\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "source_code_before": "from types import *\nfrom base_spec import base_converter\nimport base_info\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from python objects to C++ objects\n#\n# This is silly code. There is absolutely no reason why these simple\n# conversion functions should be classes. However, some versions of \n# Mandrake Linux ship with broken C++ compilers (or libraries) that do not\n# handle exceptions correctly when they are thrown from functions. However,\n# exceptions thrown from class methods always work, so we make everything\n# a class method to solve this error.\n#----------------------------------------------------------------------------\n\n#----------------------------------------------------------------------------\n# speed note\n# the convert_to_int macro below takes about 25 ns per conversion on my\n# 850 MHz PIII. A slightly more sophisticated macro version can trim this\n# to 20 ns, but this savings is dang near useless because the other \n# overhead swamps it...\n#----------------------------------------------------------------------------\npy_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(return_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // Incref occurs even if conversion fails so that\n // the decref in cleanup_code has a matching incref.\n %(inc_ref_count)s\n if (!py_obj || !%(check_func)s(py_obj))\n handle_conversion_error(py_obj,\"%(type_name)s\", name); \n return %(to_c_return)s;\n }\n \n %(return_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n // !! Pretty sure INCREF should only be called on success since\n // !! py_to_xxx is used by the user -- not the code generator.\n if (!py_obj || !%(check_func)s(py_obj))\n handle_bad_type(py_obj,\"%(type_name)s\", name); \n %(inc_ref_count)s\n return %(to_c_return)s;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\n#----------------------------------------------------------------------------\n# C++ code template for converting code from C++ objects to Python objects\n#\n#----------------------------------------------------------------------------\n\nsimple_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(PyObject* obj)\n{\n return (PyObject*) obj;\n}\n\n\"\"\"\n\nclass common_base_converter(base_converter):\n \n def __init__(self):\n self.init_info()\n self._build_information = [self.generate_build_info()]\n \n def init_info(self):\n self.matching_types = []\n self.headers = []\n self.include_dirs = []\n self.libraries = []\n self.library_dirs = []\n self.sources = []\n self.support_code = []\n self.module_init_code = []\n self.warnings = []\n self.define_macros = []\n self.extra_compile_args = []\n self.extra_link_args = []\n self.use_ref_count = 1\n self.name = \"no_name\"\n self.c_type = 'PyObject*'\n self.return_type = 'PyObject*'\n self.to_c_return = 'py_obj'\n \n def info_object(self):\n return base_info.custom_info()\n \n def generate_build_info(self):\n info = self.info_object()\n for header in self.headers:\n info.add_header(header)\n for d in self.include_dirs:\n info.add_include_dir(d)\n for lib in self.libraries:\n info.add_library(lib)\n for d in self.library_dirs:\n info.add_library_dir(d)\n for source in self.sources:\n info.add_source(source)\n for code in self.support_code:\n info.add_support_code(code)\n info.add_support_code(self.py_to_c_code())\n info.add_support_code(self.c_to_py_code())\n for init_code in self.module_init_code:\n info.add_module_init_code(init_code)\n for macro in self.define_macros:\n info.add_define_macro(macro)\n for warning in self.warnings:\n info.add_warning(warning)\n for arg in self.extra_compile_args:\n info.add_extra_compile_args(arg)\n for arg in self.extra_link_args:\n info.add_extra_link_args(arg)\n return info\n\n def type_match(self,value):\n return type(value) in self.matching_types\n\n def get_var_type(self,value):\n return type(value)\n \n def type_spec(self,name,value):\n # factory\n new_spec = self.__class__()\n new_spec.name = name \n new_spec.var_type = self.get_var_type(value)\n return new_spec\n\n def template_vars(self,inline=0):\n d = {}\n d['type_name'] = self.type_name\n d['check_func'] = self.check_func\n d['c_type'] = self.c_type\n d['return_type'] = self.return_type\n d['to_c_return'] = self.to_c_return\n d['name'] = self.name\n d['py_var'] = self.py_variable()\n d['var_lookup'] = self.retrieve_py_variable(inline)\n code = 'convert_to_%(type_name)s(%(py_var)s,\"%(name)s\")' % d\n d['var_convert'] = code\n if self.use_ref_count:\n d['inc_ref_count'] = \"Py_XINCREF(py_obj);\"\n else:\n d['inc_ref_count'] = \"\"\n return d\n\n def py_to_c_code(self):\n return py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return simple_c_to_py_template % self.template_vars()\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' % \\\n self.template_vars(inline=inline)\n return code \n\n def cleanup_code(self):\n if self.use_ref_count:\n code = 'Py_XDECREF(%(py_var)s);\\n' % self.template_vars()\n #code += 'printf(\"cleaning up %(py_var)s\\\\n\");\\n' % self.template_vars()\n else:\n code = \"\" \n return code\n \n def __repr__(self):\n msg = \"(file:: name: %s)\" % self.name\n return msg\n def __cmp__(self,other):\n #only works for equal\n result = -1\n try:\n result = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__)\n except AttributeError:\n pass\n return result \n\n#----------------------------------------------------------------------------\n# Module Converter\n#----------------------------------------------------------------------------\nclass module_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'module'\n self.check_func = 'PyModule_Check' \n # probably should test for callable classes here also.\n self.matching_types = [ModuleType]\n\n#----------------------------------------------------------------------------\n# String Converter\n#----------------------------------------------------------------------------\nclass string_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'string'\n self.check_func = 'PyString_Check' \n self.c_type = 'std::string'\n self.return_type = 'std::string'\n self.to_c_return = \"std::string(PyString_AsString(py_obj))\"\n self.matching_types = [StringType]\n self.headers.append('')\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* string_to_py(std::string s)\n {\n return PyString_FromString(s.c_str());\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n# Unicode Converter\n#----------------------------------------------------------------------------\nclass unicode_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'unicode'\n self.check_func = 'PyUnicode_Check'\n # This isn't supported by gcc 2.95.3 -- MSVC works fine with it. \n #self.c_type = 'std::wstring'\n #self.to_c_return = \"std::wstring(PyUnicode_AS_UNICODE(py_obj))\"\n self.c_type = 'Py_UNICODE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyUnicode_AS_UNICODE(py_obj)\"\n self.matching_types = [UnicodeType]\n #self.headers.append('')\n \n def declaration_code(self,templatize = 0,inline=0):\n # since wstring doesn't seem to work everywhere, we need to provide\n # the length variable Nxxx for the unicode string xxx.\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(name)s = %(var_convert)s;\\n' \\\n 'int N%(name)s = PyUnicode_GET_SIZE(%(py_var)s);\\n' \\\n % self.template_vars(inline=inline)\n\n\n return code \n#----------------------------------------------------------------------------\n# File Converter\n#----------------------------------------------------------------------------\nclass file_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'file'\n self.check_func = 'PyFile_Check' \n self.c_type = 'FILE*'\n self.return_type = self.c_type\n self.to_c_return = \"PyFile_AsFile(py_obj)\"\n self.headers = ['']\n self.matching_types = [FileType]\n\n def c_to_py_code(self):\n # !! Need to dedent returned code.\n code = \"\"\"\n PyObject* file_to_py(FILE* file, char* name, char* mode)\n {\n PyObject* py_obj = NULL;\n //extern int fclose(FILE *);\n return (PyObject*) PyFile_FromFile(file, name, mode, fclose);\n }\n \"\"\"\n return code \n\n#----------------------------------------------------------------------------\n#\n# Scalar Number Conversions\n#\n#----------------------------------------------------------------------------\n\n# the following typemaps are for 32 bit platforms. A way to do this\n# general case? maybe ask numeric types how long they are and base\n# the decisions on that.\n\n#----------------------------------------------------------------------------\n# Standard Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types = {}\nnum_to_c_types[type(1)] = 'int'\nnum_to_c_types[type(1.)] = 'double'\nnum_to_c_types[type(1.+1.j)] = 'std::complex '\n# !! hmmm. The following is likely unsafe...\nnum_to_c_types[type(1L)] = 'int'\n\n#----------------------------------------------------------------------------\n# Numeric array Python numeric --> C type maps\n#----------------------------------------------------------------------------\nnum_to_c_types['T'] = 'T' # for templates\nnum_to_c_types['F'] = 'std::complex '\nnum_to_c_types['D'] = 'std::complex '\nnum_to_c_types['f'] = 'float'\nnum_to_c_types['d'] = 'double'\nnum_to_c_types['1'] = 'char'\nnum_to_c_types['b'] = 'unsigned char'\nnum_to_c_types['s'] = 'short'\nnum_to_c_types['w'] = 'unsigned short'\nnum_to_c_types['i'] = 'int'\nnum_to_c_types['u'] = 'unsigned int'\n\n# not strictly correct, but shoulld be fine fo numeric work.\n# add test somewhere to make sure long can be cast to int before using.\nnum_to_c_types['l'] = 'int'\n\nclass scalar_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.warnings = ['disable: 4275', 'disable: 4101']\n self.headers = ['','']\n self.use_ref_count = 0\n\nclass int_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'int'\n self.check_func = 'PyInt_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyInt_AsLong(py_obj)\"\n self.matching_types = [IntType]\n\nclass long_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # !! long to int conversion isn't safe!\n self.type_name = 'long'\n self.check_func = 'PyLong_Check' \n self.c_type = 'int'\n self.return_type = 'int'\n self.to_c_return = \"(int) PyLong_AsLong(py_obj)\"\n self.matching_types = [LongType]\n\nclass float_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n # Not sure this is really that safe...\n self.type_name = 'float'\n self.check_func = 'PyFloat_Check' \n self.c_type = 'double'\n self.return_type = 'double'\n self.to_c_return = \"PyFloat_AsDouble(py_obj)\"\n self.matching_types = [FloatType]\n\nclass complex_converter(scalar_converter):\n def init_info(self):\n scalar_converter.init_info(self)\n self.type_name = 'complex'\n self.check_func = 'PyComplex_Check' \n self.c_type = 'std::complex'\n self.return_type = 'std::complex'\n self.to_c_return = \"std::complex(PyComplex_RealAsDouble(py_obj),\"\\\n \"PyComplex_ImagAsDouble(py_obj))\"\n self.matching_types = [ComplexType]\n\n#----------------------------------------------------------------------------\n#\n# List, Tuple, and Dict converters.\n#\n# Based on SCXX by Gordon McMillan\n#----------------------------------------------------------------------------\nimport os, c_spec # yes, I import myself to find out my __file__ location.\nlocal_dir,junk = os.path.split(os.path.abspath(c_spec.__file__)) \nscxx_dir = os.path.join(local_dir,'scxx')\n\nclass scxx_converter(common_base_converter):\n def init_info(self):\n common_base_converter.init_info(self)\n self.headers = ['\"scxx/object.h\"','\"scxx/list.h\"','\"scxx/tuple.h\"',\n '\"scxx/dict.h\"','']\n self.include_dirs = [local_dir,scxx_dir]\n self.sources = [os.path.join(scxx_dir,'weave_imp.cpp'),]\n\nclass list_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'list'\n self.check_func = 'PyList_Check' \n self.c_type = 'py::list'\n self.return_type = 'py::list'\n self.to_c_return = 'py::list(py_obj)'\n self.matching_types = [ListType]\n # ref counting handled by py::list\n self.use_ref_count = 0\n\nclass tuple_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'tuple'\n self.check_func = 'PyTuple_Check' \n self.c_type = 'py::tuple'\n self.return_type = 'py::tuple'\n self.to_c_return = 'py::tuple(py_obj)'\n self.matching_types = [TupleType]\n # ref counting handled by py::tuple\n self.use_ref_count = 0\n\nclass dict_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'dict'\n self.check_func = 'PyDict_Check' \n self.c_type = 'py::dict'\n self.return_type = 'py::dict'\n self.to_c_return = 'py::dict(py_obj)'\n self.matching_types = [DictType]\n # ref counting handled by py::dict\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Instance Converter\n#----------------------------------------------------------------------------\nclass instance_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'instance'\n self.check_func = 'PyInstance_Check' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n self.matching_types = [InstanceType]\n # ref counting handled by py::object\n self.use_ref_count = 0\n\n#----------------------------------------------------------------------------\n# Catchall Converter\n#\n# catch all now handles callable objects\n#----------------------------------------------------------------------------\nclass catchall_converter(scxx_converter):\n def init_info(self):\n scxx_converter.init_info(self)\n self.type_name = 'catchall'\n self.check_func = '' \n self.c_type = 'py::object'\n self.return_type = 'py::object'\n self.to_c_return = 'py::object(py_obj)'\n # ref counting handled by py::object\n self.use_ref_count = 0\n def type_match(self,value):\n return 1\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n x = list_converter().type_spec(\"x\",1)\n print x.py_to_c_code()\n print\n print x.c_to_py_code()\n print\n print x.declaration_code(inline=1)\n print\n print x.cleanup_code()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 18, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 77, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 27, "complexity": 12, "token_count": 177, "parameters": [ "self" ], "start_line": 99, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 127, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 130, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 133, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 17, "complexity": 2, "token_count": 114, "parameters": [ "self", "inline" ], "start_line": 140, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 158, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 161, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 164, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 170, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 178, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 195, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 206, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 215, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 229, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 6, "complexity": 1, "token_count": 32, "parameters": [ "self", "templatize", "inline" ], "start_line": 242, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 256, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 266, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 318, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 325, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 335, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 346, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 378, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 386, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 398, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 410, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 425, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 442, "end_line": 450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 451, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 73, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 18, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 77, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "info_object", "long_name": "info_object( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "c_spec.py", "nloc": 27, "complexity": 12, "token_count": 177, "parameters": [ "self" ], "start_line": 99, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "value" ], "start_line": 127, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "value" ], "start_line": 130, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 33, "parameters": [ "self", "name", "value" ], "start_line": 133, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "c_spec.py", "nloc": 17, "complexity": 2, "token_count": 114, "parameters": [ "self", "inline" ], "start_line": 140, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 158, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 161, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "templatize", "inline" ], "start_line": 164, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "cleanup_code", "long_name": "cleanup_code( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 170, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 178, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "c_spec.py", "nloc": 8, "complexity": 3, "token_count": 43, "parameters": [ "self", "other" ], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 195, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 206, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 215, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 229, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "c_spec.py", "nloc": 6, "complexity": 1, "token_count": 32, "parameters": [ "self", "templatize", "inline" ], "start_line": 242, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 256, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "c_spec.py", "nloc": 10, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 266, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 5, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 318, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 325, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 335, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 346, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self" ], "start_line": 378, "end_line": 383, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 386, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 398, "end_line": 407, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 410, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 9, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 425, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "c_spec.py", "nloc": 8, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 442, "end_line": 450, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "c_spec.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "value" ], "start_line": 451, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 454, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 458, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 458, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 454, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 336, "complexity": 48, "token_count": 1704, "diff_parsed": { "added": [], "deleted": [ "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "" ] } }, { "old_path": "weave/catalog.py", "new_path": "weave/catalog.py", "filename": "catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -678,11 +678,3 @@ def fast_cache(self,code,function):\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n- \n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n", "added_lines": 0, "deleted_lines": 8, "source_code": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport pickle\nimport tempfile\n\ntry:\n import dbhash\n import shelve\n dumb = 0\nexcept ImportError:\n import dumb_shelve as shelve\n dumb = 1\n\n#For testing...\n#import dumb_shelve as shelve\n#dumb = 1\n\n#import shelve\n#dumb = 0\n \ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except (TypeError, KeyError, ImportError):\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n\ndef create_dir(p):\n \"\"\" Create a directory and any necessary intermediate directories.\"\"\"\n if not os.path.exists(p):\n try:\n os.mkdir(p)\n except OSError:\n # perhaps one or more intermediate path components don't exist\n # try to create them\n base,dir = os.path.split(p)\n create_dir(base)\n # don't enclose this one in try/except - we want the user to\n # get failure info\n os.mkdir(p)\n\ndef is_writable(dir):\n dummy = os.path.join(dir, \"dummy\")\n try:\n open(dummy, 'w')\n except IOError:\n return 0\n os.unlink(dummy)\n return 1\n\ndef whoami():\n \"\"\"return a string identifying the user.\"\"\"\n return os.environ.get(\"USER\") or os.environ.get(\"USERNAME\") or \"unknown\"\n\ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n \n # add a subdirectory for the OS.\n # It might be better to do this at a different location so that\n # it wasn't only the default directory that gets this behavior. \n #path = os.path.join(path,sys.platform)\n else:\n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n \n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\ndef intermediate_dir():\n \"\"\" Location in temp dir for storing .cpp and .o files during\n builds.\n \"\"\"\n python_name = \"python%d%d_intermediate\" % tuple(sys.version_info[:2]) \n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n if not os.path.exists(path):\n create_dir(path)\n return path\n \ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n Well... it should be. Stuck with dumbdbm for now and the modes\n almost don't matter. We do some checking for 'r' mode, but that\n is about it.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n try:\n # code reliant on the fact that we are using dumbdbm\n if dumb and mode == 'r' and not os.path.exists(catalog_file+'.dat'):\n sh = None\n else:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n # open every stinking file to check if it exists.\n # This is because anydbm doesn't provide a consistent naming \n # convention across platforms for its files \n existing_files = []\n for file in files:\n if get_catalog(os.path.dirname(file),'r') is not None:\n existing_files.append(file)\n # This is the non-portable (and much faster) old code\n #existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else:\n # if it is in the cache, then it is also\n # been persisted \n return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_dir = self.get_writable_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n import glob\n files = glob.glob(cat_file+'*')\n for f in files:\n os.remove(f)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n # Prabhu was getting some corrupt catalog errors. I'll put a try/except\n # to protect against this, but should really try and track down the issue.\n function_list = [function]\n try:\n function_list = function_list + cat.get(code,[])\n except pickle.UnpicklingError:\n pass\n cat[code] = function_list\n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\tcat.close()\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n", "source_code_before": "\"\"\" Track relationships between compiled extension functions & code fragments\n\n catalog keeps track of which compiled(or even standard) functions are \n related to which code fragments. It also stores these relationships\n to disk so they are remembered between Python sessions. When \n \n a = 1\n compiler.inline('printf(\"printed from C: %d\",a);',['a'] )\n \n is called, inline() first looks to see if it has seen the code \n 'printf(\"printed from C\");' before. If not, it calls \n \n catalog.get_functions('printf(\"printed from C: %d\", a);')\n \n which returns a list of all the function objects that have been compiled\n for the code fragment. Multiple functions can occur because the code\n could be compiled for different types for 'a' (although not likely in\n this case). The catalog first looks in its cache and quickly returns\n a list of the functions if possible. If the cache lookup fails, it then\n looks through possibly multiple catalog files on disk and fills its\n cache with all the functions that match the code fragment. \n \n In case where the code fragment hasn't been compiled, inline() compiles\n the code and then adds it to the catalog:\n \n function = \n catalog.add_function('printf(\"printed from C: %d\", a);',function)\n \n add_function() adds function to the front of the cache. function,\n along with the path information to its module, are also stored in a\n persistent catalog for future use by python sessions. \n\"\"\" \n\nimport os,sys,string\nimport pickle\nimport tempfile\n\ntry:\n import dbhash\n import shelve\n dumb = 0\nexcept ImportError:\n import dumb_shelve as shelve\n dumb = 1\n\n#For testing...\n#import dumb_shelve as shelve\n#dumb = 1\n\n#import shelve\n#dumb = 0\n \ndef getmodule(object):\n \"\"\" Discover the name of the module where object was defined.\n \n This is an augmented version of inspect.getmodule that can discover \n the parent module for extension functions.\n \"\"\"\n import inspect\n value = inspect.getmodule(object)\n if value is None:\n #walk trough all modules looking for function\n for name,mod in sys.modules.items():\n # try except used because of some comparison failures\n # in wxPoint code. Need to review this\n try:\n if mod and object in mod.__dict__.values():\n value = mod\n # if it is a built-in module, keep looking to see\n # if a non-builtin also has it. Otherwise quit and\n # consider the module found. (ain't perfect, but will \n # have to do for now).\n if string.find('(built-in)',str(mod)) is -1:\n break\n \n except (TypeError, KeyError, ImportError):\n pass \n return value\n\ndef expr_to_filename(expr):\n \"\"\" Convert an arbitrary expr string to a valid file name.\n \n The name is based on the md5 check sum for the string and\n Something that was a little more human readable would be \n nice, but the computer doesn't seem to care.\n \"\"\"\n import md5\n base = 'sc_'\n return base + md5.new(expr).hexdigest()\n\ndef unique_file(d,expr):\n \"\"\" Generate a unqiue file name based on expr in directory d\n \n This is meant for use with building extension modules, so\n a file name is considered unique if none of the following\n extension '.cpp','.o','.so','module.so','.py', or '.pyd'\n exists in directory d. The fully qualified path to the\n new name is returned. You'll need to append your own\n extension to it before creating files.\n \"\"\"\n files = os.listdir(d)\n #base = 'scipy_compile'\n base = expr_to_filename(expr)\n for i in range(1000000):\n fname = base + `i`\n if not (fname+'.cpp' in files or\n fname+'.o' in files or\n fname+'.so' in files or\n fname+'module.so' in files or\n fname+'.py' in files or\n fname+'.pyd' in files):\n break\n return os.path.join(d,fname)\n\ndef create_dir(p):\n \"\"\" Create a directory and any necessary intermediate directories.\"\"\"\n if not os.path.exists(p):\n try:\n os.mkdir(p)\n except OSError:\n # perhaps one or more intermediate path components don't exist\n # try to create them\n base,dir = os.path.split(p)\n create_dir(base)\n # don't enclose this one in try/except - we want the user to\n # get failure info\n os.mkdir(p)\n\ndef is_writable(dir):\n dummy = os.path.join(dir, \"dummy\")\n try:\n open(dummy, 'w')\n except IOError:\n return 0\n os.unlink(dummy)\n return 1\n\ndef whoami():\n \"\"\"return a string identifying the user.\"\"\"\n return os.environ.get(\"USER\") or os.environ.get(\"USERNAME\") or \"unknown\"\n\ndef default_dir():\n \"\"\" Return a default location to store compiled files and catalogs.\n \n XX is the Python version number in all paths listed below\n On windows, the default location is the temporary directory\n returned by gettempdir()/pythonXX.\n \n On Unix, ~/.pythonXX_compiled is the default location. If it doesn't\n exist, it is created. The directory is marked rwx------.\n \n If for some reason it isn't possible to build a default directory\n in the user's home, /tmp/_pythonXX_compiled is used. If it \n doesn't exist, it is created. The directory is marked rwx------\n to try and keep people from being able to sneak a bad module\n in on you. \n \"\"\"\n python_name = \"python%d%d_compiled\" % tuple(sys.version_info[:2]) \n if sys.platform != 'win32':\n try:\n path = os.path.join(os.environ['HOME'],'.' + python_name)\n except KeyError:\n temp_dir = `os.getuid()` + '_' + python_name\n path = os.path.join(tempfile.gettempdir(),temp_dir) \n \n # add a subdirectory for the OS.\n # It might be better to do this at a different location so that\n # it wasn't only the default directory that gets this behavior. \n #path = os.path.join(path,sys.platform)\n else:\n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n \n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\ndef intermediate_dir():\n \"\"\" Location in temp dir for storing .cpp and .o files during\n builds.\n \"\"\"\n python_name = \"python%d%d_intermediate\" % tuple(sys.version_info[:2]) \n path = os.path.join(tempfile.gettempdir(),\"%s\"%whoami(),python_name)\n if not os.path.exists(path):\n create_dir(path)\n return path\n \ndef default_temp_dir():\n path = os.path.join(default_dir(),'temp')\n if not os.path.exists(path):\n create_dir(path)\n os.chmod(path,0700) # make it only accessible by this user.\n if not is_writable(path):\n print 'warning: default directory is not write accessible.'\n print 'default:', path\n return path\n\n \ndef os_dependent_catalog_name():\n \"\"\" Generate catalog name dependent on OS and Python version being used.\n \n This allows multiple platforms to have catalog files in the\n same directory without stepping on each other. For now, it \n bases the name of the value returned by sys.platform and the\n version of python being run. If this isn't enough to descriminate\n on some platforms, we can try to add other info. It has \n occured to me that if we get fancy enough to optimize for different\n architectures, then chip type might be added to the catalog name also.\n \"\"\"\n version = '%d%d' % sys.version_info[:2]\n return sys.platform+version+'compiled_catalog'\n \ndef catalog_path(module_path):\n \"\"\" Return the full path name for the catalog file in the given directory.\n \n module_path can either be a file name or a path name. If it is a \n file name, the catalog file name in its parent directory is returned.\n If it is a directory, the catalog file in that directory is returned.\n\n If module_path doesn't exist, None is returned. Note though, that the\n catalog file does *not* have to exist, only its parent. '~', shell\n variables, and relative ('.' and '..') paths are all acceptable.\n \n catalog file names are os dependent (based on sys.platform), so this \n should support multiple platforms sharing the same disk space \n (NFS mounts). See os_dependent_catalog_name() for more info.\n \"\"\"\n module_path = os.path.expanduser(module_path)\n module_path = os.path.expandvars(module_path)\n module_path = os.path.abspath(module_path)\n if not os.path.exists(module_path):\n catalog_file = None\n elif not os.path.isdir(module_path):\n module_path,dummy = os.path.split(module_path)\n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n else: \n catalog_file = os.path.join(module_path,os_dependent_catalog_name())\n return catalog_file\n\ndef get_catalog(module_path,mode='r'):\n \"\"\" Return a function catalog (shelve object) from the path module_path\n\n If module_path is a directory, the function catalog returned is\n from that directory. If module_path is an actual module_name,\n then the function catalog returned is from its parent directory.\n mode uses the standard 'c' = create, 'n' = new, 'r' = read, \n 'w' = write file open modes available for anydbm databases.\n \n Well... it should be. Stuck with dumbdbm for now and the modes\n almost don't matter. We do some checking for 'r' mode, but that\n is about it.\n \n See catalog_path() for more information on module_path.\n \"\"\"\n if mode not in ['c','r','w','n']:\n msg = \" mode must be 'c', 'n', 'r', or 'w'. See anydbm for more info\"\n raise ValueError, msg\n catalog_file = catalog_path(module_path)\n try:\n # code reliant on the fact that we are using dumbdbm\n if dumb and mode == 'r' and not os.path.exists(catalog_file+'.dat'):\n sh = None\n else:\n sh = shelve.open(catalog_file,mode)\n except: # not sure how to pin down which error to catch yet\n sh = None\n return sh\n\nclass catalog:\n \"\"\" Stores information about compiled functions both in cache and on disk.\n \n catalog stores (code, list_of_function) pairs so that all the functions\n that have been compiled for code are available for calling (usually in\n inline or blitz).\n \n catalog keeps a dictionary of previously accessed code values cached \n for quick access. It also handles the looking up of functions compiled \n in previously called Python sessions on disk in function catalogs. \n catalog searches the directories in the PYTHONCOMPILED environment \n variable in order loading functions that correspond to the given code \n fragment. A default directory is also searched for catalog functions. \n On unix, the default directory is usually '~/.pythonxx_compiled' where \n xx is the version of Python used. On windows, it is the directory \n returned by temfile.gettempdir(). Functions closer to the front are of \n the variable list are guaranteed to be closer to the front of the \n function list so that they will be called first. See \n get_cataloged_functions() for more info on how the search order is \n traversed.\n \n Catalog also handles storing information about compiled functions to\n a catalog. When writing this information, the first writable catalog\n file in PYTHONCOMPILED path is used. If a writable catalog is not\n found, it is written to the catalog in the default directory. This\n directory should always be writable.\n \"\"\"\n def __init__(self,user_path_list=None):\n \"\"\" Create a catalog for storing/searching for compiled functions. \n \n user_path_list contains directories that should be searched \n first for function catalogs. They will come before the path\n entries in the PYTHONCOMPILED environment varilable.\n \"\"\"\n if type(user_path_list) == type('string'):\n self.user_path_list = [user_path_list]\n elif user_path_list:\n self.user_path_list = user_path_list\n else:\n self.user_path_list = []\n self.cache = {}\n self.module_dir = None\n self.paths_added = 0\n \n def set_module_directory(self,module_dir):\n \"\"\" Set the path that will replace 'MODULE' in catalog searches.\n \n You should call clear_module_directory() when your finished\n working with it.\n \"\"\"\n self.module_dir = module_dir\n def get_module_directory(self):\n \"\"\" Return the path used to replace the 'MODULE' in searches.\n \"\"\"\n return self.module_dir\n def clear_module_directory(self):\n \"\"\" Reset 'MODULE' path to None so that it is ignored in searches. \n \"\"\"\n self.module_dir = None\n \n def get_environ_path(self):\n \"\"\" Return list of paths from 'PYTHONCOMPILED' environment variable.\n \n On Unix the path in PYTHONCOMPILED is a ':' separated list of\n directories. On Windows, a ';' separated list is used. \n \"\"\"\n paths = []\n if os.environ.has_key('PYTHONCOMPILED'):\n path_string = os.environ['PYTHONCOMPILED'] \n if sys.platform == 'win32':\n #probably should also look in registry\n paths = path_string.split(';')\n else: \n paths = path_string.split(':')\n return paths \n\n def build_search_order(self):\n \"\"\" Returns a list of paths that are searched for catalogs. \n \n Values specified in the catalog constructor are searched first,\n then values found in the PYTHONCOMPILED environment variable.\n The directory returned by default_dir() is always returned at\n the end of the list.\n \n There is a 'magic' path name called 'MODULE' that is replaced\n by the directory defined by set_module_directory(). If the\n module directory hasn't been set, 'MODULE' is ignored.\n \"\"\"\n \n paths = self.user_path_list + self.get_environ_path()\n search_order = []\n for path in paths:\n if path == 'MODULE':\n if self.module_dir:\n search_order.append(self.module_dir)\n else:\n search_order.append(path)\n search_order.append(default_dir())\n return search_order\n\n def get_catalog_files(self):\n \"\"\" Returns catalog file list in correct search order.\n \n Some of the catalog files may not currently exists.\n However, all will be valid locations for a catalog\n to be created (if you have write permission).\n \"\"\"\n files = map(catalog_path,self.build_search_order())\n files = filter(lambda x: x is not None,files)\n return files\n\n def get_existing_files(self):\n \"\"\" Returns all existing catalog file list in correct search order.\n \"\"\"\n files = self.get_catalog_files()\n # open every stinking file to check if it exists.\n # This is because anydbm doesn't provide a consistent naming \n # convention across platforms for its files \n existing_files = []\n for file in files:\n if get_catalog(os.path.dirname(file),'r') is not None:\n existing_files.append(file)\n # This is the non-portable (and much faster) old code\n #existing_files = filter(os.path.exists,files)\n return existing_files\n\n def get_writable_file(self,existing_only=0):\n \"\"\" Return the name of the first writable catalog file.\n \n Its parent directory must also be writable. This is so that\n compiled modules can be written to the same directory.\n \"\"\"\n # note: both file and its parent directory must be writeable\n if existing_only:\n files = self.get_existing_files()\n else:\n files = self.get_catalog_files()\n # filter for (file exists and is writable) OR directory is writable\n def file_test(x):\n from os import access, F_OK, W_OK\n return (access(x,F_OK) and access(x,W_OK) or\n access(os.path.dirname(x),W_OK))\n writable = filter(file_test,files)\n if writable:\n file = writable[0]\n else:\n file = None\n return file\n \n def get_writable_dir(self):\n \"\"\" Return the parent directory of first writable catalog file.\n \n The returned directory has write access.\n \"\"\"\n return os.path.dirname(self.get_writable_file())\n \n def unique_module_name(self,code,module_dir=None):\n \"\"\" Return full path to unique file name that in writable location.\n \n The directory for the file is the first writable directory in \n the catalog search path. The unique file name is derived from\n the code fragment. If, module_dir is specified, it is used\n to replace 'MODULE' in the search path.\n \"\"\"\n if module_dir is not None:\n self.set_module_directory(module_dir)\n try:\n d = self.get_writable_dir()\n finally:\n if module_dir is not None:\n self.clear_module_directory()\n return unique_file(d,code)\n\n def path_key(self,code):\n \"\"\" Return key for path information for functions associated with code.\n \"\"\"\n return '__path__' + code\n \n def configure_path(self,cat,code):\n \"\"\" Add the python path for the given code to the sys.path\n \n unconfigure_path() should be called as soon as possible after\n imports associated with code are finished so that sys.path \n is restored to normal.\n \"\"\"\n try:\n paths = cat[self.path_key(code)]\n self.paths_added = len(paths)\n sys.path = paths + sys.path\n except:\n self.paths_added = 0 \n \n def unconfigure_path(self):\n \"\"\" Restores sys.path to normal after calls to configure_path()\n \n Remove the previously added paths from sys.path\n \"\"\"\n sys.path = sys.path[self.paths_added:]\n self.paths_added = 0\n\n def get_cataloged_functions(self,code):\n \"\"\" Load all functions associated with code from catalog search path.\n \n Sometimes there can be trouble loading a function listed in a\n catalog file because the actual module that holds the function \n has been moved or deleted. When this happens, that catalog file\n is \"repaired\", meaning the entire entry for this function is \n removed from the file. This only affects the catalog file that\n has problems -- not the others in the search path.\n \n The \"repair\" behavior may not be needed, but I'll keep it for now.\n \"\"\"\n mode = 'r'\n cat = None\n function_list = []\n for path in self.build_search_order():\n cat = get_catalog(path,mode)\n if cat is not None and cat.has_key(code):\n # set up the python path so that modules for this\n # function can be loaded.\n self.configure_path(cat,code)\n try: \n function_list += cat[code]\n except: #SystemError and ImportError so far seen \n # problems loading a function from the catalog. Try to\n # repair the cause.\n cat.close()\n self.repair_catalog(path,code)\n self.unconfigure_path() \n return function_list\n\n\n def repair_catalog(self,catalog_path,code):\n \"\"\" Remove entry for code from catalog_path\n \n Occasionally catalog entries could get corrupted. An example\n would be when a module that had functions in the catalog was\n deleted or moved on the disk. The best current repair method is \n just to trash the entire catalog entry for this piece of code. \n This may loose function entries that are valid, but thats life.\n \n catalog_path must be writable for repair. If it isn't, the\n function exists with a warning. \n \"\"\"\n writable_cat = None\n if not os.path.exists(catalog_path):\n return\n try:\n writable_cat = get_catalog(catalog_path,'w')\n except:\n print 'warning: unable to repair catalog entry\\n %s\\n in\\n %s' % \\\n (code,catalog_path)\n return \n if writable_cat.has_key(code):\n print 'repairing catalog by removing key'\n del writable_cat[code]\n \n # it is possible that the path key doesn't exist (if the function registered\n # was a built-in function), so we have to check if the path exists before\n # arbitrarily deleting it.\n path_key = self.path_key(code) \n if writable_cat.has_key(path_key):\n del writable_cat[path_key] \n \n def get_functions_fast(self,code):\n \"\"\" Return list of functions for code from the cache.\n \n Return an empty list if the code entry is not found.\n \"\"\"\n return self.cache.get(code,[])\n \n def get_functions(self,code,module_dir=None):\n \"\"\" Return the list of functions associated with this code fragment.\n \n The cache is first searched for the function. If an entry\n in the cache is not found, then catalog files on disk are \n searched for the entry. This is slooooow, but only happens\n once per code object. All the functions found in catalog files\n on a cache miss are loaded into the cache to speed up future calls.\n The search order is as follows:\n \n 1. user specified path (from catalog initialization)\n 2. directories from the PYTHONCOMPILED environment variable\n 3. The temporary directory on your platform.\n\n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n # Fast!! try cache first.\n if self.cache.has_key(code):\n return self.cache[code]\n \n # 2. Slow!! read previously compiled functions from disk.\n try:\n self.set_module_directory(module_dir)\n function_list = self.get_cataloged_functions(code)\n # put function_list in cache to save future lookups.\n if function_list:\n self.cache[code] = function_list\n # return function_list, empty or otherwise.\n finally:\n self.clear_module_directory()\n return function_list\n\n def add_function(self,code,function,module_dir=None):\n \"\"\" Adds a function to the catalog.\n \n The function is added to the cache as well as the first\n writable file catalog found in the search path. If no\n code entry exists in the cache, the on disk catalogs\n are loaded into the cache and function is added to the\n beginning of the function list.\n \n The path specified by module_dir will replace the 'MODULE' \n place holder in the catalog search path. See build_search_order()\n for more info on the search path. \n \"\"\" \n\n # 1. put it in the cache.\n if self.cache.has_key(code):\n if function not in self.cache[code]:\n self.cache[code].insert(0,function)\n else:\n # if it is in the cache, then it is also\n # been persisted \n return\n else: \n # Load functions and put this one up front\n self.cache[code] = self.get_functions(code) \n self.fast_cache(code,function)\n # 2. Store the function entry to disk. \n try:\n self.set_module_directory(module_dir)\n self.add_function_persistent(code,function)\n finally:\n self.clear_module_directory()\n \n def add_function_persistent(self,code,function):\n \"\"\" Store the code->function relationship to disk.\n \n Two pieces of information are needed for loading functions\n from disk -- the function pickle (which conveniently stores\n the module name, etc.) and the path to its module's directory.\n The latter is needed so that the function can be loaded no\n matter what the user's Python path is.\n \"\"\" \n # add function to data in first writable catalog\n mode = 'c' # create if doesn't exist, otherwise, use existing\n cat_dir = self.get_writable_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir()\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n cat_dir = default_dir() \n cat_file = catalog_path(cat_dir)\n print 'problems with default catalog -- removing'\n import glob\n files = glob.glob(cat_file+'*')\n for f in files:\n os.remove(f)\n cat = get_catalog(cat_dir,mode)\n if cat is None:\n raise ValueError, 'Failed to access a catalog for storing functions' \n # Prabhu was getting some corrupt catalog errors. I'll put a try/except\n # to protect against this, but should really try and track down the issue.\n function_list = [function]\n try:\n function_list = function_list + cat.get(code,[])\n except pickle.UnpicklingError:\n pass\n cat[code] = function_list\n # now add needed path information for loading function\n module = getmodule(function)\n try:\n # built in modules don't have the __file__ extension, so this\n # will fail. Just pass in this case since path additions aren't\n # needed for built-in modules.\n mod_path,f=os.path.split(os.path.abspath(module.__file__))\n pkey = self.path_key(code)\n cat[pkey] = [mod_path] + cat.get(pkey,[])\n except:\n pass\n\tcat.close()\n\n def fast_cache(self,code,function):\n \"\"\" Move function to the front of the cache entry for code\n \n If future calls to the function have the same type signature,\n this will speed up access significantly because the first\n function call is correct.\n \n Note: The cache added to the inline_tools module is significantly\n faster than always calling get_functions, so this isn't\n as necessary as it used to be. Still, it's probably worth\n doing. \n \"\"\"\n try:\n if self.cache[code][0] == function:\n return\n except: # KeyError, IndexError \n pass\n try:\n self.cache[code].remove(function)\n except ValueError:\n pass\n # put new function at the beginning of the list to search.\n self.cache[code].insert(0,function)\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 81, "parameters": [ "object" ], "start_line": 53, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 80, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 91, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "create_dir", "long_name": "create_dir( p )", "filename": "catalog.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "p" ], "start_line": 115, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "is_writable", "long_name": "is_writable( dir )", "filename": "catalog.py", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [ "dir" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "whoami", "long_name": "whoami( )", "filename": "catalog.py", "nloc": 2, "complexity": 3, "token_count": 25, "parameters": [], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 17, "complexity": 5, "token_count": 141, "parameters": [], "start_line": 142, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "intermediate_dir", "long_name": "intermediate_dir( )", "filename": "catalog.py", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 56, "parameters": [], "start_line": 191, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 202, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 216, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 13, "complexity": 6, "token_count": 80, "parameters": [ "module_path", "mode" ], "start_line": 243, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 299, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 316, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 323, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 332, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 348, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 372, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 7, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 383, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 410, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 398, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 421, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 428, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 445, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 450, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 464, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 472, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 504, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 536, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 65, "parameters": [ "self", "code", "module_dir" ], "start_line": 543, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 577, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 32, "complexity": 7, "token_count": 199, "parameters": [ "self", "code", "function" ], "start_line": 610, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 658, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 } ], "methods_before": [ { "name": "getmodule", "long_name": "getmodule( object )", "filename": "catalog.py", "nloc": 13, "complexity": 7, "token_count": 81, "parameters": [ "object" ], "start_line": 53, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "expr_to_filename", "long_name": "expr_to_filename( expr )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "expr" ], "start_line": 80, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "unique_file", "long_name": "unique_file( d , expr )", "filename": "catalog.py", "nloc": 13, "complexity": 8, "token_count": 89, "parameters": [ "d", "expr" ], "start_line": 91, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "create_dir", "long_name": "create_dir( p )", "filename": "catalog.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "p" ], "start_line": 115, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "is_writable", "long_name": "is_writable( dir )", "filename": "catalog.py", "nloc": 8, "complexity": 2, "token_count": 38, "parameters": [ "dir" ], "start_line": 129, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "whoami", "long_name": "whoami( )", "filename": "catalog.py", "nloc": 2, "complexity": 3, "token_count": 25, "parameters": [], "start_line": 138, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "default_dir", "long_name": "default_dir( )", "filename": "catalog.py", "nloc": 17, "complexity": 5, "token_count": 141, "parameters": [], "start_line": 142, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "intermediate_dir", "long_name": "intermediate_dir( )", "filename": "catalog.py", "nloc": 6, "complexity": 2, "token_count": 58, "parameters": [], "start_line": 181, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "default_temp_dir", "long_name": "default_temp_dir( )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 56, "parameters": [], "start_line": 191, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "os_dependent_catalog_name", "long_name": "os_dependent_catalog_name( )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [], "start_line": 202, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "catalog_path", "long_name": "catalog_path( module_path )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 105, "parameters": [ "module_path" ], "start_line": 216, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "name": "get_catalog", "long_name": "get_catalog( module_path , mode = 'r' )", "filename": "catalog.py", "nloc": 13, "complexity": 6, "token_count": 80, "parameters": [ "module_path", "mode" ], "start_line": 243, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , user_path_list = None )", "filename": "catalog.py", "nloc": 10, "complexity": 3, "token_count": 60, "parameters": [ "self", "user_path_list" ], "start_line": 299, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "set_module_directory", "long_name": "set_module_directory( self , module_dir )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "module_dir" ], "start_line": 316, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_module_directory", "long_name": "get_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 323, "end_line": 326, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "clear_module_directory", "long_name": "clear_module_directory( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 327, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_environ_path", "long_name": "get_environ_path( self )", "filename": "catalog.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 332, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "build_search_order", "long_name": "build_search_order( self )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 62, "parameters": [ "self" ], "start_line": 348, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "get_catalog_files", "long_name": "get_catalog_files( self )", "filename": "catalog.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 372, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_existing_files", "long_name": "get_existing_files( self )", "filename": "catalog.py", "nloc": 7, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 383, "end_line": 396, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "get_writable_file.file_test", "long_name": "get_writable_file.file_test( x )", "filename": "catalog.py", "nloc": 4, "complexity": 3, "token_count": 43, "parameters": [ "x" ], "start_line": 410, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 }, { "name": "get_writable_file", "long_name": "get_writable_file( self , existing_only = 0 )", "filename": "catalog.py", "nloc": 12, "complexity": 3, "token_count": 55, "parameters": [ "self", "existing_only" ], "start_line": 398, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_writable_dir", "long_name": "get_writable_dir( self )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 421, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "unique_module_name", "long_name": "unique_module_name( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "self", "code", "module_dir" ], "start_line": 428, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "path_key", "long_name": "path_key( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "code" ], "start_line": 445, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "configure_path", "long_name": "configure_path( self , cat , code )", "filename": "catalog.py", "nloc": 7, "complexity": 2, "token_count": 47, "parameters": [ "self", "cat", "code" ], "start_line": 450, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "unconfigure_path", "long_name": "unconfigure_path( self )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 464, "end_line": 470, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_cataloged_functions", "long_name": "get_cataloged_functions( self , code )", "filename": "catalog.py", "nloc": 15, "complexity": 5, "token_count": 86, "parameters": [ "self", "code" ], "start_line": 472, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "repair_catalog", "long_name": "repair_catalog( self , catalog_path , code )", "filename": "catalog.py", "nloc": 16, "complexity": 5, "token_count": 83, "parameters": [ "self", "catalog_path", "code" ], "start_line": 504, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "get_functions_fast", "long_name": "get_functions_fast( self , code )", "filename": "catalog.py", "nloc": 2, "complexity": 1, "token_count": 20, "parameters": [ "self", "code" ], "start_line": 536, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_functions", "long_name": "get_functions( self , code , module_dir = None )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 65, "parameters": [ "self", "code", "module_dir" ], "start_line": 543, "end_line": 575, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , code , function , module_dir = None )", "filename": "catalog.py", "nloc": 14, "complexity": 4, "token_count": 97, "parameters": [ "self", "code", "function", "module_dir" ], "start_line": 577, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "add_function_persistent", "long_name": "add_function_persistent( self , code , function )", "filename": "catalog.py", "nloc": 32, "complexity": 7, "token_count": 199, "parameters": [ "self", "code", "function" ], "start_line": 610, "end_line": 656, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "fast_cache", "long_name": "fast_cache( self , code , function )", "filename": "catalog.py", "nloc": 11, "complexity": 4, "token_count": 59, "parameters": [ "self", "code", "function" ], "start_line": 658, "end_line": 680, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 682, "end_line": 684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 686, "end_line": 688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 686, "end_line": 688, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "catalog.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 682, "end_line": 684, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 363, "complexity": 106, "token_count": 1992, "diff_parsed": { "added": [], "deleted": [ "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)" ] } }, { "old_path": "weave/ext_tools.py", "new_path": "weave/ext_tools.py", "filename": "ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -442,11 +442,3 @@ def format_error_msg(errors):\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n", "added_lines": 0, "deleted_lines": 8, "source_code": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n\n def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n return kw,file\n \n def setup_extension(self,location='.',**kw):\n kw,file = self.build_kw_and_file(location,kw)\n return build_tools.create_extension(file, **kw)\n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n kw,file = self.build_kw_and_file(location,kw)\n \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n \"\"\" generate the source code file. Only overwrite\n the existing file if the actual source has changed.\n \"\"\"\n file_changed = 1\n if os.path.exists(module_file):\n f =open(module_file,'r')\n old_string = f.read()\n f.close()\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n print 'file changed'\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n", "source_code_before": "import os, sys\nimport string, re\n\nimport catalog \nimport build_tools\nimport converters\nimport base_spec\n\nclass ext_function_from_specs:\n def __init__(self,name,code_block,arg_specs):\n self.name = name\n self.arg_specs = base_spec.arg_spec_list(arg_specs)\n self.code_block = code_block\n self.compiler = ''\n self.customize = base_info.custom_info()\n \n def header_code(self):\n pass\n\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args,' \\\n ' PyObject* kywds)\\n{\\n'\n return code % self.name\n\n #def cpp_function_declaration_code(self):\n # pass\n #def cpp_function_call_code(self):\n #s pass\n \n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n \n This code got a lot uglier when I added local_dict...\n \"\"\"\n join = string.join\n\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py_local_dict = NULL;\\n'\n arg_string_list = self.arg_specs.variable_as_strings() + ['\"local_dict\"']\n arg_strings = join(arg_string_list,',')\n if arg_strings: arg_strings += ','\n declare_kwlist = 'static char *kwlist[] = {%s NULL};\\n' % arg_strings\n\n py_objects = join(self.arg_specs.py_pointers(),', ')\n init_flags = join(self.arg_specs.init_flags(),', ')\n init_flags_init = join(self.arg_specs.init_flags(),'= ')\n py_vars = join(self.arg_specs.py_variables(),' = ')\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n declare_py_objects += 'int '+ init_flags + ';\\n' \n init_values = py_vars + ' = NULL;\\n'\n init_values += init_flags_init + ' = 0;\\n\\n'\n else:\n declare_py_objects = ''\n init_values = '' \n\n #Each variable is in charge of its own cleanup now.\n #cnt = len(arg_list)\n #declare_cleanup = \"blitz::TinyVector clean_up(0);\\n\" % cnt\n\n ref_string = join(self.arg_specs.py_references(),', ')\n if ref_string:\n ref_string += ', &py_local_dict'\n else:\n ref_string = '&py_local_dict'\n \n format = \"O\"* len(self.arg_specs) + \"|O\" + ':' + self.name\n parse_tuple = 'if(!PyArg_ParseTupleAndKeywords(args,' \\\n 'kywds,\"%s\",kwlist,%s))\\n' % (format,ref_string)\n parse_tuple += ' return NULL;\\n'\n\n return declare_return + declare_kwlist + declare_py_objects \\\n + init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code())\n arg_strings.append(arg.init_flag() +\" = 1;\\n\")\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n have_cleanup = filter(lambda x:x.cleanup_code(),self.arg_specs)\n for arg in have_cleanup:\n code = \"if(%s)\\n\" % arg.init_flag()\n code += \"{\\n\"\n code += indent(arg.cleanup_code(),4)\n code += \"}\\n\"\n arg_strings.append(code)\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n \n def function_code(self):\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n local_dict_code = indent(self.arg_local_dict_code(),4)\n\n dict_code = \"if(py_local_dict) \\n\" \\\n \"{ \\n\" \\\n \" py::dict local_dict = py::dict(py_local_dict); \\n\" + \\\n local_dict_code + \\\n \"} \\n\"\n\n try_code = \"try \\n\" \\\n \"{ \\n\" + \\\n decl_code + \\\n \" /**/ \\n\" + \\\n function_code + \\\n indent(dict_code,4) + \\\n \"\\n} \\n\"\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\"\n\n return_code = \" /*cleanup code*/ \\n\" + \\\n cleanup_code + \\\n ' if(!(PyObject*)return_val && !exception_occured)\\n' \\\n ' {\\n \\n' \\\n ' return_val = Py_None; \\n' \\\n ' }\\n \\n' \\\n ' return return_val.disown(); \\n' \\\n '} \\n'\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS|' \\\n 'METH_KEYWORDS},\\n' % args\n return function_decls\n\n def set_compiler(self,compiler):\n self.compiler = compiler\n for arg in self.arg_specs:\n arg.set_compiler(compiler)\n\n\nclass ext_function(ext_function_from_specs):\n def __init__(self,name,code_block, args, local_dict=None, global_dict=None,\n auto_downcast=1, type_converters=None):\n \n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if type_converters is None:\n type_converters = converters.default\n arg_specs = assign_variable_types(args,local_dict, global_dict,\n auto_downcast, type_converters)\n ext_function_from_specs.__init__(self,name,code_block,arg_specs)\n \n \nimport base_info\n\nclass ext_module:\n def __init__(self,name,compiler=''):\n standard_info = converters.standard_info\n self.name = name\n self.functions = []\n self.compiler = compiler\n self.customize = base_info.custom_info()\n self._build_information = base_info.info_list(standard_info)\n \n def add_function(self,func):\n self.functions.append(func)\n def module_code(self):\n code = self.warning_code() + \\\n self.header_code() + \\\n self.support_code() + \\\n self.function_code() + \\\n self.python_function_definition_code() + \\\n self.module_init_code()\n return code\n\n def arg_specs(self):\n all_arg_specs = base_spec.arg_spec_list()\n for func in self.functions:\n all_arg_specs += func.arg_specs\n return all_arg_specs\n\n def build_information(self):\n info = [self.customize] + self._build_information + \\\n self.arg_specs().build_information()\n for func in self.functions:\n info.append(func.customize)\n #redundant, but easiest place to make sure compiler is set\n for i in info:\n i.set_compiler(self.compiler)\n return info\n \n def get_headers(self):\n all_headers = self.build_information().headers()\n\n # blitz/array.h always needs to be first so we hack that here...\n if '\"blitz/array.h\"' in all_headers:\n all_headers.remove('\"blitz/array.h\"')\n all_headers.insert(0,'\"blitz/array.h\"')\n return all_headers\n\n def warning_code(self):\n all_warnings = self.build_information().warnings()\n w=map(lambda x: \"#pragma warning(%s)\\n\" % x,all_warnings)\n return ''.join(w)\n \n def header_code(self):\n h = self.get_headers()\n h= map(lambda x: '#include ' + x + '\\n',h)\n return ''.join(h)\n\n def support_code(self):\n code = self.build_information().support_code()\n return ''.join(code)\n\n def function_code(self):\n all_function_code = \"\"\n for func in self.functions:\n all_function_code += func.function_code()\n return ''.join(all_function_code)\n\n def python_function_definition_code(self):\n all_definition_code = \"\"\n for func in self.functions:\n all_definition_code += func.python_function_definition_code()\n all_definition_code = indent(''.join(all_definition_code),4)\n code = 'static PyMethodDef compiled_methods[] = \\n' \\\n '{\\n' \\\n '%s' \\\n ' {NULL, NULL} /* Sentinel */\\n' \\\n '};\\n'\n return code % (all_definition_code)\n\n def module_init_code(self):\n init_code_list = self.build_information().module_init_code()\n init_code = indent(''.join(init_code_list),4)\n code = 'extern \"C\" void init%s()\\n' \\\n '{\\n' \\\n '%s' \\\n ' (void) Py_InitModule(\"%s\", compiled_methods);\\n' \\\n '}\\n' % (self.name,init_code,self.name)\n return code\n\n def generate_file(self,file_name=\"\",location='.'):\n code = self.module_code()\n if not file_name:\n file_name = self.name + '.cpp'\n name = generate_file_name(file_name,location)\n #return name\n return generate_module(code,name)\n\n def set_compiler(self,compiler):\n # This is not used anymore -- I think we should ditch it.\n #for i in self.arg_specs()\n # i.set_compiler(compiler)\n for i in self.build_information():\n i.set_compiler(compiler) \n for i in self.functions:\n i.set_compiler(compiler)\n self.compiler = compiler \n\n def build_kw_and_file(self,location,kw): \n arg_specs = self.arg_specs()\n info = self.build_information()\n _source_files = info.sources()\n # remove duplicates\n source_files = {}\n for i in _source_files:\n source_files[i] = None\n source_files = source_files.keys()\n \n # add internally specified macros, includes, etc. to the key words\n # values of the same names so that distutils will use them.\n kw['define_macros'] = kw.get('define_macros',[]) + \\\n info.define_macros()\n kw['include_dirs'] = kw.get('include_dirs',[]) + info.include_dirs()\n kw['libraries'] = kw.get('libraries',[]) + info.libraries()\n kw['library_dirs'] = kw.get('library_dirs',[]) + info.library_dirs()\n kw['extra_compile_args'] = kw.get('extra_compile_args',[]) + \\\n info.extra_compile_args()\n kw['extra_link_args'] = kw.get('extra_link_args',[]) + \\\n info.extra_link_args()\n kw['sources'] = kw.get('sources',[]) + source_files \n file = self.generate_file(location=location)\n return kw,file\n \n def setup_extension(self,location='.',**kw):\n kw,file = self.build_kw_and_file(location,kw)\n return build_tools.create_extension(file, **kw)\n \n def compile(self,location='.',compiler=None, verbose = 0, **kw):\n \n if compiler is not None:\n self.compiler = compiler\n \n # !! removed -- we don't have any compiler dependent code\n # currently in spec or info classes \n # hmm. Is there a cleaner way to do this? Seems like\n # choosing the compiler spagettis around a little. \n #compiler = build_tools.choose_compiler(self.compiler) \n #self.set_compiler(compiler)\n \n kw,file = self.build_kw_and_file(location,kw)\n \n # This is needed so that files build correctly even when different\n # versions of Python are running around.\n # Imported at beginning of file now to help with test paths.\n # import catalog \n #temp = catalog.default_temp_dir()\n # for speed, build in the machines temp directory\n temp = catalog.intermediate_dir()\n \n success = build_tools.build_extension(file, temp_dir = temp,\n compiler_name = compiler,\n verbose = verbose, **kw)\n if not success:\n raise SystemError, 'Compilation failed'\n\ndef generate_file_name(module_name,module_location):\n module_file = os.path.join(module_location,module_name)\n return os.path.abspath(module_file)\n\ndef generate_module(module_string, module_file):\n \"\"\" generate the source code file. Only overwrite\n the existing file if the actual source has changed.\n \"\"\"\n file_changed = 1\n if os.path.exists(module_file):\n f =open(module_file,'r')\n old_string = f.read()\n f.close()\n if old_string == module_string:\n file_changed = 0\n if file_changed:\n print 'file changed'\n f =open(module_file,'w')\n f.write(module_string)\n f.close()\n return module_file\n\ndef assign_variable_types(variables,local_dict = {}, global_dict = {},\n auto_downcast = 1,\n type_converters = converters.default):\n incoming_vars = {}\n incoming_vars.update(global_dict)\n incoming_vars.update(local_dict)\n variable_specs = []\n errors={}\n for var in variables:\n try:\n example_type = incoming_vars[var]\n\n # look through possible type specs to find which one\n # should be used to for example_type\n spec = None\n for factory in type_converters:\n if factory.type_match(example_type):\n spec = factory.type_spec(var,example_type)\n break \n if not spec:\n # should really define our own type.\n raise IndexError\n else:\n variable_specs.append(spec)\n except KeyError:\n errors[var] = (\"The type and dimensionality specifications\" +\n \"for variable '\" + var + \"' are missing.\")\n except IndexError:\n errors[var] = (\"Unable to convert variable '\"+ var +\n \"' to a C++ type.\")\n if errors:\n raise TypeError, format_error_msg(errors)\n\n if auto_downcast:\n variable_specs = downcast(variable_specs)\n return variable_specs\n\ndef downcast(var_specs):\n \"\"\" Cast python scalars down to most common type of\n arrays used.\n\n Right now, focus on complex and float types. Ignore int types.\n Require all arrays to have same type before forcing downcasts.\n\n Note: var_specs are currently altered in place (horrors...!)\n \"\"\"\n numeric_types = []\n\n #grab all the numeric types associated with a variables.\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n numeric_types.append(var.numeric_type)\n\n # if arrays are present, but none of them are double precision,\n # make all numeric types float or complex(float)\n if ( ('f' in numeric_types or 'F' in numeric_types) and\n not ('d' in numeric_types or 'D' in numeric_types) ):\n for var in var_specs:\n if hasattr(var,'numeric_type'):\n # really should do this some other way...\n if var.numeric_type == type(1+1j):\n var.numeric_type = 'F'\n elif var.numeric_type == type(1.):\n var.numeric_type = 'f'\n return var_specs\n\ndef indent(st,spaces):\n indention = ' '*spaces\n indented = indention + string.replace(st,'\\n','\\n'+indention)\n # trim off any trailing spaces\n indented = re.sub(r' +$',r'',indented)\n return indented\n\ndef format_error_msg(errors):\n #minimum effort right now...\n import pprint,cStringIO\n msg = cStringIO.StringIO()\n pprint.pprint(errors,msg)\n return msg.getvalue()\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 344, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 14, "complexity": 4, "token_count": 75, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 366, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 403, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 432, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 439, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , code_block , arg_specs )", "filename": "ext_tools.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "self", "name", "code_block", "arg_specs" ], "start_line": 10, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 17, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "ext_tools.py", "nloc": 32, "complexity": 4, "token_count": 209, "parameters": [ "self" ], "start_line": 36, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "ext_tools.py", "nloc": 7, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 83, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 76, "parameters": [ "self" ], "start_line": 91, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 36, "complexity": 1, "token_count": 160, "parameters": [ "self" ], "start_line": 110, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 152, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self", "compiler" ], "start_line": 158, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , code_block , args , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None )", "filename": "ext_tools.py", "nloc": 12, "complexity": 4, "token_count": 92, "parameters": [ "self", "name", "code_block", "args", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 165, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "ext_tools.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "name", "compiler" ], "start_line": 183, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "add_function", "long_name": "add_function( self , func )", "filename": "ext_tools.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "func" ], "start_line": 191, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "module_code", "long_name": "module_code( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 193, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "arg_specs", "long_name": "arg_specs( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 26, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "build_information", "long_name": "build_information( self )", "filename": "ext_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "self" ], "start_line": 208, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "get_headers", "long_name": "get_headers( self )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 37, "parameters": [ "self" ], "start_line": 218, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "warning_code", "long_name": "warning_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 227, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "header_code", "long_name": "header_code( self )", "filename": "ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 232, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "support_code", "long_name": "support_code( self )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 237, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "ext_tools.py", "nloc": 5, "complexity": 2, "token_count": 29, "parameters": [ "self" ], "start_line": 241, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "ext_tools.py", "nloc": 11, "complexity": 2, "token_count": 52, "parameters": [ "self" ], "start_line": 247, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "module_init_code", "long_name": "module_init_code( self )", "filename": "ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 259, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_file", "long_name": "generate_file( self , file_name = \"\" , location = '.' )", "filename": "ext_tools.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "file_name", "location" ], "start_line": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "set_compiler", "long_name": "set_compiler( self , compiler )", "filename": "ext_tools.py", "nloc": 6, "complexity": 3, "token_count": 40, "parameters": [ "self", "compiler" ], "start_line": 277, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_kw_and_file", "long_name": "build_kw_and_file( self , location , kw )", "filename": "ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 205, "parameters": [ "self", "location", "kw" ], "start_line": 287, "end_line": 310, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 24, "top_nesting_level": 1 }, { "name": "setup_extension", "long_name": "setup_extension( self , location = '.' , ** kw )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 34, "parameters": [ "self", "location", "kw" ], "start_line": 312, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "compile", "long_name": "compile( self , location = '.' , compiler = None , verbose = 0 , ** kw )", "filename": "ext_tools.py", "nloc": 10, "complexity": 3, "token_count": 81, "parameters": [ "self", "location", "compiler", "verbose", "kw" ], "start_line": 316, "end_line": 342, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "generate_file_name", "long_name": "generate_file_name( module_name , module_location )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "module_name", "module_location" ], "start_line": 344, "end_line": 346, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "generate_module", "long_name": "generate_module( module_string , module_file )", "filename": "ext_tools.py", "nloc": 14, "complexity": 4, "token_count": 75, "parameters": [ "module_string", "module_file" ], "start_line": 348, "end_line": 364, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "assign_variable_types", "long_name": "assign_variable_types( variables , local_dict = { } , global_dict = { } , auto_downcast = 1 , type_converters = converters . default )", "filename": "ext_tools.py", "nloc": 31, "complexity": 9, "token_count": 156, "parameters": [ "variables", "local_dict", "global_dict", "auto_downcast", "type_converters" ], "start_line": 366, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 0 }, { "name": "downcast", "long_name": "downcast( var_specs )", "filename": "ext_tools.py", "nloc": 14, "complexity": 11, "token_count": 103, "parameters": [ "var_specs" ], "start_line": 403, "end_line": 430, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 0 }, { "name": "indent", "long_name": "indent( st , spaces )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 44, "parameters": [ "st", "spaces" ], "start_line": 432, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "format_error_msg", "long_name": "format_error_msg( errors )", "filename": "ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "errors" ], "start_line": 439, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 450, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 450, "end_line": 452, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "ext_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 446, "end_line": 448, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 329, "complexity": 78, "token_count": 2130, "diff_parsed": { "added": [], "deleted": [ "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)" ] } }, { "old_path": "weave/pre___init__.py", "new_path": "weave/info_weave.py", "filename": "info_weave.py", "extension": "py", "change_type": "RENAME", "diff": "@@ -7,3 +7,5 @@\n 3. ext_tools-- a module that helps construct C/C++ extension modules.\n 4. accelerate -- a module that inline accelerates Python functions\n \"\"\"\n+postpone_import = 1\n+standalone = 1\n", "added_lines": 2, "deleted_lines": 0, "source_code": "\"\"\"\nC/C++ integration\n=================\n\n 1. inline() -- a function for including C/C++ code within Python\n 2. blitz() -- a function for compiling Numeric expressions to C++\n 3. ext_tools-- a module that helps construct C/C++ extension modules.\n 4. accelerate -- a module that inline accelerates Python functions\n\"\"\"\npostpone_import = 1\nstandalone = 1\n", "source_code_before": "\"\"\"\nC/C++ integration\n=================\n\n 1. inline() -- a function for including C/C++ code within Python\n 2. blitz() -- a function for compiling Numeric expressions to C++\n 3. ext_tools-- a module that helps construct C/C++ extension modules.\n 4. accelerate -- a module that inline accelerates Python functions\n\"\"\"\n", "methods": [], "methods_before": [], "changed_methods": [], "nloc": 11, "complexity": 0, "token_count": 7, "diff_parsed": { "added": [ "postpone_import = 1", "standalone = 1" ], "deleted": [] } }, { "old_path": "weave/inline_tools.py", "new_path": "weave/inline_tools.py", "filename": "inline_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -448,14 +448,3 @@ def compile_function(code,arg_names,local_dict,global_dict,\n del sys.path[0]\n return func\n \n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n-if __name__ == \"__main__\":\n- test_function()\n-\n", "added_lines": 0, "deleted_lines": 11, "source_code": "# should re-write compiled functions to take a local and global dict\n# as input.\nimport sys,os\nimport ext_tools\nimport string\nimport catalog\nimport common_info\n\n# not an easy way for the user_path_list to come in here.\n# the PYTHONCOMPILED environment variable offers the most hope.\n\nfunction_catalog = catalog.catalog()\n\n\nclass inline_ext_function(ext_tools.ext_function):\n # Some specialization is needed for inline extension functions\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n\n This code got a lot uglier when I added local_dict...\n \"\"\"\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py__locals = NULL;\\n' \\\n 'PyObject *py__globals = NULL;\\n'\n\n py_objects = ', '.join(self.arg_specs.py_pointers())\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n else:\n declare_py_objects = ''\n\n py_vars = ' = '.join(self.arg_specs.py_variables())\n if py_vars:\n init_values = py_vars + ' = NULL;\\n\\n'\n else:\n init_values = ''\n\n parse_tuple = 'if(!PyArg_ParseTuple(args,\"OO:compiled_func\",'\\\n '&py__locals,'\\\n '&py__globals))\\n'\\\n ' return NULL;\\n'\n\n return declare_return + declare_py_objects + \\\n init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code(inline=1))\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.cleanup_code())\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n\n\n def function_code(self):\n from ext_tools import indent\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n #local_dict_code = indent(self.arg_local_dict_code(),4)\n\n try_code = 'try \\n' \\\n '{ \\n' \\\n ' PyObject* raw_locals = py_to_raw_dict(' \\\n 'py__locals,\"_locals\");\\n' \\\n ' PyObject* raw_globals = py_to_raw_dict(' \\\n 'py__globals,\"_globals\");\\n' + \\\n ' /* argument conversion code */ \\n' + \\\n decl_code + \\\n ' /* inline code */ \\n' + \\\n function_code + \\\n ' /*I would like to fill in changed ' \\\n 'locals and globals here...*/ \\n' \\\n '\\n} \\n'\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\" \n return_code = \" /* cleanup code */ \\n\" + \\\n cleanup_code + \\\n \" if(!(PyObject*)return_val && !exception_occured)\\n\" \\\n \" {\\n \\n\" \\\n \" return_val = Py_None; \\n\" \\\n \" }\\n \\n\" \\\n \" return return_val.disown(); \\n\" \\\n \"} \\n\"\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS},\\n' % args\n return function_decls\n\nclass inline_ext_module(ext_tools.ext_module):\n def __init__(self,name,compiler=''):\n ext_tools.ext_module.__init__(self,name,compiler)\n self._build_information.append(common_info.inline_info())\n\nfunction_cache = {}\ndef inline(code,arg_names=[],local_dict = None, global_dict = None,\n force = 0,\n compiler='',\n verbose = 0,\n support_code = None,\n headers = [],\n customize=None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n \"\"\" Inline C/C++ code within Python scripts.\n\n inline() compiles and executes C/C++ code on the fly. Variables\n in the local and global Python scope are also available in the\n C/C++ code. Values are passed to the C/C++ code by assignment\n much like variables passed are passed into a standard Python\n function. Values are returned from the C/C++ code through a\n special argument called return_val. Also, the contents of\n mutable objects can be changed within the C/C++ code and the\n changes remain after the C code exits and returns to Python.\n\n inline has quite a few options as listed below. Also, the keyword\n arguments for distutils extension modules are accepted to\n specify extra information needed for compiling.\n\n code -- string. A string of valid C++ code. It should not specify a\n return statement. Instead it should assign results that\n need to be returned to Python in the return_val.\n arg_names -- optional. list of strings. A list of Python variable names \n that should be transferred from Python into the C/C++ \n code. It defaults to an empty string.\n local_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the local scope for the\n C/C++ code. If local_dict is not specified the local\n dictionary of the calling function is used.\n global_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the global scope for\n the C/C++ code. If global_dict is not specified the\n global dictionary of the calling function is used.\n force -- optional. 0 or 1. default 0. If 1, the C++ code is\n compiled every time inline is called. This is really\n only useful for debugging, and probably only useful if\n your editing support_code a lot.\n compiler -- optional. string. The name of compiler to use when\n compiling. On windows, it understands 'msvc' and 'gcc'\n as well as all the compiler names understood by\n distutils. On Unix, it'll only understand the values\n understoof by distutils. ( I should add 'gcc' though\n to this).\n\n On windows, the compiler defaults to the Microsoft C++\n compiler. If this isn't available, it looks for mingw32\n (the gcc compiler).\n\n On Unix, it'll probably use the same compiler that was\n used when compiling Python. Cygwin's behavior should be\n similar.\n verbose -- optional. 0,1, or 2. defualt 0. Speficies how much\n much information is printed during the compile phase\n of inlining code. 0 is silent (except on windows with\n msvc where it still prints some garbage). 1 informs\n you when compiling starts, finishes, and how long it\n took. 2 prints out the command lines for the compilation\n process and can be useful if your having problems\n getting code to work. Its handy for finding the name\n of the .cpp file if you need to examine it. verbose has\n no affect if the compilation isn't necessary.\n support_code -- optional. string. A string of valid C++ code declaring\n extra code that might be needed by your compiled\n function. This could be declarations of functions,\n classes, or structures.\n headers -- optional. list of strings. A list of strings specifying\n header files to use when compiling the code. The list \n might look like [\"\",\"'my_header'\"]. Note that \n the header strings need to be in a form than can be \n pasted at the end of a #include statement in the \n C++ code.\n customize -- optional. base_info.custom_info object. An alternative\n way to specifiy support_code, headers, etc. needed by\n the function see the compiler.base_info module for more\n details. (not sure this'll be used much).\n type_converters -- optional. list of type converters. These\n guys are what convert Python data types to C/C++ data\n types. If you'd like to use a different set of type\n conversions than the default, specify them here. Look\n in the type conversions section of the main\n documentation for examples.\n auto_downcast -- optional. 0 or 1. default 1. This only affects\n functions that have Numeric arrays as input variables.\n Setting this to 1 will cause all floating point values\n to be cast as float instead of double if all the\n Numeric arrays are of type float. If even one of the\n arrays has type double or double complex, all\n variables maintain there standard types.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n\n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list\n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability)\n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line)\n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n global function_catalog\n\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if force:\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n headers = headers,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n else:\n # 1. try local cache\n try:\n results = apply(function_cache[code],(local_dict,global_dict))\n return results\n except TypeError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg\n except KeyError:\n pass\n # 2. try function catalog\n try:\n results = attempt_function_call(code,local_dict,global_dict)\n # 3. build the function\n except ValueError:\n # compile the library\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n headers = headers,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n return results\n\ndef attempt_function_call(code,local_dict,global_dict):\n # we try 3 levels here -- a local cache first, then the\n # catalog cache, and then persistent catalog.\n #\n global function_cache\n # 2. try catalog cache.\n function_list = function_catalog.get_functions_fast(code)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except TypeError, msg: # should specify argument types here.\n # This should really have its own error type, instead of\n # checking the beginning of the message, but I don't know\n # how to define that yet.\n msg = str(msg)\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg \n # 3. try persistent catalog\n module_dir = global_dict.get('__file__',None)\n function_list = function_catalog.get_functions(code,module_dir)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except: # should specify argument types here.\n pass\n # if we get here, the function wasn't found\n raise ValueError, 'function with correct signature not found'\n\ndef inline_function_code(code,arg_names,local_dict=None,\n global_dict=None,auto_downcast = 1,\n type_converters=None,compiler=''):\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n import build_tools\n compiler = build_tools.choose_compiler(compiler)\n ext_func.set_compiler(compiler)\n return ext_func.function_code()\n\ndef compile_function(code,arg_names,local_dict,global_dict,\n module_dir,\n compiler='',\n verbose = 0,\n support_code = None,\n headers = [],\n customize = None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n # figure out where to store and what to name the extension module\n # that will contain the function.\n #storage_dir = catalog.intermediate_dir()\n module_path = function_catalog.unique_module_name(code,module_dir)\n storage_dir, module_name = os.path.split(module_path)\n mod = inline_ext_module(module_name,compiler)\n\n # create the function. This relies on the auto_downcast and\n # type factories setting\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n mod.add_function(ext_func)\n\n # if customize (a custom_info object), then set the module customization.\n if customize:\n mod.customize = customize\n\n # add the extra \"support code\" needed by the function to the module.\n if support_code:\n mod.customize.add_support_code(support_code)\n \n # add the extra headers needed by the function to the module.\n for header in headers:\n mod.customize.add_header(header)\n \n # compile code in correct location, with the given compiler and verbosity\n # setting. All input keywords are passed through to distutils\n mod.compile(location=storage_dir,compiler=compiler,\n verbose=verbose, **kw)\n\n # import the module and return the function. Make sure\n # the directory where it lives is in the python path.\n try:\n sys.path.insert(0,storage_dir)\n exec 'import ' + module_name\n func = eval(module_name+'.compiled_func')\n finally:\n del sys.path[0]\n return func\n\n", "source_code_before": "# should re-write compiled functions to take a local and global dict\n# as input.\nimport sys,os\nimport ext_tools\nimport string\nimport catalog\nimport common_info\n\n# not an easy way for the user_path_list to come in here.\n# the PYTHONCOMPILED environment variable offers the most hope.\n\nfunction_catalog = catalog.catalog()\n\n\nclass inline_ext_function(ext_tools.ext_function):\n # Some specialization is needed for inline extension functions\n def function_declaration_code(self):\n code = 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def template_declaration_code(self):\n code = 'template\\n' \\\n 'static PyObject* %s(PyObject*self, PyObject* args)\\n{\\n'\n return code % self.name\n\n def parse_tuple_code(self):\n \"\"\" Create code block for PyArg_ParseTuple. Variable declarations\n for all PyObjects are done also.\n\n This code got a lot uglier when I added local_dict...\n \"\"\"\n declare_return = 'py::object return_val;\\n' \\\n 'int exception_occured = 0;\\n' \\\n 'PyObject *py__locals = NULL;\\n' \\\n 'PyObject *py__globals = NULL;\\n'\n\n py_objects = ', '.join(self.arg_specs.py_pointers())\n if py_objects:\n declare_py_objects = 'PyObject ' + py_objects +';\\n'\n else:\n declare_py_objects = ''\n\n py_vars = ' = '.join(self.arg_specs.py_variables())\n if py_vars:\n init_values = py_vars + ' = NULL;\\n\\n'\n else:\n init_values = ''\n\n parse_tuple = 'if(!PyArg_ParseTuple(args,\"OO:compiled_func\",'\\\n '&py__locals,'\\\n '&py__globals))\\n'\\\n ' return NULL;\\n'\n\n return declare_return + declare_py_objects + \\\n init_values + parse_tuple\n\n def arg_declaration_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.declaration_code(inline=1))\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_cleanup_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.cleanup_code())\n code = string.join(arg_strings,\"\")\n return code\n\n def arg_local_dict_code(self):\n arg_strings = []\n for arg in self.arg_specs:\n arg_strings.append(arg.local_dict_code())\n code = string.join(arg_strings,\"\")\n return code\n\n\n def function_code(self):\n from ext_tools import indent\n decl_code = indent(self.arg_declaration_code(),4)\n cleanup_code = indent(self.arg_cleanup_code(),4)\n function_code = indent(self.code_block,4)\n #local_dict_code = indent(self.arg_local_dict_code(),4)\n\n try_code = 'try \\n' \\\n '{ \\n' \\\n ' PyObject* raw_locals = py_to_raw_dict(' \\\n 'py__locals,\"_locals\");\\n' \\\n ' PyObject* raw_globals = py_to_raw_dict(' \\\n 'py__globals,\"_globals\");\\n' + \\\n ' /* argument conversion code */ \\n' + \\\n decl_code + \\\n ' /* inline code */ \\n' + \\\n function_code + \\\n ' /*I would like to fill in changed ' \\\n 'locals and globals here...*/ \\n' \\\n '\\n} \\n'\n catch_code = \"catch(...) \\n\" \\\n \"{ \\n\" + \\\n \" return_val = py::object(); \\n\" \\\n \" exception_occured = 1; \\n\" \\\n \"} \\n\" \n return_code = \" /* cleanup code */ \\n\" + \\\n cleanup_code + \\\n \" if(!(PyObject*)return_val && !exception_occured)\\n\" \\\n \" {\\n \\n\" \\\n \" return_val = Py_None; \\n\" \\\n \" }\\n \\n\" \\\n \" return return_val.disown(); \\n\" \\\n \"} \\n\"\n\n all_code = self.function_declaration_code() + \\\n indent(self.parse_tuple_code(),4) + \\\n indent(try_code,4) + \\\n indent(catch_code,4) + \\\n return_code\n\n return all_code\n\n def python_function_definition_code(self):\n args = (self.name, self.name)\n function_decls = '{\"%s\",(PyCFunction)%s , METH_VARARGS},\\n' % args\n return function_decls\n\nclass inline_ext_module(ext_tools.ext_module):\n def __init__(self,name,compiler=''):\n ext_tools.ext_module.__init__(self,name,compiler)\n self._build_information.append(common_info.inline_info())\n\nfunction_cache = {}\ndef inline(code,arg_names=[],local_dict = None, global_dict = None,\n force = 0,\n compiler='',\n verbose = 0,\n support_code = None,\n headers = [],\n customize=None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n \"\"\" Inline C/C++ code within Python scripts.\n\n inline() compiles and executes C/C++ code on the fly. Variables\n in the local and global Python scope are also available in the\n C/C++ code. Values are passed to the C/C++ code by assignment\n much like variables passed are passed into a standard Python\n function. Values are returned from the C/C++ code through a\n special argument called return_val. Also, the contents of\n mutable objects can be changed within the C/C++ code and the\n changes remain after the C code exits and returns to Python.\n\n inline has quite a few options as listed below. Also, the keyword\n arguments for distutils extension modules are accepted to\n specify extra information needed for compiling.\n\n code -- string. A string of valid C++ code. It should not specify a\n return statement. Instead it should assign results that\n need to be returned to Python in the return_val.\n arg_names -- optional. list of strings. A list of Python variable names \n that should be transferred from Python into the C/C++ \n code. It defaults to an empty string.\n local_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the local scope for the\n C/C++ code. If local_dict is not specified the local\n dictionary of the calling function is used.\n global_dict -- optional. dictionary. If specified, it is a dictionary\n of values that should be used as the global scope for\n the C/C++ code. If global_dict is not specified the\n global dictionary of the calling function is used.\n force -- optional. 0 or 1. default 0. If 1, the C++ code is\n compiled every time inline is called. This is really\n only useful for debugging, and probably only useful if\n your editing support_code a lot.\n compiler -- optional. string. The name of compiler to use when\n compiling. On windows, it understands 'msvc' and 'gcc'\n as well as all the compiler names understood by\n distutils. On Unix, it'll only understand the values\n understoof by distutils. ( I should add 'gcc' though\n to this).\n\n On windows, the compiler defaults to the Microsoft C++\n compiler. If this isn't available, it looks for mingw32\n (the gcc compiler).\n\n On Unix, it'll probably use the same compiler that was\n used when compiling Python. Cygwin's behavior should be\n similar.\n verbose -- optional. 0,1, or 2. defualt 0. Speficies how much\n much information is printed during the compile phase\n of inlining code. 0 is silent (except on windows with\n msvc where it still prints some garbage). 1 informs\n you when compiling starts, finishes, and how long it\n took. 2 prints out the command lines for the compilation\n process and can be useful if your having problems\n getting code to work. Its handy for finding the name\n of the .cpp file if you need to examine it. verbose has\n no affect if the compilation isn't necessary.\n support_code -- optional. string. A string of valid C++ code declaring\n extra code that might be needed by your compiled\n function. This could be declarations of functions,\n classes, or structures.\n headers -- optional. list of strings. A list of strings specifying\n header files to use when compiling the code. The list \n might look like [\"\",\"'my_header'\"]. Note that \n the header strings need to be in a form than can be \n pasted at the end of a #include statement in the \n C++ code.\n customize -- optional. base_info.custom_info object. An alternative\n way to specifiy support_code, headers, etc. needed by\n the function see the compiler.base_info module for more\n details. (not sure this'll be used much).\n type_converters -- optional. list of type converters. These\n guys are what convert Python data types to C/C++ data\n types. If you'd like to use a different set of type\n conversions than the default, specify them here. Look\n in the type conversions section of the main\n documentation for examples.\n auto_downcast -- optional. 0 or 1. default 1. This only affects\n functions that have Numeric arrays as input variables.\n Setting this to 1 will cause all floating point values\n to be cast as float instead of double if all the\n Numeric arrays are of type float. If even one of the\n arrays has type double or double complex, all\n variables maintain there standard types.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n\n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list\n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability)\n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line)\n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n global function_catalog\n\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n if force:\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n headers = headers,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n else:\n # 1. try local cache\n try:\n results = apply(function_cache[code],(local_dict,global_dict))\n return results\n except TypeError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg\n except KeyError:\n pass\n # 2. try function catalog\n try:\n results = attempt_function_call(code,local_dict,global_dict)\n # 3. build the function\n except ValueError:\n # compile the library\n module_dir = global_dict.get('__file__',None)\n func = compile_function(code,arg_names,local_dict,\n global_dict,module_dir,\n compiler=compiler,\n verbose=verbose,\n support_code = support_code,\n headers = headers,\n customize=customize,\n type_converters = type_converters,\n auto_downcast = auto_downcast,\n **kw)\n\n function_catalog.add_function(code,func,module_dir)\n results = attempt_function_call(code,local_dict,global_dict)\n return results\n\ndef attempt_function_call(code,local_dict,global_dict):\n # we try 3 levels here -- a local cache first, then the\n # catalog cache, and then persistent catalog.\n #\n global function_cache\n # 2. try catalog cache.\n function_list = function_catalog.get_functions_fast(code)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except TypeError, msg: # should specify argument types here.\n # This should really have its own error type, instead of\n # checking the beginning of the message, but I don't know\n # how to define that yet.\n msg = str(msg)\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise TypeError, msg\n except NameError, msg: \n msg = str(msg).strip()\n if msg[:16] == \"Conversion Error\":\n pass\n else:\n raise NameError, msg \n # 3. try persistent catalog\n module_dir = global_dict.get('__file__',None)\n function_list = function_catalog.get_functions(code,module_dir)\n for func in function_list:\n try:\n results = apply(func,(local_dict,global_dict))\n function_catalog.fast_cache(code,func)\n function_cache[code] = func\n return results\n except: # should specify argument types here.\n pass\n # if we get here, the function wasn't found\n raise ValueError, 'function with correct signature not found'\n\ndef inline_function_code(code,arg_names,local_dict=None,\n global_dict=None,auto_downcast = 1,\n type_converters=None,compiler=''):\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n import build_tools\n compiler = build_tools.choose_compiler(compiler)\n ext_func.set_compiler(compiler)\n return ext_func.function_code()\n\ndef compile_function(code,arg_names,local_dict,global_dict,\n module_dir,\n compiler='',\n verbose = 0,\n support_code = None,\n headers = [],\n customize = None,\n type_converters = None,\n auto_downcast=1,\n **kw):\n # figure out where to store and what to name the extension module\n # that will contain the function.\n #storage_dir = catalog.intermediate_dir()\n module_path = function_catalog.unique_module_name(code,module_dir)\n storage_dir, module_name = os.path.split(module_path)\n mod = inline_ext_module(module_name,compiler)\n\n # create the function. This relies on the auto_downcast and\n # type factories setting\n ext_func = inline_ext_function('compiled_func',code,arg_names,\n local_dict,global_dict,auto_downcast,\n type_converters = type_converters)\n mod.add_function(ext_func)\n\n # if customize (a custom_info object), then set the module customization.\n if customize:\n mod.customize = customize\n\n # add the extra \"support code\" needed by the function to the module.\n if support_code:\n mod.customize.add_support_code(support_code)\n \n # add the extra headers needed by the function to the module.\n for header in headers:\n mod.customize.add_header(header)\n \n # compile code in correct location, with the given compiler and verbosity\n # setting. All input keywords are passed through to distutils\n mod.compile(location=storage_dir,compiler=compiler,\n verbose=verbose, **kw)\n\n # import the module and return the function. Make sure\n # the directory where it lives is in the python path.\n try:\n sys.path.insert(0,storage_dir)\n exec 'import ' + module_name\n func = eval(module_name+'.compiled_func')\n finally:\n del sys.path[0]\n return func\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n test_function()\n\n", "methods": [ { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 17, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "inline_tools.py", "nloc": 21, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 26, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 57, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 64, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "inline_tools.py", "nloc": 37, "complexity": 1, "token_count": 146, "parameters": [ "self" ], "start_line": 79, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 121, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 35, "parameters": [ "self", "name", "compiler" ], "start_line": 127, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "inline", "long_name": "inline( code , arg_names = [ ] , local_dict = None , global_dict = None , force = 0 , compiler = '' , verbose = 0 , support_code = None , headers = [ ] , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 65, "complexity": 10, "token_count": 343, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "force", "compiler", "verbose", "support_code", "headers", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 132, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 209, "top_nesting_level": 0 }, { "name": "attempt_function_call", "long_name": "attempt_function_call( code , local_dict , global_dict )", "filename": "inline_tools.py", "nloc": 32, "complexity": 8, "token_count": 174, "parameters": [ "code", "local_dict", "global_dict" ], "start_line": 342, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "inline_function_code", "long_name": "inline_function_code( code , arg_names , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None , compiler = '' )", "filename": "inline_tools.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "auto_downcast", "type_converters", "compiler" ], "start_line": 384, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "compile_function", "long_name": "compile_function( code , arg_names , local_dict , global_dict , module_dir , compiler = '' , verbose = 0 , support_code = None , headers = [ ] , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 32, "complexity": 5, "token_count": 187, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "module_dir", "compiler", "verbose", "support_code", "headers", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 400, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 } ], "methods_before": [ { "name": "function_declaration_code", "long_name": "function_declaration_code( self )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 17, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "template_declaration_code", "long_name": "template_declaration_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "parse_tuple_code", "long_name": "parse_tuple_code( self )", "filename": "inline_tools.py", "nloc": 21, "complexity": 3, "token_count": 89, "parameters": [ "self" ], "start_line": 26, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "arg_declaration_code", "long_name": "arg_declaration_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 41, "parameters": [ "self" ], "start_line": 57, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_cleanup_code", "long_name": "arg_cleanup_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 64, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "arg_local_dict_code", "long_name": "arg_local_dict_code( self )", "filename": "inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self" ], "start_line": 71, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "function_code", "long_name": "function_code( self )", "filename": "inline_tools.py", "nloc": 37, "complexity": 1, "token_count": 146, "parameters": [ "self" ], "start_line": 79, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 1 }, { "name": "python_function_definition_code", "long_name": "python_function_definition_code( self )", "filename": "inline_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 121, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , name , compiler = '' )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 35, "parameters": [ "self", "name", "compiler" ], "start_line": 127, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "inline", "long_name": "inline( code , arg_names = [ ] , local_dict = None , global_dict = None , force = 0 , compiler = '' , verbose = 0 , support_code = None , headers = [ ] , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 65, "complexity": 10, "token_count": 343, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "force", "compiler", "verbose", "support_code", "headers", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 132, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 209, "top_nesting_level": 0 }, { "name": "attempt_function_call", "long_name": "attempt_function_call( code , local_dict , global_dict )", "filename": "inline_tools.py", "nloc": 32, "complexity": 8, "token_count": 174, "parameters": [ "code", "local_dict", "global_dict" ], "start_line": 342, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 0 }, { "name": "inline_function_code", "long_name": "inline_function_code( code , arg_names , local_dict = None , global_dict = None , auto_downcast = 1 , type_converters = None , compiler = '' )", "filename": "inline_tools.py", "nloc": 15, "complexity": 3, "token_count": 98, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "auto_downcast", "type_converters", "compiler" ], "start_line": 384, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "compile_function", "long_name": "compile_function( code , arg_names , local_dict , global_dict , module_dir , compiler = '' , verbose = 0 , support_code = None , headers = [ ] , customize = None , type_converters = None , auto_downcast = 1 , ** kw )", "filename": "inline_tools.py", "nloc": 32, "complexity": 5, "token_count": 187, "parameters": [ "code", "arg_names", "local_dict", "global_dict", "module_dir", "compiler", "verbose", "support_code", "headers", "customize", "type_converters", "auto_downcast", "kw" ], "start_line": 400, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 50, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 451, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 455, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 455, "end_line": 457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "inline_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 451, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 243, "complexity": 40, "token_count": 1294, "diff_parsed": { "added": [], "deleted": [ "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "", "if __name__ == \"__main__\":", " test_function()", "" ] } }, { "old_path": "weave/setup_weave.py", "new_path": "weave/setup_weave.py", "filename": "setup_weave.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -4,9 +4,9 @@\n from glob import glob\n from scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n \n-def configuration(parent_package=''):\n+def configuration(parent_package='',parent_path2=None):\n parent_path = parent_package\n- local_path = get_path(__name__)\n+ local_path = get_path(__name__,parent_path2)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package='',parent_path2=None):\n parent_path = parent_package\n local_path = get_path(__name__,parent_path2)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n local_path = get_path(__name__)\n config = default_config_dict('weave',parent_package)\n config['packages'].append(dot_join(parent_package,'weave.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['weave.tests'] = test_path\n \n scxx_files = glob(os.path.join(local_path,'scxx','*.*'))\n install_path = os.path.join(parent_path,'weave','scxx')\n config['data_files'].extend( [(install_path,scxx_files)])\n \n blitz_files = glob(os.path.join(local_path,'blitz-20001213','blitz','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz')\n config['data_files'].extend( [(install_path,blitz_files)])\n \n array_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'array','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','array')\n config['data_files'].extend( [(install_path,array_files)])\n \n meta_files = glob(os.path.join(local_path,'blitz-20001213','blitz',\n 'meta','*.*'))\n install_path = os.path.join(parent_path,'weave','blitz-20001213',\n 'blitz','meta')\n config['data_files'].extend( [(install_path,meta_files)])\n\n swig_files = glob(os.path.join(local_path,'swig','*.c'))\n install_path = os.path.join(parent_path,'weave','swig')\n config['data_files'].extend( [(install_path,swig_files)])\n\n doc_files = glob(os.path.join(local_path,'doc','*.html'))\n install_path = os.path.join(parent_path,'weave','doc')\n config['data_files'].extend( [(install_path,doc_files)])\n\n example_files = glob(os.path.join(local_path,'examples','*.py'))\n install_path = os.path.join(parent_path,'weave','examples')\n config['data_files'].extend( [(install_path,example_files)])\n \n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path2 = None )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 409, "parameters": [ "parent_package", "parent_path2" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path2 = None )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 409, "parameters": [ "parent_package", "parent_path2" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_weave.py", "nloc": 34, "complexity": 1, "token_count": 403, "parameters": [ "parent_package" ], "start_line": 7, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "nloc": 40, "complexity": 1, "token_count": 444, "diff_parsed": { "added": [ "def configuration(parent_package='',parent_path2=None):", " local_path = get_path(__name__,parent_path2)" ], "deleted": [ "def configuration(parent_package=''):", " local_path = get_path(__name__)" ] } }, { "old_path": "weave/size_check.py", "new_path": "weave/size_check.py", "filename": "size_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -282,12 +282,3 @@ def reduction(ary,axis=0):\n # so this is gonna take some thought (probably some tree manipulation).\n def take(ary,axis=0): raise NotImplemented\n # and all the rest\n- \n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n- \n", "added_lines": 0, "deleted_lines": 9, "source_code": "from Numeric import *\n\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n\nfrom ast_tools import *\nfrom types import *\nimport sys\n\ndef time_it():\n import time\n \n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\" \\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n ex = ones((10,10,10),typecode=Float32)\n ca_x = ones((10,10,10),typecode=Float32)\n cb_y_x = ones((10,10,10),typecode=Float32)\n cb_z_x = ones((10,10,10),typecode=Float32)\n hz = ones((10,10,10),typecode=Float32)\n hy = ones((10,10,10),typecode=Float32)\n \n N = 1\n t1 = time.time()\n for i in range(N):\n passed = check_expr(expr,locals())\n t2 = time.time()\n print 'time per call:', (t2 - t1)/N\n print 'passed:', passed\n \ndef check_expr(expr,local_vars,global_vars={}):\n \"\"\" Currently only checks expressions (not suites).\n Doesn't check that lhs = rhs. checked by compiled func though\n \"\"\"\n values ={}\n \n #first handle the globals\n for var,val in global_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n #now handle the locals \n for var,val in local_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n exec(expr,values)\n try:\n exec(expr,values)\n except:\n try:\n eval(expr,values)\n except:\n return 0 \n return 1 \n \nempty = array(())\nempty_slice = slice(None)\n\ndef make_same_length(x,y):\n try:\n Nx = len(x)\n except:\n Nx = 0\n try:\n Ny = len(y)\n except:\n Ny = 0\n if Nx == Ny == 0:\n return empty,empty\n elif Nx == Ny:\n return asarray(x),asarray(y)\n else: \n diff = abs(Nx - Ny)\n front = ones(diff,Int)\n if Nx > Ny:\n return asarray(x), concatenate((front,y))\n elif Ny > Nx:\n return concatenate((front,x)),asarray(y) \n\ndef binary_op_size(xx,yy):\n \"\"\" This returns the resulting size from operating on xx, and yy\n with a binary operator. It accounts for broadcasting, and\n throws errors if the array sizes are incompatible.\n \"\"\"\n x,y = make_same_length(xx,yy)\n res = zeros(len(x))\n for i in range(len(x)):\n if x[i] == y[i]:\n res[i] = x[i]\n elif x[i] == 1:\n res[i] = y[i]\n elif y[i] == 1:\n res[i] = x[i]\n else:\n # offer more information here about which variables.\n raise ValueError, \"frames are not aligned\"\n return res \nclass dummy_array:\n def __init__(self,ary,ary_is_shape = 0,name=None):\n self.name = name\n if ary_is_shape:\n self.shape = ary\n #self.shape = asarray(ary)\n else:\n try:\n self.shape = shape(ary)\n except:\n self.shape = empty\n #self.value = ary \n def binary_op(self,other):\n try: \n x = other.shape\n except AttributeError:\n x = empty \n new_shape = binary_op_size(self.shape,x)\n return dummy_array(new_shape,1)\n def __cmp__(self,other):\n # This isn't an exact compare, but does work for == \n # cluge for Numeric\n if type(other) in [IntType,LongType,FloatType,ComplexType]:\n return 0\n if len(self.shape) == len(other.shape) == 0:\n return 0\n return not alltrue(equal(self.shape,other.shape))\n\n def __add__(self,other): return self.binary_op(other)\n def __radd__(self,other): return self.binary_op(other)\n def __sub__(self,other): return self.binary_op(other)\n def __rsub__(self,other): return self.binary_op(other)\n def __mul__(self,other): return self.binary_op(other)\n def __rmul__(self,other): return self.binary_op(other)\n def __div__(self,other): return self.binary_op(other)\n def __rdiv__(self,other): return self.binary_op(other)\n def __mod__(self,other): return self.binary_op(other)\n def __rmod__(self,other): return self.binary_op(other)\n def __lshift__(self,other): return self.binary_op(other)\n def __rshift__(self,other): return self.binary_op(other)\n # unary ops\n def __neg__(self,other): return self\n def __pos__(self,other): return self\n def __abs__(self,other): return self\n def __invert__(self,other): return self \n # Not sure what to do with coersion ops. Ignore for now.\n #\n # not currently supported by compiler.\n # __divmod__\n # __pow__\n # __rpow__\n # __and__\n # __or__\n # __xor__\n # item access and slicing \n def __setitem__(self,indices,val):\n #ignore for now\n pass\n def __len__(self):\n return self.shape[0]\n def __getslice__(self,i,j):\n # enabling the following would make class compatible with\n # lists. Its current incarnation is compatible with arrays.\n # Both this and Numeric should have this FIXED to correspond\n # to lists.\n #i = max(i, 0); j = max(j, 0)\n return self.__getitem__((slice(i,j),))\n def __getitem__(self,indices):\n # ayeyaya this is a mess\n #print indices, type(indices), indices.shape \n if type(indices) is not TupleType:\n indices = (indices,)\n if Ellipsis in indices:\n raise IndexError, \"Ellipsis not currently supported\"\n new_dims = [] \n dim = 0 \n for index in indices:\n try:\n dim_len = self.shape[dim]\n except IndexError:\n raise IndexError, \"To many indices specified\"\n \n #if (type(index) is SliceType and index.start == index.stop == index.step):\n if (index is empty_slice):\n slc_len = dim_len\n elif type(index) is SliceType:\n beg,end,step = index.start,index.stop,index.step \n # handle if they are dummy arrays\n #if hasattr(beg,'value') and type(beg.value) != ArrayType:\n # beg = beg.value\n #if hasattr(end,'value') and type(end.value) != ArrayType:\n # end = end.value\n #if hasattr(step,'value') and type(step.value) != ArrayType:\n # step = step.value \n if beg is None: beg = 0\n if end == sys.maxint or end is None:\n end = dim_len\n if step is None: \n step = 1\n \n if beg < 0: beg += dim_len\n if end < 0: end += dim_len\n # the following is list like behavior,\n # which isn't adhered to by arrays. \n # FIX THIS ANOMOLY IN NUMERIC!\n if beg < 0: beg = 0\n if beg > dim_len: beg = dim_len\n if end < 0: end = 0\n if end > dim_len: end = dim_len\n # This is rubbish. \n if beg == end:\n beg,end,step = 0,0,1\n elif beg >= dim_len and step > 0:\n beg,end,step = 0,0,1\n #elif index.step > 0 and beg <= end:\n elif step > 0 and beg <= end:\n pass #slc_len = abs(divide(end-beg-1,step)+1) \n # handle [::-1] and [-1::-1] correctly \n #elif index.step > 0 and beg > end:\n elif step > 0 and beg > end:\n beg,end,step = 0,0,1\n elif(step < 0 and index.start is None and index.stop is None):\n beg,end,step = 0,dim_len,-step\n elif(step < 0 and index.start is None):\n # +1 because negative stepping is inclusive\n beg,end,step = end+1,dim_len,-step \n elif(step < 0 and index.stop is None):\n beg,end,step = 0,beg+1,-step\n elif(step < 0 and beg > end): \n beg,end,step = end,beg,-step\n elif(step < 0 and beg < end): \n beg,end,step = 0,0,-step\n slc_len = abs(divide(end-beg-1,step)+1)\n new_dims.append(slc_len)\n else:\n if index < 0: index += dim_len\n if index >=0 and index < dim_len:\n #this reduces the array dimensions by one\n pass\n else:\n raise IndexError, \"Index out of range\" \n dim += 1 \n new_dims.extend(self.shape[dim:])\n if 0 in new_dims:\n raise IndexError, \"Zero length slices not currently supported\"\n return dummy_array(new_dims,1)\n def __repr__(self):\n val = str((self.name, str(self.shape)))\n return val \n\ndef unary(ary):\n return ary\n\ndef not_implemented(ary):\n return ary\n \n#all imported from Numeric and need to be reassigned.\nunary_op = [arccos, arcsin, arctan, cos, cosh, sin, sinh, \n exp,ceil,floor,fabs,log,log10,sqrt]\n\nunsupported = [argmin,argmax, argsort,around, absolute,sign,negative,floor]\n\nfor func in unary_op:\n func = unary\n \nfor func in unsupported:\n func = not_implemented\n \ndef reduction(ary,axis=0):\n if axis < 0:\n axis += len(ary.shape) \n if axis < 0 or axis >= len(ary.shape):\n raise ValueError, \"Dimension not in array\" \n new_dims = list(ary.shape[:axis]) + list(ary.shape[axis+1:])\n return dummy_array(new_dims,1) \n\n# functions currently not supported by compiler\n# reductions are gonna take some array reordering for the general case,\n# so this is gonna take some thought (probably some tree manipulation).\ndef take(ary,axis=0): raise NotImplemented\n# and all the rest\n", "source_code_before": "from Numeric import *\n\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n\nfrom ast_tools import *\nfrom types import *\nimport sys\n\ndef time_it():\n import time\n \n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\" \\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n ex = ones((10,10,10),typecode=Float32)\n ca_x = ones((10,10,10),typecode=Float32)\n cb_y_x = ones((10,10,10),typecode=Float32)\n cb_z_x = ones((10,10,10),typecode=Float32)\n hz = ones((10,10,10),typecode=Float32)\n hy = ones((10,10,10),typecode=Float32)\n \n N = 1\n t1 = time.time()\n for i in range(N):\n passed = check_expr(expr,locals())\n t2 = time.time()\n print 'time per call:', (t2 - t1)/N\n print 'passed:', passed\n \ndef check_expr(expr,local_vars,global_vars={}):\n \"\"\" Currently only checks expressions (not suites).\n Doesn't check that lhs = rhs. checked by compiled func though\n \"\"\"\n values ={}\n \n #first handle the globals\n for var,val in global_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n #now handle the locals \n for var,val in local_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n exec(expr,values)\n try:\n exec(expr,values)\n except:\n try:\n eval(expr,values)\n except:\n return 0 \n return 1 \n \nempty = array(())\nempty_slice = slice(None)\n\ndef make_same_length(x,y):\n try:\n Nx = len(x)\n except:\n Nx = 0\n try:\n Ny = len(y)\n except:\n Ny = 0\n if Nx == Ny == 0:\n return empty,empty\n elif Nx == Ny:\n return asarray(x),asarray(y)\n else: \n diff = abs(Nx - Ny)\n front = ones(diff,Int)\n if Nx > Ny:\n return asarray(x), concatenate((front,y))\n elif Ny > Nx:\n return concatenate((front,x)),asarray(y) \n\ndef binary_op_size(xx,yy):\n \"\"\" This returns the resulting size from operating on xx, and yy\n with a binary operator. It accounts for broadcasting, and\n throws errors if the array sizes are incompatible.\n \"\"\"\n x,y = make_same_length(xx,yy)\n res = zeros(len(x))\n for i in range(len(x)):\n if x[i] == y[i]:\n res[i] = x[i]\n elif x[i] == 1:\n res[i] = y[i]\n elif y[i] == 1:\n res[i] = x[i]\n else:\n # offer more information here about which variables.\n raise ValueError, \"frames are not aligned\"\n return res \nclass dummy_array:\n def __init__(self,ary,ary_is_shape = 0,name=None):\n self.name = name\n if ary_is_shape:\n self.shape = ary\n #self.shape = asarray(ary)\n else:\n try:\n self.shape = shape(ary)\n except:\n self.shape = empty\n #self.value = ary \n def binary_op(self,other):\n try: \n x = other.shape\n except AttributeError:\n x = empty \n new_shape = binary_op_size(self.shape,x)\n return dummy_array(new_shape,1)\n def __cmp__(self,other):\n # This isn't an exact compare, but does work for == \n # cluge for Numeric\n if type(other) in [IntType,LongType,FloatType,ComplexType]:\n return 0\n if len(self.shape) == len(other.shape) == 0:\n return 0\n return not alltrue(equal(self.shape,other.shape))\n\n def __add__(self,other): return self.binary_op(other)\n def __radd__(self,other): return self.binary_op(other)\n def __sub__(self,other): return self.binary_op(other)\n def __rsub__(self,other): return self.binary_op(other)\n def __mul__(self,other): return self.binary_op(other)\n def __rmul__(self,other): return self.binary_op(other)\n def __div__(self,other): return self.binary_op(other)\n def __rdiv__(self,other): return self.binary_op(other)\n def __mod__(self,other): return self.binary_op(other)\n def __rmod__(self,other): return self.binary_op(other)\n def __lshift__(self,other): return self.binary_op(other)\n def __rshift__(self,other): return self.binary_op(other)\n # unary ops\n def __neg__(self,other): return self\n def __pos__(self,other): return self\n def __abs__(self,other): return self\n def __invert__(self,other): return self \n # Not sure what to do with coersion ops. Ignore for now.\n #\n # not currently supported by compiler.\n # __divmod__\n # __pow__\n # __rpow__\n # __and__\n # __or__\n # __xor__\n # item access and slicing \n def __setitem__(self,indices,val):\n #ignore for now\n pass\n def __len__(self):\n return self.shape[0]\n def __getslice__(self,i,j):\n # enabling the following would make class compatible with\n # lists. Its current incarnation is compatible with arrays.\n # Both this and Numeric should have this FIXED to correspond\n # to lists.\n #i = max(i, 0); j = max(j, 0)\n return self.__getitem__((slice(i,j),))\n def __getitem__(self,indices):\n # ayeyaya this is a mess\n #print indices, type(indices), indices.shape \n if type(indices) is not TupleType:\n indices = (indices,)\n if Ellipsis in indices:\n raise IndexError, \"Ellipsis not currently supported\"\n new_dims = [] \n dim = 0 \n for index in indices:\n try:\n dim_len = self.shape[dim]\n except IndexError:\n raise IndexError, \"To many indices specified\"\n \n #if (type(index) is SliceType and index.start == index.stop == index.step):\n if (index is empty_slice):\n slc_len = dim_len\n elif type(index) is SliceType:\n beg,end,step = index.start,index.stop,index.step \n # handle if they are dummy arrays\n #if hasattr(beg,'value') and type(beg.value) != ArrayType:\n # beg = beg.value\n #if hasattr(end,'value') and type(end.value) != ArrayType:\n # end = end.value\n #if hasattr(step,'value') and type(step.value) != ArrayType:\n # step = step.value \n if beg is None: beg = 0\n if end == sys.maxint or end is None:\n end = dim_len\n if step is None: \n step = 1\n \n if beg < 0: beg += dim_len\n if end < 0: end += dim_len\n # the following is list like behavior,\n # which isn't adhered to by arrays. \n # FIX THIS ANOMOLY IN NUMERIC!\n if beg < 0: beg = 0\n if beg > dim_len: beg = dim_len\n if end < 0: end = 0\n if end > dim_len: end = dim_len\n # This is rubbish. \n if beg == end:\n beg,end,step = 0,0,1\n elif beg >= dim_len and step > 0:\n beg,end,step = 0,0,1\n #elif index.step > 0 and beg <= end:\n elif step > 0 and beg <= end:\n pass #slc_len = abs(divide(end-beg-1,step)+1) \n # handle [::-1] and [-1::-1] correctly \n #elif index.step > 0 and beg > end:\n elif step > 0 and beg > end:\n beg,end,step = 0,0,1\n elif(step < 0 and index.start is None and index.stop is None):\n beg,end,step = 0,dim_len,-step\n elif(step < 0 and index.start is None):\n # +1 because negative stepping is inclusive\n beg,end,step = end+1,dim_len,-step \n elif(step < 0 and index.stop is None):\n beg,end,step = 0,beg+1,-step\n elif(step < 0 and beg > end): \n beg,end,step = end,beg,-step\n elif(step < 0 and beg < end): \n beg,end,step = 0,0,-step\n slc_len = abs(divide(end-beg-1,step)+1)\n new_dims.append(slc_len)\n else:\n if index < 0: index += dim_len\n if index >=0 and index < dim_len:\n #this reduces the array dimensions by one\n pass\n else:\n raise IndexError, \"Index out of range\" \n dim += 1 \n new_dims.extend(self.shape[dim:])\n if 0 in new_dims:\n raise IndexError, \"Zero length slices not currently supported\"\n return dummy_array(new_dims,1)\n def __repr__(self):\n val = str((self.name, str(self.shape)))\n return val \n\ndef unary(ary):\n return ary\n\ndef not_implemented(ary):\n return ary\n \n#all imported from Numeric and need to be reassigned.\nunary_op = [arccos, arcsin, arctan, cos, cosh, sin, sinh, \n exp,ceil,floor,fabs,log,log10,sqrt]\n\nunsupported = [argmin,argmax, argsort,around, absolute,sign,negative,floor]\n\nfor func in unary_op:\n func = unary\n \nfor func in unsupported:\n func = not_implemented\n \ndef reduction(ary,axis=0):\n if axis < 0:\n axis += len(ary.shape) \n if axis < 0 or axis >= len(ary.shape):\n raise ValueError, \"Dimension not in array\" \n new_dims = list(ary.shape[:axis]) + list(ary.shape[axis+1:])\n return dummy_array(new_dims,1) \n\n# functions currently not supported by compiler\n# reductions are gonna take some array reordering for the general case,\n# so this is gonna take some thought (probably some tree manipulation).\ndef take(ary,axis=0): raise NotImplemented\n# and all the rest\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n \n", "methods": [ { "name": "time_it", "long_name": "time_it( )", "filename": "size_check.py", "nloc": 18, "complexity": 2, "token_count": 158, "parameters": [], "start_line": 13, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_expr", "long_name": "check_expr( expr , local_vars , global_vars = { } )", "filename": "size_check.py", "nloc": 21, "complexity": 9, "token_count": 159, "parameters": [ "expr", "local_vars", "global_vars" ], "start_line": 34, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "make_same_length", "long_name": "make_same_length( x , y )", "filename": "size_check.py", "nloc": 20, "complexity": 7, "token_count": 115, "parameters": [ "x", "y" ], "start_line": 65, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "binary_op_size", "long_name": "binary_op_size( xx , yy )", "filename": "size_check.py", "nloc": 13, "complexity": 5, "token_count": 100, "parameters": [ "xx", "yy" ], "start_line": 86, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , ary , ary_is_shape = 0 , name = None )", "filename": "size_check.py", "nloc": 9, "complexity": 3, "token_count": 47, "parameters": [ "self", "ary", "ary_is_shape", "name" ], "start_line": 105, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "binary_op", "long_name": "binary_op( self , other )", "filename": "size_check.py", "nloc": 7, "complexity": 2, "token_count": 37, "parameters": [ "self", "other" ], "start_line": 116, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "size_check.py", "nloc": 6, "complexity": 3, "token_count": 59, "parameters": [ "self", "other" ], "start_line": 123, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , indices , val )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self", "indices", "val" ], "start_line": 159, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 162, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , i , j )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self", "i", "j" ], "start_line": 164, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , indices )", "filename": "size_check.py", "nloc": 58, "complexity": 39, "token_count": 450, "parameters": [ "self", "indices" ], "start_line": 171, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 79, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "size_check.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 250, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "unary", "long_name": "unary( ary )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "ary" ], "start_line": 254, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "not_implemented", "long_name": "not_implemented( ary )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "ary" ], "start_line": 257, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "reduction", "long_name": "reduction( ary , axis = 0 )", "filename": "size_check.py", "nloc": 7, "complexity": 4, "token_count": 72, "parameters": [ "ary", "axis" ], "start_line": 272, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 } ], "methods_before": [ { "name": "time_it", "long_name": "time_it( )", "filename": "size_check.py", "nloc": 18, "complexity": 2, "token_count": 158, "parameters": [], "start_line": 13, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_expr", "long_name": "check_expr( expr , local_vars , global_vars = { } )", "filename": "size_check.py", "nloc": 21, "complexity": 9, "token_count": 159, "parameters": [ "expr", "local_vars", "global_vars" ], "start_line": 34, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "make_same_length", "long_name": "make_same_length( x , y )", "filename": "size_check.py", "nloc": 20, "complexity": 7, "token_count": 115, "parameters": [ "x", "y" ], "start_line": 65, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "binary_op_size", "long_name": "binary_op_size( xx , yy )", "filename": "size_check.py", "nloc": 13, "complexity": 5, "token_count": 100, "parameters": [ "xx", "yy" ], "start_line": 86, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , ary , ary_is_shape = 0 , name = None )", "filename": "size_check.py", "nloc": 9, "complexity": 3, "token_count": 47, "parameters": [ "self", "ary", "ary_is_shape", "name" ], "start_line": 105, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "binary_op", "long_name": "binary_op( self , other )", "filename": "size_check.py", "nloc": 7, "complexity": 2, "token_count": 37, "parameters": [ "self", "other" ], "start_line": 116, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "size_check.py", "nloc": 6, "complexity": 3, "token_count": 59, "parameters": [ "self", "other" ], "start_line": 123, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , indices , val )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self", "indices", "val" ], "start_line": 159, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 162, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getslice__", "long_name": "__getslice__( self , i , j )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 24, "parameters": [ "self", "i", "j" ], "start_line": 164, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , indices )", "filename": "size_check.py", "nloc": 58, "complexity": 39, "token_count": 450, "parameters": [ "self", "indices" ], "start_line": 171, "end_line": 249, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 79, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "size_check.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 250, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "unary", "long_name": "unary( ary )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "ary" ], "start_line": 254, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "not_implemented", "long_name": "not_implemented( ary )", "filename": "size_check.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "ary" ], "start_line": 257, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "reduction", "long_name": "reduction( ary , axis = 0 )", "filename": "size_check.py", "nloc": 7, "complexity": 4, "token_count": 72, "parameters": [ "ary", "axis" ], "start_line": 272, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "size_check.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "size_check.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 290, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "size_check.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 290, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "size_check.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 207, "complexity": 80, "token_count": 1635, "diff_parsed": { "added": [], "deleted": [ "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "" ] } }, { "old_path": "weave/slice_handler.py", "new_path": "weave/slice_handler.py", "filename": "slice_handler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -153,14 +153,3 @@ def transform_slices(ast_list):\n (token.RSQB, ']')\n )\n )\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\n-if __name__ == \"__main__\": \n- test()\n\\ No newline at end of file\n", "added_lines": 0, "deleted_lines": 11, "source_code": "import pprint\nimport string\nfrom ast_tools import * \n\ndef slice_ast_to_dict(ast_seq):\n sl_vars = {}\n if type(ast_seq) in (ListType,TupleType):\n for pattern in slice_patterns:\n found,data = match(pattern,ast_seq)\n if found: \n sl_vars = {'begin':'_beg',\n 'end':'_end', \n 'step':'_stp',\n 'single_index':'_index'}\n for key in data.keys():\n data[key] = ast_to_string(data[key])\n sl_vars.update(data)\n break; \n return sl_vars\n \ndef build_slice_atom(slice_vars, position):\n # Note: This produces slices that are incorrect for Python\n # evaluation because of slicing being exclusive in Python\n # and inclusive for blitz on the top end of the range.\n # This difference should really be handle in a blitz specific transform,\n # but I've put it here for convenience. This doesn't cause any\n # problems in code, its just a maintance hassle (I'll forget I did it here)\n # and inelegant. *FIX ME*.\n \n \n ###########################################################################\n # Handling negative indices.\n #\n # Range indices that begin with a negative sign, '-', are assumed to be\n # negative. Blitz++ interprets negative indices differently than \n # Python. To correct this, we subtract negative indices from the length\n # of the array (at run-time). If indices do not start with a negative \n # sign, they are assumed to be positive.\n #\n # This scheme doesn't work in the general case. For example, if you\n # are calculating negative indices from a math expression that doesn't\n # start with the negative sign, then it will be assumed positive and\n # hence generate wrong results (and maybe a seg-fault).\n # \n # I think this case can might be remedied by calculating all ranges on\n # the fly, and then subtracting them from the length of the array in \n # that dimension if they are negative. This is major code bloat in the\n # funcitons and more work. Save till later...\n ###########################################################################\n # I don't think the strip is necessary, but it insures\n # that '-' is the first sign for negative indices.\n if slice_vars['single_index'] != '_index':\n expr = '%(single_index)s' % slice_vars \n else: \n begin = string.strip(slice_vars['begin'])\n if begin[0] == '-':\n slice_vars['begin'] = 'N' + slice_vars['var']+`position`+begin;\n \n end = string.strip(slice_vars['end'])\n if end != '_end' and end[0] != '-':\n #compensate for blitz using inclusive indexing on top end \n #of slice for positive indices.\n slice_vars['end'] = end + '-1'\n if end[0] == '-':\n slice_vars['end'] = 'N%s[%d]%s-1' % (slice_vars['var'],position,end)\n \n if slice_vars['step'] == '_stp':\n # this if/then isn't strictly necessary, it'll\n # just keep the output code a little cleaner\n expr = 'slice(%(begin)s,%(end)s)' % slice_vars \n else: \n expr = 'slice(%(begin)s,%(end)s,%(step)s)' % slice_vars \n val = atom_list(expr)\n return val\n\ndef transform_subscript_list(subscript_dict):\n # this is gonna edit the ast_list... \n subscript_list = subscript_dict['subscript_list']\n\n var = subscript_dict['var']\n #skip the first entry (the subscript_list symbol)\n slice_position = -1\n for i in range(1,len(subscript_list)):\n #skip commas...\n if subscript_list[i][0] != token.COMMA:\n slice_position += 1\n slice_vars = slice_ast_to_dict(subscript_list[i])\n\n slice_vars['var'] = var\n # create a slice(b,e,s) atom and insert in \n # place of the x:y:z atom in the tree. \n subscript_list[i] = build_slice_atom(slice_vars, slice_position)\n \ndef harvest_subscript_dicts(ast_list):\n \"\"\" Needs Tests!\n \"\"\"\n subscript_lists = []\n if type(ast_list) == ListType:\n found,data = match(indexed_array_pattern,ast_list)\n # data is a dict with 'var' = variable name\n # and 'subscript_list' = to the ast_seq for the subscript list\n if found:\n subscript_lists.append(data)\n for item in ast_list:\n if type(item) == ListType:\n subscript_lists.extend(harvest_subscript_dicts(item))\n return subscript_lists\n\ndef transform_slices(ast_list):\n \"\"\" Walk through an ast_list converting all x:y:z subscripts\n to slice(x,y,z) subscripts.\n \"\"\"\n all_dicts = harvest_subscript_dicts(ast_list)\n for subscript_dict in all_dicts:\n transform_subscript_list(subscript_dict)\n\nslice_patterns = []\nCLN = (token.COLON,':')\nCLN2= (symbol.sliceop, (token.COLON, ':'))\nCLN2_STEP = (symbol.sliceop, (token.COLON, ':'),['step'])\n# [begin:end:step]\nslice_patterns.append((symbol.subscript, ['begin'],CLN,['end'], CLN2_STEP ))\n# [:end:step]\nslice_patterns.append((symbol.subscript, CLN,['end'], CLN2_STEP ))\n# [begin::step]\nslice_patterns.append((symbol.subscript, ['begin'],CLN, CLN2_STEP ))\n# [begin:end:]\nslice_patterns.append((symbol.subscript, ['begin'],CLN,['end'], CLN2 ))\n# [begin::]\nslice_patterns.append((symbol.subscript, ['begin'],CLN, CLN2 ))\n# [:end:]\nslice_patterns.append((symbol.subscript, CLN,['end'], CLN2, ))\n# [::step]\nslice_patterns.append((symbol.subscript, CLN, CLN2_STEP ))\n# [::]\nslice_patterns.append((symbol.subscript, CLN, CLN2 ))\n\n# begin:end variants\nslice_patterns.append((symbol.subscript, ['begin'],CLN,['end']))\nslice_patterns.append((symbol.subscript, CLN,['end']))\nslice_patterns.append((symbol.subscript, ['begin'],CLN))\nslice_patterns.append((symbol.subscript, CLN)) \n\n# a[0] variant -- can't believe I left this out...\nslice_patterns.append((symbol.subscript,['single_index'])) \n\nindexed_array_pattern = \\\n (symbol.power,\n (symbol.atom,(token.NAME, ['var'])),\n (symbol.trailer,\n (token.LSQB, '['),\n ['subscript_list'],\n (token.RSQB, ']')\n )\n )\n", "source_code_before": "import pprint\nimport string\nfrom ast_tools import * \n\ndef slice_ast_to_dict(ast_seq):\n sl_vars = {}\n if type(ast_seq) in (ListType,TupleType):\n for pattern in slice_patterns:\n found,data = match(pattern,ast_seq)\n if found: \n sl_vars = {'begin':'_beg',\n 'end':'_end', \n 'step':'_stp',\n 'single_index':'_index'}\n for key in data.keys():\n data[key] = ast_to_string(data[key])\n sl_vars.update(data)\n break; \n return sl_vars\n \ndef build_slice_atom(slice_vars, position):\n # Note: This produces slices that are incorrect for Python\n # evaluation because of slicing being exclusive in Python\n # and inclusive for blitz on the top end of the range.\n # This difference should really be handle in a blitz specific transform,\n # but I've put it here for convenience. This doesn't cause any\n # problems in code, its just a maintance hassle (I'll forget I did it here)\n # and inelegant. *FIX ME*.\n \n \n ###########################################################################\n # Handling negative indices.\n #\n # Range indices that begin with a negative sign, '-', are assumed to be\n # negative. Blitz++ interprets negative indices differently than \n # Python. To correct this, we subtract negative indices from the length\n # of the array (at run-time). If indices do not start with a negative \n # sign, they are assumed to be positive.\n #\n # This scheme doesn't work in the general case. For example, if you\n # are calculating negative indices from a math expression that doesn't\n # start with the negative sign, then it will be assumed positive and\n # hence generate wrong results (and maybe a seg-fault).\n # \n # I think this case can might be remedied by calculating all ranges on\n # the fly, and then subtracting them from the length of the array in \n # that dimension if they are negative. This is major code bloat in the\n # funcitons and more work. Save till later...\n ###########################################################################\n # I don't think the strip is necessary, but it insures\n # that '-' is the first sign for negative indices.\n if slice_vars['single_index'] != '_index':\n expr = '%(single_index)s' % slice_vars \n else: \n begin = string.strip(slice_vars['begin'])\n if begin[0] == '-':\n slice_vars['begin'] = 'N' + slice_vars['var']+`position`+begin;\n \n end = string.strip(slice_vars['end'])\n if end != '_end' and end[0] != '-':\n #compensate for blitz using inclusive indexing on top end \n #of slice for positive indices.\n slice_vars['end'] = end + '-1'\n if end[0] == '-':\n slice_vars['end'] = 'N%s[%d]%s-1' % (slice_vars['var'],position,end)\n \n if slice_vars['step'] == '_stp':\n # this if/then isn't strictly necessary, it'll\n # just keep the output code a little cleaner\n expr = 'slice(%(begin)s,%(end)s)' % slice_vars \n else: \n expr = 'slice(%(begin)s,%(end)s,%(step)s)' % slice_vars \n val = atom_list(expr)\n return val\n\ndef transform_subscript_list(subscript_dict):\n # this is gonna edit the ast_list... \n subscript_list = subscript_dict['subscript_list']\n\n var = subscript_dict['var']\n #skip the first entry (the subscript_list symbol)\n slice_position = -1\n for i in range(1,len(subscript_list)):\n #skip commas...\n if subscript_list[i][0] != token.COMMA:\n slice_position += 1\n slice_vars = slice_ast_to_dict(subscript_list[i])\n\n slice_vars['var'] = var\n # create a slice(b,e,s) atom and insert in \n # place of the x:y:z atom in the tree. \n subscript_list[i] = build_slice_atom(slice_vars, slice_position)\n \ndef harvest_subscript_dicts(ast_list):\n \"\"\" Needs Tests!\n \"\"\"\n subscript_lists = []\n if type(ast_list) == ListType:\n found,data = match(indexed_array_pattern,ast_list)\n # data is a dict with 'var' = variable name\n # and 'subscript_list' = to the ast_seq for the subscript list\n if found:\n subscript_lists.append(data)\n for item in ast_list:\n if type(item) == ListType:\n subscript_lists.extend(harvest_subscript_dicts(item))\n return subscript_lists\n\ndef transform_slices(ast_list):\n \"\"\" Walk through an ast_list converting all x:y:z subscripts\n to slice(x,y,z) subscripts.\n \"\"\"\n all_dicts = harvest_subscript_dicts(ast_list)\n for subscript_dict in all_dicts:\n transform_subscript_list(subscript_dict)\n\nslice_patterns = []\nCLN = (token.COLON,':')\nCLN2= (symbol.sliceop, (token.COLON, ':'))\nCLN2_STEP = (symbol.sliceop, (token.COLON, ':'),['step'])\n# [begin:end:step]\nslice_patterns.append((symbol.subscript, ['begin'],CLN,['end'], CLN2_STEP ))\n# [:end:step]\nslice_patterns.append((symbol.subscript, CLN,['end'], CLN2_STEP ))\n# [begin::step]\nslice_patterns.append((symbol.subscript, ['begin'],CLN, CLN2_STEP ))\n# [begin:end:]\nslice_patterns.append((symbol.subscript, ['begin'],CLN,['end'], CLN2 ))\n# [begin::]\nslice_patterns.append((symbol.subscript, ['begin'],CLN, CLN2 ))\n# [:end:]\nslice_patterns.append((symbol.subscript, CLN,['end'], CLN2, ))\n# [::step]\nslice_patterns.append((symbol.subscript, CLN, CLN2_STEP ))\n# [::]\nslice_patterns.append((symbol.subscript, CLN, CLN2 ))\n\n# begin:end variants\nslice_patterns.append((symbol.subscript, ['begin'],CLN,['end']))\nslice_patterns.append((symbol.subscript, CLN,['end']))\nslice_patterns.append((symbol.subscript, ['begin'],CLN))\nslice_patterns.append((symbol.subscript, CLN)) \n\n# a[0] variant -- can't believe I left this out...\nslice_patterns.append((symbol.subscript,['single_index'])) \n\nindexed_array_pattern = \\\n (symbol.power,\n (symbol.atom,(token.NAME, ['var'])),\n (symbol.trailer,\n (token.LSQB, '['),\n ['subscript_list'],\n (token.RSQB, ']')\n )\n )\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\": \n test()", "methods": [ { "name": "slice_ast_to_dict", "long_name": "slice_ast_to_dict( ast_seq )", "filename": "slice_handler.py", "nloc": 15, "complexity": 5, "token_count": 89, "parameters": [ "ast_seq" ], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "build_slice_atom", "long_name": "build_slice_atom( slice_vars , position )", "filename": "slice_handler.py", "nloc": 18, "complexity": 7, "token_count": 143, "parameters": [ "slice_vars", "position" ], "start_line": 21, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 0 }, { "name": "transform_subscript_list", "long_name": "transform_subscript_list( subscript_dict )", "filename": "slice_handler.py", "nloc": 10, "complexity": 3, "token_count": 76, "parameters": [ "subscript_dict" ], "start_line": 76, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "harvest_subscript_dicts", "long_name": "harvest_subscript_dicts( ast_list )", "filename": "slice_handler.py", "nloc": 10, "complexity": 5, "token_count": 61, "parameters": [ "ast_list" ], "start_line": 94, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "transform_slices", "long_name": "transform_slices( ast_list )", "filename": "slice_handler.py", "nloc": 4, "complexity": 2, "token_count": 21, "parameters": [ "ast_list" ], "start_line": 109, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 } ], "methods_before": [ { "name": "slice_ast_to_dict", "long_name": "slice_ast_to_dict( ast_seq )", "filename": "slice_handler.py", "nloc": 15, "complexity": 5, "token_count": 89, "parameters": [ "ast_seq" ], "start_line": 5, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "build_slice_atom", "long_name": "build_slice_atom( slice_vars , position )", "filename": "slice_handler.py", "nloc": 18, "complexity": 7, "token_count": 143, "parameters": [ "slice_vars", "position" ], "start_line": 21, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 0 }, { "name": "transform_subscript_list", "long_name": "transform_subscript_list( subscript_dict )", "filename": "slice_handler.py", "nloc": 10, "complexity": 3, "token_count": 76, "parameters": [ "subscript_dict" ], "start_line": 76, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "harvest_subscript_dicts", "long_name": "harvest_subscript_dicts( ast_list )", "filename": "slice_handler.py", "nloc": 10, "complexity": 5, "token_count": 61, "parameters": [ "ast_list" ], "start_line": 94, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "transform_slices", "long_name": "transform_slices( ast_list )", "filename": "slice_handler.py", "nloc": 4, "complexity": 2, "token_count": 21, "parameters": [ "ast_list" ], "start_line": 109, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "slice_handler.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 157, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "slice_handler.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "slice_handler.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 161, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "slice_handler.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 157, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 86, "complexity": 22, "token_count": 723, "diff_parsed": { "added": [], "deleted": [ "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "", "if __name__ == \"__main__\":", " test()" ] } }, { "old_path": "weave/standard_array_spec.py", "new_path": "weave/standard_array_spec.py", "filename": "standard_array_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -155,11 +155,3 @@ def declaration_code(self,templatize = 0,inline=0):\n '%(num_type)s* %(name)s = (%(num_type)s*) %(array_name)s->data;\\n' \n code = code % self.template_vars(inline=inline)\n return code\n-\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n", "added_lines": 0, "deleted_lines": 8, "source_code": "from c_spec import common_base_converter\nfrom c_spec import num_to_c_types\nfrom Numeric import *\nfrom types import *\nimport os\n\n\nnum_typecode = {}\nnum_typecode['c'] = 'PyArray_CHAR'\nnum_typecode['1'] = 'PyArray_SBYTE'\nnum_typecode['b'] = 'PyArray_UBYTE'\nnum_typecode['s'] = 'PyArray_SHORT'\nnum_typecode['w'] = 'PyArray_USHORT'\nnum_typecode['i'] = 'PyArray_INT' # PyArray_INT has troubles ?? What does this note mean ??\nnum_typecode['u'] = 'PyArray_UINT'\nnum_typecode['l'] = 'PyArray_LONG'\nnum_typecode['f'] = 'PyArray_FLOAT'\nnum_typecode['d'] = 'PyArray_DOUBLE'\nnum_typecode['F'] = 'PyArray_CFLOAT'\nnum_typecode['D'] = 'PyArray_CDOUBLE'\n\ntype_check_code = \\\n\"\"\"\nclass numpy_type_handler\n{\npublic:\n void conversion_numpy_check_type(PyArrayObject* arr_obj, int numeric_type,\n const char* name)\n {\n // Make sure input has correct numeric type.\n // allow character and byte to match\n // also allow int and long to match\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n\n char* type_names[20] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \"unsigned short\",\n \"int\", \"unsigned int\", \"long\", \"float\", \"double\", \n \"complex float\",\"complex double\", \"object\",\"ntype\",\n \"unkown\"};\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n \n void numpy_check_type(PyArrayObject* arr_obj, int numeric_type, const char* name)\n {\n // Make sure input has correct numeric type.\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n char* type_names[20] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \n \"unsigned short\", \"int\", \"unsigned int\",\n \"long\", \"float\", \"double\", \n \"complex float\", \"complex double\", \n \"object\",\"ntype\",\"unkown\"};\n char msg[500];\n sprintf(msg,\"received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n};\n\nnumpy_type_handler x__numpy_type_handler = numpy_type_handler();\n#define conversion_numpy_check_type x__numpy_type_handler.conversion_numpy_check_type\n#define numpy_check_type x__numpy_type_handler.numpy_check_type\n\n\"\"\"\n\nsize_check_code = \\\n\"\"\"\nclass numpy_size_handler\n{\npublic:\n void conversion_numpy_check_size(PyArrayObject* arr_obj, int Ndims, \n const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n \n void numpy_check_size(PyArrayObject* arr_obj, int Ndims, const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n};\n\nnumpy_size_handler x__numpy_size_handler = numpy_size_handler();\n#define conversion_numpy_check_size x__numpy_size_handler.conversion_numpy_check_size\n#define numpy_check_size x__numpy_size_handler.numpy_check_size\n\n\"\"\"\n\nnumeric_init_code = \\\n\"\"\"\nPy_Initialize();\nimport_array();\nPyImport_ImportModule(\"Numeric\");\n\"\"\"\n \nclass array_converter(common_base_converter):\n\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'numpy'\n self.check_func = 'PyArray_Check' \n self.c_type = 'PyArrayObject*'\n self.return_type = 'PyArrayObject*'\n self.to_c_return = '(PyArrayObject*) py_obj'\n self.matching_types = [ArrayType]\n self.headers = ['\"Numeric/arrayobject.h\"','','']\n self.support_code = [size_check_code, type_check_code]\n self.module_init_code = [numeric_init_code] \n \n def get_var_type(self,value):\n return value.typecode()\n \n def template_vars(self,inline=0):\n res = common_base_converter.template_vars(self,inline) \n if hasattr(self,'var_type'):\n res['num_type'] = num_to_c_types[self.var_type]\n res['num_typecode'] = num_typecode[self.var_type]\n res['array_name'] = self.name + \"_array\"\n return res\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(array_name)s = %(var_convert)s;\\n' \\\n 'conversion_numpy_check_type(%(array_name)s,%(num_typecode)s,\"%(name)s\");\\n' \\\n 'int* N%(name)s = %(array_name)s->dimensions;\\n' \\\n 'int* S%(name)s = %(array_name)s->strides;\\n' \\\n 'int D%(name)s = %(array_name)s->nd;\\n' \\\n '%(num_type)s* %(name)s = (%(num_type)s*) %(array_name)s->data;\\n' \n code = code % self.template_vars(inline=inline)\n return code\n", "source_code_before": "from c_spec import common_base_converter\nfrom c_spec import num_to_c_types\nfrom Numeric import *\nfrom types import *\nimport os\n\n\nnum_typecode = {}\nnum_typecode['c'] = 'PyArray_CHAR'\nnum_typecode['1'] = 'PyArray_SBYTE'\nnum_typecode['b'] = 'PyArray_UBYTE'\nnum_typecode['s'] = 'PyArray_SHORT'\nnum_typecode['w'] = 'PyArray_USHORT'\nnum_typecode['i'] = 'PyArray_INT' # PyArray_INT has troubles ?? What does this note mean ??\nnum_typecode['u'] = 'PyArray_UINT'\nnum_typecode['l'] = 'PyArray_LONG'\nnum_typecode['f'] = 'PyArray_FLOAT'\nnum_typecode['d'] = 'PyArray_DOUBLE'\nnum_typecode['F'] = 'PyArray_CFLOAT'\nnum_typecode['D'] = 'PyArray_CDOUBLE'\n\ntype_check_code = \\\n\"\"\"\nclass numpy_type_handler\n{\npublic:\n void conversion_numpy_check_type(PyArrayObject* arr_obj, int numeric_type,\n const char* name)\n {\n // Make sure input has correct numeric type.\n // allow character and byte to match\n // also allow int and long to match\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n\n char* type_names[20] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \"unsigned short\",\n \"int\", \"unsigned int\", \"long\", \"float\", \"double\", \n \"complex float\",\"complex double\", \"object\",\"ntype\",\n \"unkown\"};\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n \n void numpy_check_type(PyArrayObject* arr_obj, int numeric_type, const char* name)\n {\n // Make sure input has correct numeric type.\n int arr_type = arr_obj->descr->type_num;\n if ( arr_type != numeric_type &&\n !(numeric_type == PyArray_CHAR && arr_type == PyArray_SBYTE) &&\n !(numeric_type == PyArray_SBYTE && arr_type == PyArray_CHAR) &&\n !(numeric_type == PyArray_INT && arr_type == PyArray_LONG) &&\n !(numeric_type == PyArray_LONG && arr_type == PyArray_INT)) \n {\n char* type_names[20] = {\"char\",\"unsigned byte\",\"byte\", \"short\", \n \"unsigned short\", \"int\", \"unsigned int\",\n \"long\", \"float\", \"double\", \n \"complex float\", \"complex double\", \n \"object\",\"ntype\",\"unkown\"};\n char msg[500];\n sprintf(msg,\"received '%s' typed array instead of '%s' typed array for variable '%s'\",\n type_names[arr_type],type_names[numeric_type],name);\n throw_error(PyExc_TypeError,msg); \n }\n }\n};\n\nnumpy_type_handler x__numpy_type_handler = numpy_type_handler();\n#define conversion_numpy_check_type x__numpy_type_handler.conversion_numpy_check_type\n#define numpy_check_type x__numpy_type_handler.numpy_check_type\n\n\"\"\"\n\nsize_check_code = \\\n\"\"\"\nclass numpy_size_handler\n{\npublic:\n void conversion_numpy_check_size(PyArrayObject* arr_obj, int Ndims, \n const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"Conversion Error: received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n \n void numpy_check_size(PyArrayObject* arr_obj, int Ndims, const char* name)\n {\n if (arr_obj->nd != Ndims)\n {\n char msg[500];\n sprintf(msg,\"received '%d' dimensional array instead of '%d' dimensional array for variable '%s'\",\n arr_obj->nd,Ndims,name);\n throw_error(PyExc_TypeError,msg);\n } \n }\n};\n\nnumpy_size_handler x__numpy_size_handler = numpy_size_handler();\n#define conversion_numpy_check_size x__numpy_size_handler.conversion_numpy_check_size\n#define numpy_check_size x__numpy_size_handler.numpy_check_size\n\n\"\"\"\n\nnumeric_init_code = \\\n\"\"\"\nPy_Initialize();\nimport_array();\nPyImport_ImportModule(\"Numeric\");\n\"\"\"\n \nclass array_converter(common_base_converter):\n\n def init_info(self):\n common_base_converter.init_info(self)\n self.type_name = 'numpy'\n self.check_func = 'PyArray_Check' \n self.c_type = 'PyArrayObject*'\n self.return_type = 'PyArrayObject*'\n self.to_c_return = '(PyArrayObject*) py_obj'\n self.matching_types = [ArrayType]\n self.headers = ['\"Numeric/arrayobject.h\"','','']\n self.support_code = [size_check_code, type_check_code]\n self.module_init_code = [numeric_init_code] \n \n def get_var_type(self,value):\n return value.typecode()\n \n def template_vars(self,inline=0):\n res = common_base_converter.template_vars(self,inline) \n if hasattr(self,'var_type'):\n res['num_type'] = num_to_c_types[self.var_type]\n res['num_typecode'] = num_typecode[self.var_type]\n res['array_name'] = self.name + \"_array\"\n return res\n \n def declaration_code(self,templatize = 0,inline=0):\n code = '%(py_var)s = %(var_lookup)s;\\n' \\\n '%(c_type)s %(array_name)s = %(var_convert)s;\\n' \\\n 'conversion_numpy_check_type(%(array_name)s,%(num_typecode)s,\"%(name)s\");\\n' \\\n 'int* N%(name)s = %(array_name)s->dimensions;\\n' \\\n 'int* S%(name)s = %(array_name)s->strides;\\n' \\\n 'int D%(name)s = %(array_name)s->nd;\\n' \\\n '%(num_type)s* %(name)s = (%(num_type)s*) %(array_name)s->data;\\n' \n code = code % self.template_vars(inline=inline)\n return code\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "methods": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "standard_array_spec.py", "nloc": 11, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 125, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "standard_array_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "value" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "self", "inline" ], "start_line": 140, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 10, "complexity": 1, "token_count": 42, "parameters": [ "self", "templatize", "inline" ], "start_line": 148, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "init_info", "long_name": "init_info( self )", "filename": "standard_array_spec.py", "nloc": 11, "complexity": 1, "token_count": 70, "parameters": [ "self" ], "start_line": 125, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "get_var_type", "long_name": "get_var_type( self , value )", "filename": "standard_array_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "value" ], "start_line": 137, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "template_vars", "long_name": "template_vars( self , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 7, "complexity": 2, "token_count": 61, "parameters": [ "self", "inline" ], "start_line": 140, "end_line": 146, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "declaration_code", "long_name": "declaration_code( self , templatize = 0 , inline = 0 )", "filename": "standard_array_spec.py", "nloc": 10, "complexity": 1, "token_count": 42, "parameters": [ "self", "templatize", "inline" ], "start_line": 148, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 159, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 163, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 159, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "nloc": 147, "complexity": 5, "token_count": 302, "diff_parsed": { "added": [], "deleted": [ "", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)" ] } }, { "old_path": "weave/tests/test_ast_tools.py", "new_path": "weave/tests/test_ast_tools.py", "filename": "test_ast_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,14 +8,12 @@\n import RandomArray\n import time\n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-from scipy_distutils.misc_util import add_local_to_path\n-\n-add_grandparent_to_path(__name__)\n-import ast_tools\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import ast_tools\n restore_path()\n \n-add_local_to_path(__name__)\n+set_local_path()\n from weave_test_utils import *\n restore_path()\n \n@@ -38,19 +36,5 @@ def check_simple_expr(self):\n desired = ['a','b','i'] \n self.generic_test(expr,desired)\n \n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_harvest_variables,'check_') )\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.ast_tools').run()\n", "added_lines": 5, "deleted_lines": 21, "source_code": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import ast_tools\nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_harvest_variables(unittest.TestCase):\n \"\"\" Not much testing going on here, but \n at least it is a flame test.\n \"\"\" \n def generic_test(self,expr,desired):\n import parser\n ast_list = parser.suite(expr).tolist()\n actual = ast_tools.harvest_variables(ast_list)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = ['a','b','i'] \n self.generic_test(expr,desired)\n\nif __name__ == \"__main__\":\n ScipyTest('weave.ast_tools').run()\n", "source_code_before": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ast_tools\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_harvest_variables(unittest.TestCase):\n \"\"\" Not much testing going on here, but \n at least it is a flame test.\n \"\"\" \n def generic_test(self,expr,desired):\n import parser\n ast_list = parser.suite(expr).tolist()\n actual = ast_tools.harvest_variables(ast_list)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = ['a','b','i'] \n self.generic_test(expr,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_harvest_variables,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "generic_test", "long_name": "generic_test( self , expr , desired )", "filename": "test_ast_tools.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "expr", "desired" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_ast_tools.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 30, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "methods_before": [ { "name": "generic_test", "long_name": "generic_test( self , expr , desired )", "filename": "test_ast_tools.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "expr", "desired" ], "start_line": 26, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_ast_tools.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 32, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ast_tools.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ast_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 49, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ast_tools.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 42, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ast_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 49, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 30, "complexity": 2, "token_count": 136, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import ast_tools", "set_local_path()", " ScipyTest('weave.ast_tools').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "from scipy_distutils.misc_util import add_local_to_path", "", "add_grandparent_to_path(__name__)", "import ast_tools", "add_local_to_path(__name__)", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_harvest_variables,'check_') )", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/tests/test_blitz_tools.py", "new_path": "weave/tests/test_blitz_tools.py", "filename": "test_blitz_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -9,12 +9,11 @@\n import os\n import time\n \n-from scipy_distutils.misc_util import add_grandparent_to_path,restore_path\n-from scipy_distutils.misc_util import add_local_to_path\n-\n-add_grandparent_to_path(__name__)\n-import blitz_tools\n-from ast_tools import *\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import blitz_tools\n+restore_path()\n+set_local_path()\n from weave_test_utils import *\n restore_path()\n \n@@ -139,21 +138,21 @@ def generic_2d(self,expr,typ):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n- def check_5point_avg_2d_float(self):\n+ def check_5point_avg_2d_float(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float32)\n- def check_5point_avg_2d_double(self):\n+ def check_5point_avg_2d_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float64)\n- def _check_5point_avg_2d_complex_float(self):\n+ def _check_5point_avg_2d_complex_float(self,level=10):\n \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave \n \n result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n@@ -170,28 +169,13 @@ def _check_5point_avg_2d_complex_float(self):\n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex32)\n- def check_5point_avg_2d_complex_double(self):\n+ def check_5point_avg_2d_complex_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex64)\n- \n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_ast_to_blitz_expr,'check_') )\n- if level >= 10:\n- suites.append( unittest.makeSuite(test_blitz,'check_') ) \n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n \n if __name__ == \"__main__\":\n- test(10)\n+ ScipyTest('weave.blitz_tools').run()\n", "added_lines": 10, "deleted_lines": 26, "source_code": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport os\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import blitz_tools\nrestore_path()\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_ast_to_blitz_expr(unittest.TestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(unittest.TestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr,typ):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d_float(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float32)\n def check_5point_avg_2d_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float64)\n def _check_5point_avg_2d_complex_float(self,level=10):\n \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave \n \n result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \n Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that \n 5. is a double and b is a complex32. blitz doesn't know \n how to handle complex32/double. See:\n http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php\n Unfortunately, the fix isn't trivial. Instead of fixing it, I\n prefer to wait until we replace blitz++ with Pat Miller's code \n that doesn't rely on blitz..\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex32)\n def check_5point_avg_2d_complex_double(self,level=10):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex64)\n\nif __name__ == \"__main__\":\n ScipyTest('weave.blitz_tools').run()\n", "source_code_before": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport os\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport blitz_tools\nfrom ast_tools import *\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_ast_to_blitz_expr(unittest.TestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(unittest.TestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr,typ):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d_float(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float32)\n def check_5point_avg_2d_double(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Float64)\n def _check_5point_avg_2d_complex_float(self):\n \"\"\" Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. It will not adversely affect 99.99 percent of weave \n \n result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \n Note: THIS TEST is KNOWN TO FAIL ON GCC 3.x. The reason is that \n 5. is a double and b is a complex32. blitz doesn't know \n how to handle complex32/double. See:\n http://www.oonumerics.org/MailArchives/blitz-support/msg00541.php\n Unfortunately, the fix isn't trivial. Instead of fixing it, I\n prefer to wait until we replace blitz++ with Pat Miller's code \n that doesn't rely on blitz..\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex32)\n def check_5point_avg_2d_complex_double(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr,Complex64)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_ast_to_blitz_expr,'check_') )\n if level >= 10:\n suites.append( unittest.makeSuite(test_blitz,'check_') ) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test(10)\n", "methods": [ { "name": "generic_test", "long_name": "generic_test( self , expr , desired )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 1, "token_count": 54, "parameters": [ "self", "expr", "desired" ], "start_line": 22, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 31, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_fdtd_expr", "long_name": "check_fdtd_expr( self )", "filename": "test_blitz_tools.py", "nloc": 14, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 41, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", "filename": "test_blitz_tools.py", "nloc": 27, "complexity": 2, "token_count": 227, "parameters": [ "self", "expr", "arg_dict", "type", "size", "mod_location" ], "start_line": 68, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr , typ )", "filename": "test_blitz_tools.py", "nloc": 33, "complexity": 6, "token_count": 239, "parameters": [ "self", "expr", "typ" ], "start_line": 100, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_float", "long_name": "check_5point_avg_2d_float( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_double", "long_name": "check_5point_avg_2d_double( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 148, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "_check_5point_avg_2d_complex_float", "long_name": "_check_5point_avg_2d_complex_float( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 155, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_complex_double", "long_name": "check_5point_avg_2d_complex_double( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 172, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "methods_before": [ { "name": "generic_test", "long_name": "generic_test( self , expr , desired )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 1, "token_count": 54, "parameters": [ "self", "expr", "desired" ], "start_line": 23, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 32, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_fdtd_expr", "long_name": "check_fdtd_expr( self )", "filename": "test_blitz_tools.py", "nloc": 14, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 42, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", "filename": "test_blitz_tools.py", "nloc": 27, "complexity": 2, "token_count": 227, "parameters": [ "self", "expr", "arg_dict", "type", "size", "mod_location" ], "start_line": 69, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr , typ )", "filename": "test_blitz_tools.py", "nloc": 33, "complexity": 6, "token_count": 239, "parameters": [ "self", "expr", "typ" ], "start_line": 101, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_float", "long_name": "check_5point_avg_2d_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_double", "long_name": "check_5point_avg_2d_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 149, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "_check_5point_avg_2d_complex_float", "long_name": "_check_5point_avg_2d_complex_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 156, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_complex_double", "long_name": "check_5point_avg_2d_complex_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 173, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "level" ], "start_line": 181, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 190, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_5point_avg_2d_complex_double", "long_name": "check_5point_avg_2d_complex_double( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 172, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_float", "long_name": "check_5point_avg_2d_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 142, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_double", "long_name": "check_5point_avg_2d_double( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 148, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_blitz_tools.py", "nloc": 8, "complexity": 3, "token_count": 57, "parameters": [ "level" ], "start_line": 181, "end_line": 188, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "check_5point_avg_2d_float", "long_name": "check_5point_avg_2d_float( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "_check_5point_avg_2d_complex_float", "long_name": "_check_5point_avg_2d_complex_float( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 156, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_blitz_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 190, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_5point_avg_2d_complex_double", "long_name": "check_5point_avg_2d_complex_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 173, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "_check_5point_avg_2d_complex_float", "long_name": "_check_5point_avg_2d_complex_float( self , level = 10 )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 23, "parameters": [ "self", "level" ], "start_line": 155, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_5point_avg_2d_double", "long_name": "check_5point_avg_2d_double( self )", "filename": "test_blitz_tools.py", "nloc": 4, "complexity": 1, "token_count": 19, "parameters": [ "self" ], "start_line": 149, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 } ], "nloc": 127, "complexity": 15, "token_count": 762, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import blitz_tools", "restore_path()", "set_local_path()", " def check_5point_avg_2d_float(self,level=10):", " def check_5point_avg_2d_double(self,level=10):", " def _check_5point_avg_2d_complex_float(self,level=10):", " def check_5point_avg_2d_complex_double(self,level=10):", " ScipyTest('weave.blitz_tools').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path,restore_path", "from scipy_distutils.misc_util import add_local_to_path", "", "add_grandparent_to_path(__name__)", "import blitz_tools", "from ast_tools import *", " def check_5point_avg_2d_float(self):", " def check_5point_avg_2d_double(self):", " def _check_5point_avg_2d_complex_float(self):", " def check_5point_avg_2d_complex_double(self):", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_ast_to_blitz_expr,'check_') )", " if level >= 10:", " suites.append( unittest.makeSuite(test_blitz,'check_') )", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", " test(10)" ] } }, { "old_path": "weave/tests/test_build_tools.py", "new_path": "weave/tests/test_build_tools.py", "filename": "test_build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,10 +5,9 @@\n import unittest\n import os, sys, tempfile\n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-\n-add_grandparent_to_path(__name__)\n-import build_tools\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import build_tools\n restore_path()\n \n def is_writable(val):\n@@ -63,21 +62,6 @@ def check_simple(self):\n argv.index('--compiler='+compiler)\n build_tools.restore_sys_argv()\n assert(pre_argv == sys.argv[:])\n- \n-def test_suite(level = 1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_configure_build_dir,'check_') )\n- suites.append( unittest.makeSuite(test_configure_temp_dir,'check_') )\n- suites.append( unittest.makeSuite(test_configure_sys_argv,'check_') )\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n \n if __name__ == \"__main__\":\n- test()\n\\ No newline at end of file\n+ ScipyTest('weave.build_tools').run()\n", "added_lines": 4, "deleted_lines": 20, "source_code": "# still needed\n# tests for MingW32Compiler\n# don't know how to test gcc_exists() and msvc_exists()...\n\nimport unittest\nimport os, sys, tempfile\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import build_tools\nrestore_path()\n\ndef is_writable(val):\n return os.access(val,os.W_OK)\n \nclass test_configure_build_dir(unittest.TestCase):\n def check_default(self):\n \" default behavior is to return current directory \"\n d = build_tools.configure_build_dir()\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d))\n def check_curdir(self):\n \" make sure it handles relative values. \"\n d = build_tools.configure_build_dir('.')\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d)) \n def check_pardir(self):\n \" make sure it handles relative values \" \n d = build_tools.configure_build_dir('..')\n if is_writable('..'):\n assert(d == os.path.abspath('..'))\n assert(is_writable(d)) \n def check_bad_path(self):\n \" bad path should return same as default (and warn) \"\n d = build_tools.configure_build_dir('_bad_path_')\n d2 = build_tools.configure_build_dir()\n assert(d == d2)\n assert(is_writable(d))\n\nclass test_configure_temp_dir(test_configure_build_dir):\n def check_default(self):\n \" default behavior returns tempdir\"\n # this'll fail if the temp directory isn't writable.\n d = build_tools.configure_temp_dir()\n assert(d == tempfile.gettempdir())\n assert(is_writable(d))\n\nclass test_configure_sys_argv(unittest.TestCase):\n def check_simple(self):\n build_dir = 'build_dir'\n temp_dir = 'temp_dir'\n compiler = 'compiler'\n pre_argv = sys.argv[:]\n build_tools.configure_sys_argv(compiler,temp_dir,build_dir)\n argv = sys.argv[:]\n bd = argv[argv.index('--build-lib')+1]\n assert(bd == build_dir)\n td = argv[argv.index('--build-temp')+1]\n assert(td == temp_dir)\n argv.index('--compiler='+compiler)\n build_tools.restore_sys_argv()\n assert(pre_argv == sys.argv[:])\n\nif __name__ == \"__main__\":\n ScipyTest('weave.build_tools').run()\n", "source_code_before": "# still needed\n# tests for MingW32Compiler\n# don't know how to test gcc_exists() and msvc_exists()...\n\nimport unittest\nimport os, sys, tempfile\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport build_tools\nrestore_path()\n\ndef is_writable(val):\n return os.access(val,os.W_OK)\n \nclass test_configure_build_dir(unittest.TestCase):\n def check_default(self):\n \" default behavior is to return current directory \"\n d = build_tools.configure_build_dir()\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d))\n def check_curdir(self):\n \" make sure it handles relative values. \"\n d = build_tools.configure_build_dir('.')\n if is_writable('.'):\n assert(d == os.path.abspath('.'))\n assert(is_writable(d)) \n def check_pardir(self):\n \" make sure it handles relative values \" \n d = build_tools.configure_build_dir('..')\n if is_writable('..'):\n assert(d == os.path.abspath('..'))\n assert(is_writable(d)) \n def check_bad_path(self):\n \" bad path should return same as default (and warn) \"\n d = build_tools.configure_build_dir('_bad_path_')\n d2 = build_tools.configure_build_dir()\n assert(d == d2)\n assert(is_writable(d))\n\nclass test_configure_temp_dir(test_configure_build_dir):\n def check_default(self):\n \" default behavior returns tempdir\"\n # this'll fail if the temp directory isn't writable.\n d = build_tools.configure_temp_dir()\n assert(d == tempfile.gettempdir())\n assert(is_writable(d))\n\nclass test_configure_sys_argv(unittest.TestCase):\n def check_simple(self):\n build_dir = 'build_dir'\n temp_dir = 'temp_dir'\n compiler = 'compiler'\n pre_argv = sys.argv[:]\n build_tools.configure_sys_argv(compiler,temp_dir,build_dir)\n argv = sys.argv[:]\n bd = argv[argv.index('--build-lib')+1]\n assert(bd == build_dir)\n td = argv[argv.index('--build-temp')+1]\n assert(td == temp_dir)\n argv.index('--compiler='+compiler)\n build_tools.restore_sys_argv()\n assert(pre_argv == sys.argv[:])\n \ndef test_suite(level = 1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_configure_build_dir,'check_') )\n suites.append( unittest.makeSuite(test_configure_temp_dir,'check_') )\n suites.append( unittest.makeSuite(test_configure_sys_argv,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()", "methods": [ { "name": "is_writable", "long_name": "is_writable( val )", "filename": "test_build_tools.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 13, "end_line": 14, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 17, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_curdir", "long_name": "check_curdir( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 23, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_pardir", "long_name": "check_pardir( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 29, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_build_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 43, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_build_tools.py", "nloc": 14, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 51, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 } ], "methods_before": [ { "name": "is_writable", "long_name": "is_writable( val )", "filename": "test_build_tools.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "val" ], "start_line": 14, "end_line": 15, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 18, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_curdir", "long_name": "check_curdir( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 24, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_pardir", "long_name": "check_pardir( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 2, "token_count": 40, "parameters": [ "self" ], "start_line": 30, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_build_tools.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 36, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_build_tools.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 44, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_build_tools.py", "nloc": 14, "complexity": 1, "token_count": 102, "parameters": [ "self" ], "start_line": 52, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_build_tools.py", "nloc": 8, "complexity": 2, "token_count": 65, "parameters": [ "level" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_build_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 76, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_build_tools.py", "nloc": 8, "complexity": 2, "token_count": 65, "parameters": [ "level" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_build_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 76, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 56, "complexity": 10, "token_count": 367, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import build_tools", " ScipyTest('weave.build_tools').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import build_tools", "", "def test_suite(level = 1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_configure_build_dir,'check_') )", " suites.append( unittest.makeSuite(test_configure_temp_dir,'check_') )", " suites.append( unittest.makeSuite(test_configure_sys_argv,'check_') )", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", " test()" ] } }, { "old_path": "weave/tests/test_c_spec.py", "new_path": "weave/tests/test_c_spec.py", "filename": "test_c_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,21 +5,18 @@\n # Note: test_dir is global to this file. \n # It is made by setup_test_location()\n \n-\n #globals\n global test_dir \n test_dir = ''\n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-\n-add_grandparent_to_path(__name__)\n-import inline_tools\n-import ext_tools\n-from catalog import unique_file\n-from build_tools import msvc_exists, gcc_exists\n-import c_spec\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import inline_tools,ext_tools,c_spec\n+from weave.build_tools import msvc_exists, gcc_exists\n+from weave.catalog import unique_file\n restore_path()\n \n+\n def unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n@@ -54,19 +51,19 @@ def print_assert_equal(test_string,actual,desired):\n #----------------------------------------------------------------------------\n class test_int_converter(unittest.TestCase):\n compiler = '' \n- def check_type_match_string(self):\n+ def check_type_match_string(self,level=5):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n- def check_type_match_int(self):\n+ def check_type_match_int(self,level=5):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n- def check_type_match_float(self):\n+ def check_type_match_float(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n- def check_type_match_complex(self):\n+ def check_type_match_complex(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n- def check_var_in(self):\n+ def check_var_in(self,level=5):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -89,7 +86,7 @@ def check_var_in(self):\n except TypeError:\n pass\n \n- def check_int_return(self):\n+ def check_int_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -109,19 +106,19 @@ def check_int_return(self):\n \n class test_float_converter(unittest.TestCase): \n compiler = ''\n- def check_type_match_string(self):\n+ def check_type_match_string(self,level=5):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n- def check_type_match_int(self):\n+ def check_type_match_int(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n- def check_type_match_float(self):\n+ def check_type_match_float(self,level=5):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n- def check_type_match_complex(self):\n+ def check_type_match_complex(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n- def check_float_var_in(self):\n+ def check_float_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -145,7 +142,7 @@ def check_float_var_in(self):\n pass\n \n \n- def check_float_return(self): \n+ def check_float_return(self,level=5): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -164,19 +161,19 @@ def check_float_return(self):\n \n class test_complex_converter(unittest.TestCase): \n compiler = ''\n- def check_type_match_string(self):\n+ def check_type_match_string(self,level=5):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n- def check_type_match_int(self):\n+ def check_type_match_int(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n- def check_type_match_float(self):\n+ def check_type_match_float(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n- def check_type_match_complex(self):\n+ def check_type_match_complex(self,level=5):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n- def check_complex_var_in(self):\n+ def check_complex_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -199,7 +196,7 @@ def check_complex_var_in(self):\n except TypeError:\n pass\n \n- def check_complex_return(self):\n+ def check_complex_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -222,7 +219,7 @@ def check_complex_return(self):\n \n class test_file_converter(unittest.TestCase): \n compiler = ''\n- def check_py_to_file(self):\n+ def check_py_to_file(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n@@ -233,7 +230,7 @@ def check_py_to_file(self):\n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n- def check_file_to_py(self):\n+ def check_file_to_py(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n@@ -263,7 +260,7 @@ class test_instance_converter(unittest.TestCase):\n \n class test_callable_converter(unittest.TestCase): \n compiler=''\n- def check_call_function(self):\n+ def check_call_function(self,level=5):\n import string\n func = string.find\n search_str = \"hello world hello\"\n@@ -283,34 +280,34 @@ def check_call_function(self):\n \n class test_sequence_converter(unittest.TestCase): \n compiler = ''\n- def check_convert_to_dict(self):\n+ def check_convert_to_dict(self,level=5):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n- def check_convert_to_list(self): \n+ def check_convert_to_list(self,level=5): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n- def check_convert_to_string(self): \n+ def check_convert_to_string(self,level=5): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n- def check_convert_to_tuple(self): \n+ def check_convert_to_tuple(self,level=5): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n \n class test_string_converter(unittest.TestCase): \n compiler = ''\n- def check_type_match_string(self):\n+ def check_type_match_string(self,level=5):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n- def check_type_match_int(self):\n+ def check_type_match_int(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n- def check_type_match_float(self):\n+ def check_type_match_float(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n- def check_type_match_complex(self):\n+ def check_type_match_complex(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n- def check_var_in(self):\n+ def check_var_in(self,level=5):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -334,7 +331,7 @@ def check_var_in(self):\n except TypeError:\n pass\n \n- def check_return(self):\n+ def check_return(self,level=5):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -353,15 +350,15 @@ def check_return(self):\n \n class test_list_converter(unittest.TestCase): \n compiler = ''\n- def check_type_match_bad(self):\n+ def check_type_match_bad(self,level=5):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n- def check_type_match_good(self):\n+ def check_type_match_good(self,level=5):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n- def check_var_in(self):\n+ def check_var_in(self,level=5):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -384,7 +381,7 @@ def check_var_in(self):\n except TypeError:\n pass\n \n- def check_return(self):\n+ def check_return(self,level=5):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -402,11 +399,11 @@ def check_return(self):\n c = test(b)\n assert( c == ['hello'])\n \n- def check_speed(self):\n+ def check_speed(self,level=5):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n- a = range(1e6);\n+ a = range(1000000);\n code = \"\"\"\n int v, sum = 0; \n for(int i = 0; i < a.len(); i++)\n@@ -464,15 +461,15 @@ def check_speed(self):\n \n class test_tuple_converter(unittest.TestCase): \n compiler = ''\n- def check_type_match_bad(self):\n+ def check_type_match_bad(self,level=5):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n- def check_type_match_good(self):\n+ def check_type_match_good(self,level=5):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n- def check_var_in(self):\n+ def check_var_in(self,level=5):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -495,7 +492,7 @@ def check_var_in(self):\n except TypeError:\n pass\n \n- def check_return(self):\n+ def check_return(self,level=5):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -516,15 +513,15 @@ def check_return(self):\n \n \n class test_dict_converter(unittest.TestCase): \n- def check_type_match_bad(self):\n+ def check_type_match_bad(self,level=5):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n- def check_type_match_good(self):\n+ def check_type_match_good(self,level=5):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n- def check_var_in(self):\n+ def check_var_in(self,level=5):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -547,7 +544,7 @@ def check_var_in(self):\n except TypeError:\n pass\n \n- def check_return(self):\n+ def check_return(self,level=5):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n@@ -665,59 +662,17 @@ def teardown_test_location():\n \n def remove_file(name):\n test_dir = os.path.abspath(name)\n- \n-def test_suite(level=1):\n- from unittest import makeSuite\n- global test_dir\n- test_dir = setup_test_location()\n- suites = [] \n- if level >= 5:\n- if msvc_exists():\n- suites.append( makeSuite(test_msvc_file_converter,'check_'))\n- suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n- suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n- suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n- suites.append( makeSuite(test_msvc_string_converter,'check_'))\n- suites.append( makeSuite(test_msvc_list_converter,'check_'))\n- suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n- suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n- suites.append( makeSuite(test_msvc_int_converter,'check_'))\n- suites.append( makeSuite(test_msvc_float_converter,'check_')) \n- suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n- else: # unix\n- suites.append( makeSuite(test_unix_file_converter,'check_'))\n- suites.append( makeSuite(test_unix_instance_converter,'check_'))\n- suites.append( makeSuite(test_unix_callable_converter,'check_'))\n- suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n- suites.append( makeSuite(test_unix_string_converter,'check_'))\n- suites.append( makeSuite(test_unix_list_converter,'check_'))\n- suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n- suites.append( makeSuite(test_unix_dict_converter,'check_'))\n- suites.append( makeSuite(test_unix_int_converter,'check_'))\n- suites.append( makeSuite(test_unix_float_converter,'check_')) \n- suites.append( makeSuite(test_unix_complex_converter,'check_')) \n- # run gcc tests also on windows\n- if gcc_exists() and msvc_exists() and sys.platform == 'win32': \n- suites.append( makeSuite(test_gcc_file_converter,'check_'))\n- suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n- suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n- suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n- suites.append( makeSuite(test_gcc_string_converter,'check_'))\n- suites.append( makeSuite(test_gcc_list_converter,'check_'))\n- suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n- suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n- suites.append( makeSuite(test_gcc_int_converter,'check_'))\n- suites.append( makeSuite(test_gcc_float_converter,'check_')) \n- suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n+\n+if not msvc_exists():\n+ for _n in dir():\n+ if _n[:10]=='test_msvc_': exec 'del '+_n\n+else:\n+ for _n in dir():\n+ if _n[:10]=='test_unix_': exec 'del '+_n\n+\n+if not (gcc_exists() and msvc_exists() and sys.platform == 'win32'):\n+ for _n in dir():\n+ if _n[:9]=='test_gcc_': exec 'del '+_n\n \n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.c_spec').run()\n", "added_lines": 63, "deleted_lines": 108, "source_code": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools,ext_tools,c_spec\nfrom weave.build_tools import msvc_exists, gcc_exists\nfrom weave.catalog import unique_file\nrestore_path()\n\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self,level=5):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self,level=5):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self,level=5): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self,level=5):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self,level=5):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self,level=5):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self,level=5):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self,level=5): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self,level=5): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self,level=5): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self,level=5):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self,level=5):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self,level=5):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self,level=5):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1000000);\n code = \"\"\"\n int v, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n if (v % 2)\n sum += v;\n else\n sum -= v; \n }\n return_val = sum;\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = sum;\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self,level=5):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self,level=5):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self,level=5):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self,level=5):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self,level=5):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self,level=5):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n\nif not msvc_exists():\n for _n in dir():\n if _n[:10]=='test_msvc_': exec 'del '+_n\nelse:\n for _n in dir():\n if _n[:10]=='test_unix_': exec 'del '+_n\n\nif not (gcc_exists() and msvc_exists() and sys.platform == 'win32'):\n for _n in dir():\n if _n[:9]=='test_gcc_': exec 'del '+_n\n\nif __name__ == \"__main__\":\n ScipyTest('weave.c_spec').run()\n", "source_code_before": "import unittest\nimport time\nimport os,sys\n\n# Note: test_dir is global to this file. \n# It is made by setup_test_location()\n\n\n#globals\nglobal test_dir \ntest_dir = ''\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nimport ext_tools\nfrom catalog import unique_file\nfrom build_tools import msvc_exists, gcc_exists\nimport c_spec\nrestore_path()\n\ndef unique_mod(d,file_name):\n f = os.path.basename(unique_file(d,file_name))\n m = os.path.splitext(f)[0]\n return m\n \ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\n#----------------------------------------------------------------------------\n# Scalar conversion test classes\n# int, float, complex\n#----------------------------------------------------------------------------\nclass test_int_converter(unittest.TestCase):\n compiler = '' \n def check_type_match_string(self):\n s = c_spec.int_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.int_converter() \n assert(s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.int_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'int_var_in' + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"a=2;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n \n def check_int_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1\n code = \"\"\"\n a=a+2;\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1\n c = test(b)\n\n assert( c == 3)\n\nclass test_float_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.float_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.float_converter() \n assert(s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.float_converter() \n assert(not s.type_match(5.+1j))\n def check_float_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"a=2.;\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n\n def check_float_return(self): \n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.\n code = \"\"\"\n a=a+2.;\n return_val = PyFloat_FromDouble(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.\n c = test(b)\n assert( c == 3.)\n \nclass test_complex_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.complex_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.complex_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.complex_converter() \n assert(s.type_match(5.+1j))\n def check_complex_var_in(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"a=std::complex(2.,2.);\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'abc'\n test(b)\n except TypeError:\n pass\n\n def check_complex_return(self):\n mod_name = sys._getframe().f_code.co_name + self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 1.+1j\n code = \"\"\"\n a= a + std::complex(2.,2.);\n return_val = PyComplex_FromDoubles(a.real(),a.imag());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=1.+1j\n c = test(b)\n assert( c == 3.+3j)\n\n#----------------------------------------------------------------------------\n# File conversion tests\n#----------------------------------------------------------------------------\n\nclass test_file_converter(unittest.TestCase): \n compiler = ''\n def check_py_to_file(self):\n import tempfile\n file_name = tempfile.mktemp() \n file = open(file_name,'w')\n code = \"\"\"\n fprintf(file,\"hello bob\");\n \"\"\"\n inline_tools.inline(code,['file'],compiler=self.compiler,force=1) \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello bob\")\n def check_file_to_py(self):\n import tempfile\n file_name = tempfile.mktemp() \n # not sure I like Py::String as default -- might move to std::sting\n # or just plain char*\n code = \"\"\"\n char* _file_name = (char*) file_name.c_str();\n FILE* file = fopen(_file_name,\"w\");\n return_val = file_to_py(file,_file_name,\"w\");\n \"\"\"\n file = inline_tools.inline(code,['file_name'], compiler=self.compiler,\n force=1)\n file.write(\"hello fred\") \n file.close()\n file = open(file_name,'r')\n assert(file.read() == \"hello fred\")\n\n#----------------------------------------------------------------------------\n# Instance conversion tests\n#----------------------------------------------------------------------------\n\nclass test_instance_converter(unittest.TestCase): \n pass\n\n#----------------------------------------------------------------------------\n# Callable object conversion tests\n#----------------------------------------------------------------------------\n \nclass test_callable_converter(unittest.TestCase): \n compiler=''\n def check_call_function(self):\n import string\n func = string.find\n search_str = \"hello world hello\"\n sub_str = \"world\"\n # * Not sure about ref counts on search_str and sub_str.\n # * Is the Py::String necessary? (it works anyways...)\n code = \"\"\"\n py::tuple args(2);\n args[0] = search_str;\n args[1] = sub_str;\n return_val = func.call(args);\n \"\"\"\n actual = inline_tools.inline(code,['func','search_str','sub_str'],\n compiler=self.compiler,force=1)\n desired = func(search_str,sub_str) \n assert(desired == actual)\n\nclass test_sequence_converter(unittest.TestCase): \n compiler = ''\n def check_convert_to_dict(self):\n d = {}\n inline_tools.inline(\"\",['d'],compiler=self.compiler,force=1) \n def check_convert_to_list(self): \n l = []\n inline_tools.inline(\"\",['l'],compiler=self.compiler,force=1)\n def check_convert_to_string(self): \n s = 'hello'\n inline_tools.inline(\"\",['s'],compiler=self.compiler,force=1)\n def check_convert_to_tuple(self): \n t = ()\n inline_tools.inline(\"\",['t'],compiler=self.compiler,force=1)\n\nclass test_string_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_string(self):\n s = c_spec.string_converter()\n assert( s.type_match('string') )\n def check_type_match_int(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = c_spec.string_converter() \n assert(not s.type_match(5.+1j))\n def check_var_in(self):\n mod_name = 'string_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = 'a=std::string(\"hello\");'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n\n exec 'from ' + mod_name + ' import test'\n b='bub'\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 1\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'string_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = 'string'\n code = \"\"\"\n a= std::string(\"hello\");\n return_val = PyString_FromString(a.c_str());\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b='bub'\n c = test(b)\n assert( c == 'hello')\n\nclass test_list_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.list_converter()\n objs = [{},(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.list_converter() \n assert(s.type_match([]))\n def check_var_in(self):\n mod_name = 'list_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = 'a=py::list();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'list_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = [1]\n code = \"\"\"\n a=py::list();\n a.append(\"hello\");\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=[1,2]\n c = test(b)\n assert( c == ['hello'])\n \n def check_speed(self):\n mod_name = 'list_speed'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = range(1e6);\n code = \"\"\"\n int v, sum = 0; \n for(int i = 0; i < a.len(); i++)\n {\n v = a[i];\n if (v % 2)\n sum += v;\n else\n sum -= v; \n }\n return_val = sum;\n \"\"\"\n with_cxx = ext_tools.ext_function('with_cxx',code,['a'])\n mod.add_function(with_cxx)\n code = \"\"\"\n int vv, sum = 0;\n PyObject *v; \n for(int i = 0; i < a.len(); i++)\n {\n v = PyList_GetItem(py_a,i);\n //didn't set error here -- just speed test\n vv = py_to_int(v,\"list item\");\n if (vv % 2)\n sum += vv;\n else\n sum -= vv; \n }\n return_val = sum;\n \"\"\"\n no_checking = ext_tools.ext_function('no_checking',code,['a'])\n mod.add_function(no_checking)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import with_cxx, no_checking'\n import time\n t1 = time.time()\n sum1 = with_cxx(a)\n t2 = time.time()\n print 'speed test for list access'\n print 'compiler:', self.compiler\n print 'scxx:', t2 - t1\n t1 = time.time()\n sum2 = no_checking(a)\n t2 = time.time()\n print 'C, no checking:', t2 - t1\n sum3 = 0\n t1 = time.time()\n for i in a:\n if i % 2:\n sum3 += i\n else:\n sum3 -= i\n t2 = time.time()\n print 'python:', t2 - t1 \n assert( sum1 == sum2 and sum1 == sum3)\n\nclass test_tuple_converter(unittest.TestCase): \n compiler = ''\n def check_type_match_bad(self):\n s = c_spec.tuple_converter()\n objs = [{},[],'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.tuple_converter() \n assert(s.type_match((1,)))\n def check_var_in(self):\n mod_name = 'tuple_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = 'a=py::tuple();'\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'tuple_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = (1,)\n code = \"\"\"\n a=py::tuple(2);\n a[0] = \"hello\";\n a.set_item(1,py::None);\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b=(1,2)\n c = test(b)\n assert( c == ('hello',None))\n\n\nclass test_dict_converter(unittest.TestCase): \n def check_type_match_bad(self):\n s = c_spec.dict_converter()\n objs = [[],(),'',1,1.,1+1j]\n for i in objs:\n assert( not s.type_match(i) )\n def check_type_match_good(self):\n s = c_spec.dict_converter() \n assert(s.type_match({}))\n def check_var_in(self):\n mod_name = 'dict_var_in'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = 'a=py::dict();' # This just checks to make sure the type is correct\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b={'y':2}\n test(b)\n try:\n b = 1.\n test(b)\n except TypeError:\n pass\n try:\n b = 'string'\n test(b)\n except TypeError:\n pass\n \n def check_return(self):\n mod_name = 'dict_return'+self.compiler\n mod_name = unique_mod(test_dir,mod_name)\n mod = ext_tools.ext_module(mod_name)\n a = {'z':1}\n code = \"\"\"\n a=py::dict();\n a[\"hello\"] = 5;\n return_val = a;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = test_dir, compiler = self.compiler)\n exec 'from ' + mod_name + ' import test'\n b = {'z':2}\n c = test(b)\n assert( c['hello'] == 5)\n\nclass test_msvc_int_converter(test_int_converter): \n compiler = 'msvc'\nclass test_unix_int_converter(test_int_converter): \n compiler = ''\nclass test_gcc_int_converter(test_int_converter): \n compiler = 'gcc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\n\nclass test_msvc_float_converter(test_float_converter): \n compiler = 'msvc'\nclass test_unix_float_converter(test_float_converter): \n compiler = ''\nclass test_gcc_float_converter(test_float_converter): \n compiler = 'gcc'\n\nclass test_msvc_complex_converter(test_complex_converter): \n compiler = 'msvc'\nclass test_unix_complex_converter(test_complex_converter): \n compiler = ''\nclass test_gcc_complex_converter(test_complex_converter): \n compiler = 'gcc'\n\nclass test_msvc_file_converter(test_file_converter): \n compiler = 'msvc'\nclass test_unix_file_converter(test_file_converter): \n compiler = ''\nclass test_gcc_file_converter(test_file_converter): \n compiler = 'gcc'\n\nclass test_msvc_callable_converter(test_callable_converter): \n compiler = 'msvc'\nclass test_unix_callable_converter(test_callable_converter): \n compiler = ''\nclass test_gcc_callable_converter(test_callable_converter): \n compiler = 'gcc'\n\nclass test_msvc_sequence_converter(test_sequence_converter): \n compiler = 'msvc'\nclass test_unix_sequence_converter(test_sequence_converter): \n compiler = ''\nclass test_gcc_sequence_converter(test_sequence_converter): \n compiler = 'gcc'\n\nclass test_msvc_string_converter(test_string_converter): \n compiler = 'msvc'\nclass test_unix_string_converter(test_string_converter): \n compiler = ''\nclass test_gcc_string_converter(test_string_converter): \n compiler = 'gcc'\n\nclass test_msvc_list_converter(test_list_converter): \n compiler = 'msvc'\nclass test_unix_list_converter(test_list_converter): \n compiler = ''\nclass test_gcc_list_converter(test_list_converter): \n compiler = 'gcc'\n\nclass test_msvc_tuple_converter(test_tuple_converter): \n compiler = 'msvc'\nclass test_unix_tuple_converter(test_tuple_converter): \n compiler = ''\nclass test_gcc_tuple_converter(test_tuple_converter): \n compiler = 'gcc'\n\nclass test_msvc_dict_converter(test_dict_converter): \n compiler = 'msvc'\nclass test_unix_dict_converter(test_dict_converter): \n compiler = ''\nclass test_gcc_dict_converter(test_dict_converter): \n compiler = 'gcc'\n\nclass test_msvc_instance_converter(test_instance_converter): \n compiler = 'msvc'\nclass test_unix_instance_converter(test_instance_converter): \n compiler = ''\nclass test_gcc_instance_converter(test_instance_converter): \n compiler = 'gcc'\n \ndef setup_test_location():\n import tempfile\n #test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n test_dir = tempfile.mktemp()\n if not os.path.exists(test_dir):\n os.mkdir(test_dir)\n sys.path.insert(0,test_dir) \n return test_dir\n\ntest_dir = setup_test_location()\n\ndef teardown_test_location():\n import tempfile\n test_dir = os.path.join(tempfile.gettempdir(),'test_files')\n if sys.path[0] == test_dir:\n sys.path = sys.path[1:]\n return test_dir\n\ndef remove_file(name):\n test_dir = os.path.abspath(name)\n \ndef test_suite(level=1):\n from unittest import makeSuite\n global test_dir\n test_dir = setup_test_location()\n suites = [] \n if level >= 5:\n if msvc_exists():\n suites.append( makeSuite(test_msvc_file_converter,'check_'))\n suites.append( makeSuite(test_msvc_instance_converter,'check_'))\n suites.append( makeSuite(test_msvc_callable_converter,'check_'))\n suites.append( makeSuite(test_msvc_sequence_converter,'check_'))\n suites.append( makeSuite(test_msvc_string_converter,'check_'))\n suites.append( makeSuite(test_msvc_list_converter,'check_'))\n suites.append( makeSuite(test_msvc_tuple_converter,'check_'))\n suites.append( makeSuite(test_msvc_dict_converter,'check_'))\n suites.append( makeSuite(test_msvc_int_converter,'check_'))\n suites.append( makeSuite(test_msvc_float_converter,'check_')) \n suites.append( makeSuite(test_msvc_complex_converter,'check_'))\n else: # unix\n suites.append( makeSuite(test_unix_file_converter,'check_'))\n suites.append( makeSuite(test_unix_instance_converter,'check_'))\n suites.append( makeSuite(test_unix_callable_converter,'check_'))\n suites.append( makeSuite(test_unix_sequence_converter,'check_'))\n suites.append( makeSuite(test_unix_string_converter,'check_'))\n suites.append( makeSuite(test_unix_list_converter,'check_'))\n suites.append( makeSuite(test_unix_tuple_converter,'check_'))\n suites.append( makeSuite(test_unix_dict_converter,'check_'))\n suites.append( makeSuite(test_unix_int_converter,'check_'))\n suites.append( makeSuite(test_unix_float_converter,'check_')) \n suites.append( makeSuite(test_unix_complex_converter,'check_')) \n # run gcc tests also on windows\n if gcc_exists() and msvc_exists() and sys.platform == 'win32': \n suites.append( makeSuite(test_gcc_file_converter,'check_'))\n suites.append( makeSuite(test_gcc_instance_converter,'check_'))\n suites.append( makeSuite(test_gcc_callable_converter,'check_'))\n suites.append( makeSuite(test_gcc_sequence_converter,'check_'))\n suites.append( makeSuite(test_gcc_string_converter,'check_'))\n suites.append( makeSuite(test_gcc_list_converter,'check_'))\n suites.append( makeSuite(test_gcc_tuple_converter,'check_'))\n suites.append( makeSuite(test_gcc_dict_converter,'check_'))\n suites.append( makeSuite(test_gcc_int_converter,'check_'))\n suites.append( makeSuite(test_gcc_float_converter,'check_')) \n suites.append( makeSuite(test_gcc_complex_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 20, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 25, "end_line": 30, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 32, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 54, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "level" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self", "level" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 112, "parameters": [ "self", "level" ], "start_line": 66, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 101, "parameters": [ "self", "level" ], "start_line": 89, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 109, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self", "level" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self", "level" ], "start_line": 121, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 104, "parameters": [ "self", "level" ], "start_line": 145, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 164, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "level" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 126, "parameters": [ "self", "level" ], "start_line": 176, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 110, "parameters": [ "self", "level" ], "start_line": 199, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 72, "parameters": [ "self", "level" ], "start_line": 222, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 72, "parameters": [ "self", "level" ], "start_line": 233, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 65, "parameters": [ "self", "level" ], "start_line": 263, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 283, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 289, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 292, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 298, "end_line": 300, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 301, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "level" ], "start_line": 304, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self", "level" ], "start_line": 307, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 112, "parameters": [ "self", "level" ], "start_line": 310, "end_line": 332, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 93, "parameters": [ "self", "level" ], "start_line": 334, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 353, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 358, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self", "level" ], "start_line": 361, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 101, "parameters": [ "self", "level" ], "start_line": 384, "end_line": 400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 59, "complexity": 4, "token_count": 218, "parameters": [ "self", "level" ], "start_line": 402, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 464, "end_line": 468, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 469, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 119, "parameters": [ "self", "level" ], "start_line": 472, "end_line": 493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 104, "parameters": [ "self", "level" ], "start_line": 495, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 516, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 521, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 120, "parameters": [ "self", "level" ], "start_line": 524, "end_line": 545, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 104, "parameters": [ "self", "level" ], "start_line": 547, "end_line": 563, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 645, "end_line": 652, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 656, "end_line": 661, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 663, "end_line": 664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 } ], "methods_before": [ { "name": "unique_mod", "long_name": "unique_mod( d , file_name )", "filename": "test_c_spec.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "d", "file_name" ], "start_line": 23, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 28, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_c_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 35, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 112, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 115, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 118, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 266, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 289, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 292, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 295, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 301, "end_line": 303, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 304, "end_line": 306, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 307, "end_line": 309, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 310, "end_line": 312, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 313, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 356, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 114, "parameters": [ "self" ], "start_line": 364, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 387, "end_line": 403, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 59, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 405, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 467, "end_line": 471, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 472, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 115, "parameters": [ "self" ], "start_line": 475, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 18, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 498, "end_line": 515, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 519, "end_line": 523, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 524, "end_line": 526, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 116, "parameters": [ "self" ], "start_line": 527, "end_line": 548, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 17, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 550, "end_line": 566, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "setup_test_location", "long_name": "setup_test_location( )", "filename": "test_c_spec.py", "nloc": 7, "complexity": 2, "token_count": 42, "parameters": [], "start_line": 648, "end_line": 655, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "teardown_test_location", "long_name": "teardown_test_location( )", "filename": "test_c_spec.py", "nloc": 6, "complexity": 2, "token_count": 45, "parameters": [], "start_line": 659, "end_line": 664, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "remove_file", "long_name": "remove_file( name )", "filename": "test_c_spec.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "name" ], "start_line": 666, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 6, "token_count": 422, "parameters": [ "level" ], "start_line": 669, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 716, "end_line": 720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 289, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 112, "parameters": [ "self", "level" ], "start_line": 66, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 283, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 295, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 716, "end_line": 720, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_complex_return", "long_name": "check_complex_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 110, "parameters": [ "self", "level" ], "start_line": 199, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 236, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_file_to_py", "long_name": "check_file_to_py( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 14, "complexity": 1, "token_count": 72, "parameters": [ "self", "level" ], "start_line": 233, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_complex_return", "long_name": "check_complex_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 106, "parameters": [ "self" ], "start_line": 202, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self", "level" ], "start_line": 121, "end_line": 142, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float_var_in", "long_name": "check_float_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 118, "parameters": [ "self" ], "start_line": 124, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self", "level" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 59, "complexity": 4, "token_count": 218, "parameters": [ "self", "level" ], "start_line": 402, "end_line": 460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 289, "end_line": 291, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 104, "parameters": [ "self", "level" ], "start_line": 145, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "level" ], "start_line": 60, "end_line": 62, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 68, "parameters": [ "self" ], "start_line": 225, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 101, "parameters": [ "self", "level" ], "start_line": 89, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_int_return", "long_name": "check_int_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 92, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_speed", "long_name": "check_speed( self )", "filename": "test_c_spec.py", "nloc": 59, "complexity": 4, "token_count": 214, "parameters": [ "self" ], "start_line": 405, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 65, "parameters": [ "self", "level" ], "start_line": 263, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 358, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 108, "parameters": [ "self" ], "start_line": 69, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_convert_to_dict", "long_name": "check_convert_to_dict( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_c_spec.py", "nloc": 44, "complexity": 6, "token_count": 422, "parameters": [ "level" ], "start_line": 669, "end_line": 714, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 0 }, { "name": "check_convert_to_tuple", "long_name": "check_convert_to_tuple( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 292, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_convert_to_string", "long_name": "check_convert_to_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 292, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_float_return", "long_name": "check_float_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 148, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_good", "long_name": "check_type_match_good( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 361, "end_line": 363, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 122, "parameters": [ "self" ], "start_line": 179, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_py_to_file", "long_name": "check_py_to_file( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 11, "complexity": 1, "token_count": 72, "parameters": [ "self", "level" ], "start_line": 222, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 93, "parameters": [ "self", "level" ], "start_line": 334, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_return", "long_name": "check_return( self )", "filename": "test_c_spec.py", "nloc": 16, "complexity": 1, "token_count": 89, "parameters": [ "self" ], "start_line": 337, "end_line": 352, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 353, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_call_function", "long_name": "check_call_function( self )", "filename": "test_c_spec.py", "nloc": 15, "complexity": 1, "token_count": 61, "parameters": [ "self" ], "start_line": 266, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_convert_to_list", "long_name": "check_convert_to_list( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 286, "end_line": 288, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_bad", "long_name": "check_type_match_bad( self )", "filename": "test_c_spec.py", "nloc": 5, "complexity": 2, "token_count": 47, "parameters": [ "self" ], "start_line": 356, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_complex_var_in", "long_name": "check_complex_var_in( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 22, "complexity": 3, "token_count": 126, "parameters": [ "self", "level" ], "start_line": 176, "end_line": 197, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self , level = 5 )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 54, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_c_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 63, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "nloc": 603, "complexity": 73, "token_count": 3646, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import inline_tools,ext_tools,c_spec", "from weave.build_tools import msvc_exists, gcc_exists", "from weave.catalog import unique_file", "", " def check_type_match_string(self,level=5):", " def check_type_match_int(self,level=5):", " def check_type_match_float(self,level=5):", " def check_type_match_complex(self,level=5):", " def check_var_in(self,level=5):", " def check_int_return(self,level=5):", " def check_type_match_string(self,level=5):", " def check_type_match_int(self,level=5):", " def check_type_match_float(self,level=5):", " def check_type_match_complex(self,level=5):", " def check_float_var_in(self,level=5):", " def check_float_return(self,level=5):", " def check_type_match_string(self,level=5):", " def check_type_match_int(self,level=5):", " def check_type_match_float(self,level=5):", " def check_type_match_complex(self,level=5):", " def check_complex_var_in(self,level=5):", " def check_complex_return(self,level=5):", " def check_py_to_file(self,level=5):", " def check_file_to_py(self,level=5):", " def check_call_function(self,level=5):", " def check_convert_to_dict(self,level=5):", " def check_convert_to_list(self,level=5):", " def check_convert_to_string(self,level=5):", " def check_convert_to_tuple(self,level=5):", " def check_type_match_string(self,level=5):", " def check_type_match_int(self,level=5):", " def check_type_match_float(self,level=5):", " def check_type_match_complex(self,level=5):", " def check_var_in(self,level=5):", " def check_return(self,level=5):", " def check_type_match_bad(self,level=5):", " def check_type_match_good(self,level=5):", " def check_var_in(self,level=5):", " def check_return(self,level=5):", " def check_speed(self,level=5):", " a = range(1000000);", " def check_type_match_bad(self,level=5):", " def check_type_match_good(self,level=5):", " def check_var_in(self,level=5):", " def check_return(self,level=5):", " def check_type_match_bad(self,level=5):", " def check_type_match_good(self,level=5):", " def check_var_in(self,level=5):", " def check_return(self,level=5):", "", "if not msvc_exists():", " for _n in dir():", " if _n[:10]=='test_msvc_': exec 'del '+_n", "else:", " for _n in dir():", " if _n[:10]=='test_unix_': exec 'del '+_n", "", "if not (gcc_exists() and msvc_exists() and sys.platform == 'win32'):", " for _n in dir():", " if _n[:9]=='test_gcc_': exec 'del '+_n", " ScipyTest('weave.c_spec').run()" ], "deleted": [ "", "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import inline_tools", "import ext_tools", "from catalog import unique_file", "from build_tools import msvc_exists, gcc_exists", "import c_spec", " def check_type_match_string(self):", " def check_type_match_int(self):", " def check_type_match_float(self):", " def check_type_match_complex(self):", " def check_var_in(self):", " def check_int_return(self):", " def check_type_match_string(self):", " def check_type_match_int(self):", " def check_type_match_float(self):", " def check_type_match_complex(self):", " def check_float_var_in(self):", " def check_float_return(self):", " def check_type_match_string(self):", " def check_type_match_int(self):", " def check_type_match_float(self):", " def check_type_match_complex(self):", " def check_complex_var_in(self):", " def check_complex_return(self):", " def check_py_to_file(self):", " def check_file_to_py(self):", " def check_call_function(self):", " def check_convert_to_dict(self):", " def check_convert_to_list(self):", " def check_convert_to_string(self):", " def check_convert_to_tuple(self):", " def check_type_match_string(self):", " def check_type_match_int(self):", " def check_type_match_float(self):", " def check_type_match_complex(self):", " def check_var_in(self):", " def check_return(self):", " def check_type_match_bad(self):", " def check_type_match_good(self):", " def check_var_in(self):", " def check_return(self):", " def check_speed(self):", " a = range(1e6);", " def check_type_match_bad(self):", " def check_type_match_good(self):", " def check_var_in(self):", " def check_return(self):", " def check_type_match_bad(self):", " def check_type_match_good(self):", " def check_var_in(self):", " def check_return(self):", "", "def test_suite(level=1):", " from unittest import makeSuite", " global test_dir", " test_dir = setup_test_location()", " suites = []", " if level >= 5:", " if msvc_exists():", " suites.append( makeSuite(test_msvc_file_converter,'check_'))", " suites.append( makeSuite(test_msvc_instance_converter,'check_'))", " suites.append( makeSuite(test_msvc_callable_converter,'check_'))", " suites.append( makeSuite(test_msvc_sequence_converter,'check_'))", " suites.append( makeSuite(test_msvc_string_converter,'check_'))", " suites.append( makeSuite(test_msvc_list_converter,'check_'))", " suites.append( makeSuite(test_msvc_tuple_converter,'check_'))", " suites.append( makeSuite(test_msvc_dict_converter,'check_'))", " suites.append( makeSuite(test_msvc_int_converter,'check_'))", " suites.append( makeSuite(test_msvc_float_converter,'check_'))", " suites.append( makeSuite(test_msvc_complex_converter,'check_'))", " else: # unix", " suites.append( makeSuite(test_unix_file_converter,'check_'))", " suites.append( makeSuite(test_unix_instance_converter,'check_'))", " suites.append( makeSuite(test_unix_callable_converter,'check_'))", " suites.append( makeSuite(test_unix_sequence_converter,'check_'))", " suites.append( makeSuite(test_unix_string_converter,'check_'))", " suites.append( makeSuite(test_unix_list_converter,'check_'))", " suites.append( makeSuite(test_unix_tuple_converter,'check_'))", " suites.append( makeSuite(test_unix_dict_converter,'check_'))", " suites.append( makeSuite(test_unix_int_converter,'check_'))", " suites.append( makeSuite(test_unix_float_converter,'check_'))", " suites.append( makeSuite(test_unix_complex_converter,'check_'))", " # run gcc tests also on windows", " if gcc_exists() and msvc_exists() and sys.platform == 'win32':", " suites.append( makeSuite(test_gcc_file_converter,'check_'))", " suites.append( makeSuite(test_gcc_instance_converter,'check_'))", " suites.append( makeSuite(test_gcc_callable_converter,'check_'))", " suites.append( makeSuite(test_gcc_sequence_converter,'check_'))", " suites.append( makeSuite(test_gcc_string_converter,'check_'))", " suites.append( makeSuite(test_gcc_list_converter,'check_'))", " suites.append( makeSuite(test_gcc_tuple_converter,'check_'))", " suites.append( makeSuite(test_gcc_dict_converter,'check_'))", " suites.append( makeSuite(test_gcc_int_converter,'check_'))", " suites.append( makeSuite(test_gcc_float_converter,'check_'))", " suites.append( makeSuite(test_gcc_complex_converter,'check_'))", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", " test()" ] } }, { "old_path": "weave/tests/test_catalog.py", "new_path": "weave/tests/test_catalog.py", "filename": "test_catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,19 +2,15 @@\n import sys, os\n \n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-from scipy_distutils.misc_util import add_local_to_path\n-\n-add_grandparent_to_path(__name__)\n-import catalog\n-reload(catalog) # this'll pick up any recent code changes\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import catalog\n restore_path()\n \n-add_local_to_path(__name__)\n+set_local_path()\n from weave_test_utils import *\n restore_path()\n \n-\n class test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n@@ -332,27 +328,7 @@ def check_add_function_ordered(self):\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n- \n- \n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_default_dir,'check_'))\n- suites.append( unittest.makeSuite(test_os_dependent_catalog_name,\n- 'check_'))\n- suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n- suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n- suites.append( unittest.makeSuite(test_catalog,'check_'))\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n \n \n if __name__ == '__main__':\n- test()\n+ ScipyTest('weave.catalog').run()\n", "added_lines": 5, "deleted_lines": 29, "source_code": "import unittest\nimport sys, os\n\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import catalog\nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile, glob\n #temp = tempfile.gettempdir()\n pardir = tempfile.mktemp(suffix='cat_test')\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n cat_glob = os.path.join(pardir,catalog.os_dependent_catalog_name()+'.*') \n cat_files = glob.glob(cat_glob)\n if erase:\n for cat_file in cat_files:\n os.remove(cat_file)\n return pardir\n def remove_dir(self,d):\n import distutils.dir_util\n distutils.dir_util.remove_tree(d)\n \n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'r')\n self.remove_dir(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n self.remove_dir(pardir)\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r is None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r is None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n # just use some already available functions\n import string\n funcs = [string.upper, string.lower, string.find,string.replace]\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n # a little cheating... I'm ignoring any functions that might have\n # been read in from a prior catalog file (such as the defualt one).\n # the test should really be made so that these aren't read in, but\n # until I get this figured out...\n #assert(funcs1 == [string.lower,string.upper])\n #assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n #assert(funcs3 == [re.purge,re.match,os.open,\n # os.access,string.atoi,string.atof])\n assert(funcs1[:2] == [string.lower,string.upper]),`funcs1`\n assert(funcs2[:4] == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3[:6] == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n\n\nif __name__ == '__main__':\n ScipyTest('weave.catalog').run()\n", "source_code_before": "import unittest\nimport sys, os\n\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport catalog\nreload(catalog) # this'll pick up any recent code changes\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\n\nclass test_default_dir(unittest.TestCase):\n def check_is_writable(self):\n path = catalog.default_dir()\n name = os.path.join(path,'dummy_catalog')\n test_file = open(name,'w')\n try:\n test_file.write('making sure default location is writable\\n')\n finally:\n test_file.close()\n os.remove(name)\n\nclass test_os_dependent_catalog_name(unittest.TestCase): \n pass\n \nclass test_catalog_path(unittest.TestCase): \n def check_default(self):\n in_path = catalog.default_dir()\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == in_path)\n assert(f == catalog.os_dependent_catalog_name())\n def check_current(self):\n in_path = '.'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.abspath(in_path)) \n assert(f == catalog.os_dependent_catalog_name()) \n def check_user(path):\n if sys.platform != 'win32':\n in_path = '~'\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert(d == os.path.expanduser(in_path)) \n assert(f == catalog.os_dependent_catalog_name())\n def check_module(self):\n # hand it a module and see if it uses the parent directory\n # of the module.\n path = catalog.catalog_path(os.__file__)\n d,f = os.path.split(os.__file__)\n d2,f = os.path.split(path)\n assert (d2 == d)\n def check_path(self):\n # use os.__file__ to get a usable directory.\n in_path,f = os.path.split(os.__file__)\n path = catalog.catalog_path(in_path)\n d,f = os.path.split(path)\n assert (d == in_path)\n def check_bad_path(self):\n # stupid_path_name\n in_path = 'stupid_path_name'\n path = catalog.catalog_path(in_path)\n assert (path is None)\n\nclass test_get_catalog(unittest.TestCase):\n \"\"\" This only tests whether new catalogs are created correctly.\n And whether non-existent return None correctly with read mode.\n Putting catalogs in the right place is all tested with\n catalog_dir tests.\n \"\"\"\n def get_test_dir(self,erase = 0):\n # make sure tempdir catalog doesn't exist\n import tempfile, glob\n #temp = tempfile.gettempdir()\n pardir = tempfile.mktemp(suffix='cat_test')\n if not os.path.exists(pardir):\n os.mkdir(pardir)\n cat_glob = os.path.join(pardir,catalog.os_dependent_catalog_name()+'.*') \n cat_files = glob.glob(cat_glob)\n if erase:\n for cat_file in cat_files:\n os.remove(cat_file)\n return pardir\n def remove_dir(self,d):\n import distutils.dir_util\n distutils.dir_util.remove_tree(d)\n \n def check_nonexistent_catalog_is_none(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'r')\n self.remove_dir(pardir)\n assert(cat is None)\n def check_create_catalog(self):\n pardir = self.get_test_dir(erase=1)\n cat = catalog.get_catalog(pardir,'c')\n self.remove_dir(pardir)\n assert(cat is not None)\n\nclass test_catalog(unittest.TestCase):\n\n def clear_environ(self):\n if os.environ.has_key('PYTHONCOMPILED'):\n self.old_PYTHONCOMPILED = os.environ['PYTHONCOMPILED']\n del os.environ['PYTHONCOMPILED']\n else: \n self.old_PYTHONCOMPILED = None\n def reset_environ(self):\n if self.old_PYTHONCOMPILED:\n os.environ['PYTHONCOMPILED'] = self.old_PYTHONCOMPILED\n self.old_PYTHONCOMPILED = None\n def setUp(self):\n self.clear_environ() \n def tearDown(self):\n self.reset_environ()\n \n def check_set_module_directory(self):\n q = catalog.catalog()\n q.set_module_directory('bob')\n r = q.get_module_directory()\n assert (r == 'bob')\n def check_clear_module_directory(self):\n q = catalog.catalog()\n r = q.get_module_directory()\n assert (r is None)\n q.set_module_directory('bob')\n r = q.clear_module_directory()\n assert (r is None)\n def check_get_environ_path(self):\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('path1','path2','path3'))\n q = catalog.catalog()\n path = q.get_environ_path() \n assert(path == ['path1','path2','path3'])\n def check_build_search_order1(self): \n \"\"\" MODULE in search path should be replaced by module_dir.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n q.set_module_directory('second')\n order = q.build_search_order()\n assert(order == ['first','second','third',catalog.default_dir()])\n def check_build_search_order2(self): \n \"\"\" MODULE in search path should be removed if module_dir==None.\n \"\"\" \n q = catalog.catalog(['first','MODULE','third'])\n order = q.build_search_order()\n assert(order == ['first','third',catalog.default_dir()]) \n def check_build_search_order3(self):\n \"\"\" If MODULE is absent, module_dir shouldn't be in search path.\n \"\"\" \n q = catalog.catalog(['first','second'])\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second',catalog.default_dir()])\n def check_build_search_order4(self):\n \"\"\" Make sure environment variable is getting used.\n \"\"\" \n q = catalog.catalog(['first','second'])\n if sys.platform == 'win32': sep = ';'\n else: sep = ':'\n os.environ['PYTHONCOMPILED'] = sep.join(('MODULE','fourth','fifth'))\n q.set_module_directory('third')\n order = q.build_search_order()\n assert(order == ['first','second','third','fourth','fifth',catalog.default_dir()])\n \n def check_catalog_files1(self):\n \"\"\" Be sure we get at least one file even without specifying the path.\n \"\"\"\n q = catalog.catalog()\n files = q.get_catalog_files()\n assert(len(files) == 1)\n\n def check_catalog_files2(self):\n \"\"\" Ignore bad paths in the path.\n \"\"\"\n q = catalog.catalog()\n os.environ['PYTHONCOMPILED'] = '_some_bad_path_'\n files = q.get_catalog_files()\n assert(len(files) == 1)\n \n def check_get_existing_files1(self):\n \"\"\" Shouldn't get any files when temp doesn't exist and no path set. \n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 0)\n def check_get_existing_files2(self):\n \"\"\" Shouldn't get a single file from the temp dir.\n \"\"\" \n clear_temp_catalog()\n q = catalog.catalog()\n # create a dummy file\n import os \n q.add_function('code', os.getpid)\n del q\n q = catalog.catalog()\n files = q.get_existing_files()\n restore_temp_catalog()\n assert(len(files) == 1)\n \n def check_access_writable_file(self):\n \"\"\" There should always be a writable file -- even if it is in temp\n \"\"\"\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_with_bad_path(self):\n \"\"\" There should always be a writable file -- even if search paths contain\n bad values.\n \"\"\"\n if sys.platform == 'win32': sep = ';'\n else: sep = ':' \n os.environ['PYTHONCOMPILED'] = sep.join(('_bad_path_name_'))\n q = catalog.catalog()\n file = q.get_writable_file()\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file) \n def check_writable_dir(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n d = q.get_writable_dir()\n file = os.path.join(d,'some_silly_file')\n try:\n f = open(file,'w')\n f.write('bob')\n finally:\n f.close()\n os.remove(file)\n def check_unique_module_name(self):\n \"\"\" Check that we can create a file in the writable directory\n \"\"\"\n q = catalog.catalog()\n file = q.unique_module_name('bob')\n cfile1 = file+'.cpp'\n assert(not os.path.exists(cfile1))\n #make sure it is writable\n try:\n f = open(cfile1,'w')\n f.write('bob')\n finally: \n f.close()\n # try again with same code fragment -- should get unique name\n file = q.unique_module_name('bob')\n cfile2 = file+'.cpp'\n assert(not os.path.exists(cfile2+'.cpp'))\n os.remove(cfile1)\n def check_add_function_persistent1(self):\n \"\"\" Test persisting a function in the default catalog\n \"\"\"\n clear_temp_catalog()\n q = catalog.catalog()\n # just use some already available functions\n import string\n funcs = [string.upper, string.lower, string.find,string.replace]\n for i in funcs:\n q.add_function_persistent('code',i)\n pfuncs = q.get_cataloged_functions('code') \n # any way to clean modules???\n restore_temp_catalog()\n for i in funcs:\n assert(i in pfuncs) \n \n def check_add_function_ordered(self):\n clear_temp_catalog()\n q = catalog.catalog()\n import string\n \n q.add_function('f',string.upper) \n q.add_function('f',string.lower)\n q.add_function('ff',string.find) \n q.add_function('ff',string.replace)\n q.add_function('fff',string.atof)\n q.add_function('fff',string.atoi)\n del q\n\n # now we're gonna make a new catalog with same code\n # but different functions in a specified module directory\n env_dir = empty_temp_dir()\n r = catalog.catalog(env_dir)\n r.add_function('ff',os.abort)\n r.add_function('ff',os.chdir)\n r.add_function('fff',os.access)\n r.add_function('fff',os.open)\n del r\n # now we're gonna make a new catalog with same code\n # but different functions in a user specified directory\n user_dir = empty_temp_dir()\n s = catalog.catalog(user_dir)\n import re\n s.add_function('fff',re.match)\n s.add_function('fff',re.purge)\n del s\n\n # open new catalog and make sure it retreives the functions\n # from d catalog instead of the temp catalog (made by q)\n os.environ['PYTHONCOMPILED'] = env_dir\n t = catalog.catalog(user_dir)\n funcs1 = t.get_functions('f')\n funcs2 = t.get_functions('ff')\n funcs3 = t.get_functions('fff')\n restore_temp_catalog()\n # make sure everything is read back in the correct order\n # a little cheating... I'm ignoring any functions that might have\n # been read in from a prior catalog file (such as the defualt one).\n # the test should really be made so that these aren't read in, but\n # until I get this figured out...\n #assert(funcs1 == [string.lower,string.upper])\n #assert(funcs2 == [os.chdir,os.abort,string.replace,string.find])\n #assert(funcs3 == [re.purge,re.match,os.open,\n # os.access,string.atoi,string.atof])\n assert(funcs1[:2] == [string.lower,string.upper]),`funcs1`\n assert(funcs2[:4] == [os.chdir,os.abort,string.replace,string.find])\n assert(funcs3[:6] == [re.purge,re.match,os.open,\n os.access,string.atoi,string.atof])\n cleanup_temp_dir(user_dir)\n cleanup_temp_dir(env_dir)\n \n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_default_dir,'check_'))\n suites.append( unittest.makeSuite(test_os_dependent_catalog_name,\n 'check_'))\n suites.append( unittest.makeSuite(test_catalog_path,'check_'))\n suites.append( unittest.makeSuite(test_get_catalog,'check_'))\n suites.append( unittest.makeSuite(test_catalog,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 15, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 29, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 35, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 58, "parameters": [ "path" ], "start_line": 41, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 48, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 61, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 11, "complexity": 4, "token_count": 82, "parameters": [ "self", "erase" ], "start_line": 73, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "remove_dir", "long_name": "remove_dir( self , d )", "filename": "test_catalog.py", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "self", "d" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 90, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 95, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 109, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "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": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 115, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 118, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 123, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 130, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 137, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 144, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 150, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "self" ], "start_line": 157, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 168, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 175, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 183, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 191, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 205, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 216, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 231, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 243, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 261, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 304, "parameters": [ "self" ], "start_line": 277, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_is_writable", "long_name": "check_is_writable( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 53, "parameters": [ "self" ], "start_line": 19, "end_line": 27, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_default", "long_name": "check_default( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 33, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_current", "long_name": "check_current( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_user", "long_name": "check_user( path )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 58, "parameters": [ "path" ], "start_line": 45, "end_line": 51, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_module", "long_name": "check_module( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 52, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_path", "long_name": "check_path( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self" ], "start_line": 59, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_bad_path", "long_name": "check_bad_path( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 65, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "get_test_dir", "long_name": "get_test_dir( self , erase = 0 )", "filename": "test_catalog.py", "nloc": 11, "complexity": 4, "token_count": 82, "parameters": [ "self", "erase" ], "start_line": 77, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "remove_dir", "long_name": "remove_dir( self , d )", "filename": "test_catalog.py", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "self", "d" ], "start_line": 90, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_nonexistent_catalog_is_none", "long_name": "check_nonexistent_catalog_is_none( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 94, "end_line": 98, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_create_catalog", "long_name": "check_create_catalog( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 99, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "clear_environ", "long_name": "clear_environ( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "self" ], "start_line": 107, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "reset_environ", "long_name": "reset_environ( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 2, "token_count": 25, "parameters": [ "self" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "setUp", "long_name": "setUp( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "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": "tearDown", "long_name": "tearDown( self )", "filename": "test_catalog.py", "nloc": 2, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 119, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_module_directory", "long_name": "check_set_module_directory( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 122, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear_module_directory", "long_name": "check_clear_module_directory( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 127, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_environ_path", "long_name": "check_get_environ_path( self )", "filename": "test_catalog.py", "nloc": 7, "complexity": 2, "token_count": 65, "parameters": [ "self" ], "start_line": 134, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order1", "long_name": "check_build_search_order1( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 141, "end_line": 147, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order2", "long_name": "check_build_search_order2( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 148, "end_line": 153, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_build_search_order3", "long_name": "check_build_search_order3( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 154, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_build_search_order4", "long_name": "check_build_search_order4( self )", "filename": "test_catalog.py", "nloc": 8, "complexity": 2, "token_count": 87, "parameters": [ "self" ], "start_line": 161, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_catalog_files1", "long_name": "check_catalog_files1( self )", "filename": "test_catalog.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 172, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_catalog_files2", "long_name": "check_catalog_files2( self )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 179, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_get_existing_files1", "long_name": "check_get_existing_files1( self )", "filename": "test_catalog.py", "nloc": 6, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 187, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_get_existing_files2", "long_name": "check_get_existing_files2( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 195, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_access_writable_file", "long_name": "check_access_writable_file( self )", "filename": "test_catalog.py", "nloc": 9, "complexity": 2, "token_count": 49, "parameters": [ "self" ], "start_line": 209, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_writable_with_bad_path", "long_name": "check_writable_with_bad_path( self )", "filename": "test_catalog.py", "nloc": 12, "complexity": 3, "token_count": 79, "parameters": [ "self" ], "start_line": 220, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_writable_dir", "long_name": "check_writable_dir( self )", "filename": "test_catalog.py", "nloc": 10, "complexity": 2, "token_count": 61, "parameters": [ "self" ], "start_line": 235, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_unique_module_name", "long_name": "check_unique_module_name( self )", "filename": "test_catalog.py", "nloc": 14, "complexity": 2, "token_count": 94, "parameters": [ "self" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_add_function_persistent1", "long_name": "check_add_function_persistent1( self )", "filename": "test_catalog.py", "nloc": 11, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 265, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_add_function_ordered", "long_name": "check_add_function_ordered( self )", "filename": "test_catalog.py", "nloc": 36, "complexity": 1, "token_count": 304, "parameters": [ "self" ], "start_line": 281, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 54, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_catalog.py", "nloc": 11, "complexity": 2, "token_count": 91, "parameters": [ "level" ], "start_line": 337, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 350, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_catalog.py", "nloc": 11, "complexity": 2, "token_count": 91, "parameters": [ "level" ], "start_line": 337, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_catalog.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 350, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 260, "complexity": 48, "token_count": 1887, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import catalog", "set_local_path()", " ScipyTest('weave.catalog').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "from scipy_distutils.misc_util import add_local_to_path", "", "add_grandparent_to_path(__name__)", "import catalog", "reload(catalog) # this'll pick up any recent code changes", "add_local_to_path(__name__)", "", "", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_default_dir,'check_'))", " suites.append( unittest.makeSuite(test_os_dependent_catalog_name,", " 'check_'))", " suites.append( unittest.makeSuite(test_catalog_path,'check_'))", " suites.append( unittest.makeSuite(test_get_catalog,'check_'))", " suites.append( unittest.makeSuite(test_catalog,'check_'))", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", " test()" ] } }, { "old_path": "weave/tests/test_ext_tools.py", "new_path": "weave/tests/test_ext_tools.py", "filename": "test_ext_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,18 +1,16 @@\n import unittest\n import time\n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-from scipy_distutils.misc_util import add_local_to_path\n-\n-add_grandparent_to_path(__name__)\n-import ext_tools\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import ext_tools, c_spec\n try:\n- from standard_array_spec import array_converter\n+ from weave.standard_array_spec import array_converter\n except ImportError:\n pass # requires Numeric \n restore_path()\n \n-add_local_to_path(__name__)\n+set_local_path()\n from weave_test_utils import *\n restore_path()\n \n@@ -21,12 +19,12 @@\n \n class test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n- def check_simple(self):\n+ def check_simple(self,level=5):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n- def check_multi_functions(self):\n+ def check_multi_functions(self,level=5):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n@@ -38,7 +36,7 @@ def check_multi_functions(self):\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n- def check_with_include(self):\n+ def check_with_include(self,level=5):\n # decalaring variables\n a = 2.;\n \n@@ -59,7 +57,7 @@ def check_with_include(self):\n import ext_module_with_include\n ext_module_with_include.test(a)\n \n- def check_string_and_int(self): \n+ def check_string_and_int(self,level=5): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n@@ -75,7 +73,7 @@ def check_string_and_int(self):\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n- def check_return_tuple(self): \n+ def check_return_tuple(self,level=5): \n # decalaring variables\n a = 2 \n # declare module\n@@ -98,7 +96,7 @@ def check_return_tuple(self):\n \n class test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n- def check_simple(self):\n+ def check_simple(self,level=5):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n@@ -129,29 +127,12 @@ def check_assign_variable_types(self):\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n- import c_spec\n+\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n \n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_assign_variable_types,'check_'))\n- if level >= 5: \n- suites.append( unittest.makeSuite(test_ext_module,'check_'))\n- suites.append( unittest.makeSuite(test_ext_function,'check_')) \n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.ext_tools').run()\n", "added_lines": 13, "deleted_lines": 32, "source_code": "import unittest\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import ext_tools, c_spec\ntry:\n from weave.standard_array_spec import array_converter\nexcept ImportError:\n pass # requires Numeric \nrestore_path()\n\nset_local_path()\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self,level=5):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self,level=5):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self,level=5): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self,level=5): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n return_val = returned;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self,level=5):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(unittest.TestCase): \n def check_assign_variable_types(self):\n try:\n from Numeric import arange, Float32, Float64\n except:\n # skip this test if Numeric not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\nif __name__ == \"__main__\":\n ScipyTest('weave.ext_tools').run()\n", "source_code_before": "import unittest\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ext_tools\ntry:\n from standard_array_spec import array_converter\nexcept ImportError:\n pass # requires Numeric \nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nbuild_dir = empty_temp_dir()\nprint 'building extensions here:', build_dir \n\nclass test_ext_module(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible module \"\"\"\n mod = ext_tools.ext_module('simple_ext_module')\n mod.compile(location = build_dir)\n import simple_ext_module\n def check_multi_functions(self):\n mod = ext_tools.ext_module('module_multi_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n test2 = ext_tools.ext_function_from_specs('test2',code,var_specs)\n mod.add_function(test2)\n mod.compile(location = build_dir)\n import module_multi_function\n module_multi_function.test()\n module_multi_function.test2()\n def check_with_include(self):\n # decalaring variables\n a = 2.;\n \n # declare module\n mod = ext_tools.ext_module('ext_module_with_include')\n mod.customize.add_header('')\n \n # function 2 --> a little more complex expression\n var_specs = ext_tools.assign_variable_types(['a'],locals(),globals())\n code = \"\"\"\n std::cout << std::endl;\n std::cout << \"test printing a value:\" << a << std::endl;\n \"\"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n # build module\n mod.compile(location = build_dir)\n import ext_module_with_include\n ext_module_with_include.test(a)\n\n def check_string_and_int(self): \n # decalaring variables\n a = 2;b = 'string' \n # declare module\n mod = ext_tools.ext_module('ext_string_and_int')\n code = \"\"\"\n a=b.length();\n return_val = PyInt_FromLong(a);\n \"\"\"\n test = ext_tools.ext_function('test',code,['a','b'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_string_and_int\n c = ext_string_and_int.test(a,b)\n assert(c == len(b))\n \n def check_return_tuple(self): \n # decalaring variables\n a = 2 \n # declare module\n mod = ext_tools.ext_module('ext_return_tuple')\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n int b;\n b = a + 1;\n py::tuple returned(2);\n returned[0] = a;\n returned[1] = b;\n return_val = returned;\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'])\n mod.add_function(test)\n mod.compile(location = build_dir)\n import ext_return_tuple\n c,d = ext_return_tuple.test(a)\n assert(c==a and d == a+1)\n \nclass test_ext_function(unittest.TestCase):\n #should really do some testing of where modules end up\n def check_simple(self):\n \"\"\" Simplest possible function \"\"\"\n mod = ext_tools.ext_module('simple_ext_function')\n var_specs = []\n code = \"\"\n test = ext_tools.ext_function_from_specs('test',code,var_specs)\n mod.add_function(test)\n mod.compile(location = build_dir)\n import simple_ext_function\n simple_ext_function.test()\n \nclass test_assign_variable_types(unittest.TestCase): \n def check_assign_variable_types(self):\n try:\n from Numeric import arange, Float32, Float64\n except:\n # skip this test if Numeric not installed\n return\n \n import types\n a = arange(10,typecode = Float32)\n b = arange(5,typecode = Float64)\n c = 5\n arg_list = ['a','b','c']\n actual = ext_tools.assign_variable_types(arg_list,locals()) \n #desired = {'a':(Float32,1),'b':(Float32,1),'i':(Int32,0)}\n \n ad = array_converter()\n ad.name, ad.var_type, ad.dims = 'a', Float32, 1\n bd = array_converter()\n bd.name, bd.var_type, bd.dims = 'b', Float64, 1\n import c_spec\n cd = c_spec.int_converter()\n cd.name, cd.var_type = 'c', types.IntType \n desired = [ad,bd,cd]\n expr = \"\"\n print_assert_equal(expr,actual,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_assign_variable_types,'check_'))\n if level >= 5: \n suites.append( unittest.makeSuite(test_ext_module,'check_'))\n suites.append( unittest.makeSuite(test_ext_function,'check_')) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_simple", "long_name": "check_simple( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 22, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 80, "parameters": [ "self", "level" ], "start_line": 27, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_with_include", "long_name": "check_with_include( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 85, "parameters": [ "self", "level" ], "start_line": 39, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 78, "parameters": [ "self", "level" ], "start_line": 60, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 89, "parameters": [ "self", "level" ], "start_line": 76, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 58, "parameters": [ "self", "level" ], "start_line": 99, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_assign_variable_types", "long_name": "check_assign_variable_types( self )", "filename": "test_ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 148, "parameters": [ "self" ], "start_line": 111, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 76, "parameters": [ "self" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_with_include", "long_name": "check_with_include( self )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 81, "parameters": [ "self" ], "start_line": 41, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 62, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 1, "token_count": 54, "parameters": [ "self" ], "start_line": 101, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_assign_variable_types", "long_name": "check_assign_variable_types( self )", "filename": "test_ext_tools.py", "nloc": 21, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 113, "end_line": 137, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 3, "token_count": 70, "parameters": [ "level" ], "start_line": 140, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 24, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_with_include", "long_name": "check_with_include( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 85, "parameters": [ "self", "level" ], "start_line": 39, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_assign_variable_types", "long_name": "check_assign_variable_types( self )", "filename": "test_ext_tools.py", "nloc": 20, "complexity": 2, "token_count": 148, "parameters": [ "self" ], "start_line": 111, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_ext_tools.py", "nloc": 9, "complexity": 3, "token_count": 70, "parameters": [ "level" ], "start_line": 140, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "check_with_include", "long_name": "check_with_include( self )", "filename": "test_ext_tools.py", "nloc": 14, "complexity": 1, "token_count": 81, "parameters": [ "self" ], "start_line": 41, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_ext_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 150, "end_line": 154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 80, "parameters": [ "self", "level" ], "start_line": 27, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_multi_functions", "long_name": "check_multi_functions( self )", "filename": "test_ext_tools.py", "nloc": 12, "complexity": 1, "token_count": 76, "parameters": [ "self" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 74, "parameters": [ "self" ], "start_line": 62, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 85, "parameters": [ "self" ], "start_line": 78, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_return_tuple", "long_name": "check_return_tuple( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 18, "complexity": 2, "token_count": 89, "parameters": [ "self", "level" ], "start_line": 76, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string_and_int", "long_name": "check_string_and_int( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 13, "complexity": 1, "token_count": 78, "parameters": [ "self", "level" ], "start_line": 60, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_simple", "long_name": "check_simple( self , level = 5 )", "filename": "test_ext_tools.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 22, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 110, "complexity": 9, "token_count": 663, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import ext_tools, c_spec", " from weave.standard_array_spec import array_converter", "set_local_path()", " def check_simple(self,level=5):", " def check_multi_functions(self,level=5):", " def check_with_include(self,level=5):", " def check_string_and_int(self,level=5):", " def check_return_tuple(self,level=5):", " def check_simple(self,level=5):", "", " ScipyTest('weave.ext_tools').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "from scipy_distutils.misc_util import add_local_to_path", "", "add_grandparent_to_path(__name__)", "import ext_tools", " from standard_array_spec import array_converter", "add_local_to_path(__name__)", " def check_simple(self):", " def check_multi_functions(self):", " def check_with_include(self):", " def check_string_and_int(self):", " def check_return_tuple(self):", " def check_simple(self):", " import c_spec", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_assign_variable_types,'check_'))", " if level >= 5:", " suites.append( unittest.makeSuite(test_ext_module,'check_'))", " suites.append( unittest.makeSuite(test_ext_function,'check_'))", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/tests/test_inline_tools.py", "new_path": "weave/tests/test_inline_tools.py", "filename": "test_inline_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,11 +1,12 @@\n import unittest\n from Numeric import *\n \n-from scipy_distutils.misc_util import add_grandparent_to_path,restore_path\n-from scipy_distutils.misc_util import add_local_to_path\n-\n-add_grandparent_to_path(__name__)\n-import inline_tools\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import inline_tools\n+restore_path()\n+set_local_path()\n+from test_scxx import *\n restore_path()\n \n class test_inline(unittest.TestCase):\n@@ -13,7 +14,7 @@ class test_inline(unittest.TestCase):\n \n I'd like to benchmark these things somehow.\n \"\"\"\n- def check_exceptions(self):\n+ def check_exceptions(self,level=5):\n a = 3 \n code = \"\"\"\n if (a < 2)\n@@ -40,19 +41,6 @@ def check_exceptions(self):\n except: \n # ?CompileError is the error reported, but catching it doesn't work\n pass\n- \n-def test_suite(level=1):\n- suites = []\n- if level >= 5:\n- suites.append( unittest.makeSuite(test_inline,'check_') ) \n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n \n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.inline_tools').run()\n", "added_lines": 8, "deleted_lines": 20, "source_code": "import unittest\nfrom Numeric import *\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\nset_local_path()\nfrom test_scxx import *\nrestore_path()\n\nclass test_inline(unittest.TestCase):\n \"\"\" These are long running tests...\n \n I'd like to benchmark these things somehow.\n \"\"\"\n def check_exceptions(self,level=5):\n a = 3 \n code = \"\"\"\n if (a < 2)\n throw_error(PyExc_ValueError,\n \"the variable 'a' should not be less than 2\");\n else \n return_val = PyInt_FromLong(a+1);\n \"\"\"\n result = inline_tools.inline(code,['a'])\n assert(result == 4)\n \n try:\n a = 1\n result = inline_tools.inline(code,['a'])\n assert(1) # should've thrown a ValueError\n except ValueError:\n pass\n \n from distutils.errors import DistutilsError, CompileError \n try:\n a = 'string'\n result = inline_tools.inline(code,['a'])\n assert(1) # should've gotten an error\n except: \n # ?CompileError is the error reported, but catching it doesn't work\n pass\n\nif __name__ == \"__main__\":\n ScipyTest('weave.inline_tools').run()\n", "source_code_before": "import unittest\nfrom Numeric import *\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\nclass test_inline(unittest.TestCase):\n \"\"\" These are long running tests...\n \n I'd like to benchmark these things somehow.\n \"\"\"\n def check_exceptions(self):\n a = 3 \n code = \"\"\"\n if (a < 2)\n throw_error(PyExc_ValueError,\n \"the variable 'a' should not be less than 2\");\n else \n return_val = PyInt_FromLong(a+1);\n \"\"\"\n result = inline_tools.inline(code,['a'])\n assert(result == 4)\n \n try:\n a = 1\n result = inline_tools.inline(code,['a'])\n assert(1) # should've thrown a ValueError\n except ValueError:\n pass\n \n from distutils.errors import DistutilsError, CompileError \n try:\n a = 'string'\n result = inline_tools.inline(code,['a'])\n assert(1) # should've gotten an error\n except: \n # ?CompileError is the error reported, but catching it doesn't work\n pass\n \ndef test_suite(level=1):\n suites = []\n if level >= 5:\n suites.append( unittest.makeSuite(test_inline,'check_') ) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_exceptions", "long_name": "check_exceptions( self , level = 5 )", "filename": "test_inline_tools.py", "nloc": 24, "complexity": 3, "token_count": 90, "parameters": [ "self", "level" ], "start_line": 17, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_exceptions", "long_name": "check_exceptions( self )", "filename": "test_inline_tools.py", "nloc": 24, "complexity": 3, "token_count": 86, "parameters": [ "self" ], "start_line": 16, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 44, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_inline_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 51, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_inline_tools.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 44, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_inline_tools.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 51, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_exceptions", "long_name": "check_exceptions( self , level = 5 )", "filename": "test_inline_tools.py", "nloc": 24, "complexity": 3, "token_count": 90, "parameters": [ "self", "level" ], "start_line": 17, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "check_exceptions", "long_name": "check_exceptions( self )", "filename": "test_inline_tools.py", "nloc": 24, "complexity": 3, "token_count": 86, "parameters": [ "self" ], "start_line": 16, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 } ], "nloc": 40, "complexity": 3, "token_count": 145, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import inline_tools", "restore_path()", "set_local_path()", "from test_scxx import *", " def check_exceptions(self,level=5):", " ScipyTest('weave.inline_tools').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path,restore_path", "from scipy_distutils.misc_util import add_local_to_path", "", "add_grandparent_to_path(__name__)", "import inline_tools", " def check_exceptions(self):", "", "def test_suite(level=1):", " suites = []", " if level >= 5:", " suites.append( unittest.makeSuite(test_inline,'check_') )", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", " test()" ] } }, { "old_path": "weave/tests/test_scxx.py", "new_path": "weave/tests/test_scxx.py", "filename": "test_scxx.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,30 +3,14 @@\n import unittest\n import time\n import os,sys\n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n \n-add_grandparent_to_path(__name__)\n-import inline_tools\n+from scipy_test.testing import *\n+set_local_path()\n+from test_scxx_object import *\n+from test_scxx_sequence import *\n+from test_scxx_dict import *\n restore_path()\n \n-def test_suite(level=1):\n- from unittest import makeSuite\n- suites = [] \n- if level >= 5:\n- import test_scxx_object\n- suites.append( test_scxx_object.test_suite(level))\n- import test_scxx_sequence\n- suites.append( test_scxx_sequence.test_suite(level))\n- import test_scxx_dict\n- suites.append( test_scxx_dict.test_suite(level))\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10,verbose=2):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner(verbosity=verbose)\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.inline_tools').run()\n+\n", "added_lines": 7, "deleted_lines": 23, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_local_path()\nfrom test_scxx_object import *\nfrom test_scxx_sequence import *\nfrom test_scxx_dict import *\nrestore_path()\n\nif __name__ == \"__main__\":\n ScipyTest('weave.inline_tools').run()\n\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n import test_scxx_object\n suites.append( test_scxx_object.test_suite(level))\n import test_scxx_sequence\n suites.append( test_scxx_sequence.test_suite(level))\n import test_scxx_dict\n suites.append( test_scxx_dict.test_suite(level))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [], "methods_before": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "level" ], "start_line": 12, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx.py", "nloc": 12, "complexity": 2, "token_count": 69, "parameters": [ "level" ], "start_line": 12, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 13, "complexity": 0, "token_count": 46, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_local_path()", "from test_scxx_object import *", "from test_scxx_sequence import *", "from test_scxx_dict import *", " ScipyTest('weave.inline_tools').run()", "" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "add_grandparent_to_path(__name__)", "import inline_tools", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " import test_scxx_object", " suites.append( test_scxx_object.test_suite(level))", " import test_scxx_sequence", " suites.append( test_scxx_sequence.test_suite(level))", " import test_scxx_dict", " suites.append( test_scxx_dict.test_suite(level))", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbose=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbose)", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/tests/test_scxx_dict.py", "new_path": "weave/tests/test_scxx_dict.py", "filename": "test_scxx_dict.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,18 +3,19 @@\n import unittest\n import time\n import os,sys\n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n \n-add_grandparent_to_path(__name__)\n-import inline_tools\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import inline_tools\n restore_path()\n \n+\n class test_dict_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n- def check_empty(self):\n+ def check_empty(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::dict val;\n@@ -26,7 +27,7 @@ def check_empty(self):\n \n \n class test_dict_has_key(unittest.TestCase):\n- def check_obj(self):\n+ def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n@@ -37,7 +38,7 @@ class foo:\n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n- def check_int(self):\n+ def check_int(self,level=5):\n a = {}\n a[1234] = 12345\n code = \"\"\"\n@@ -45,7 +46,7 @@ def check_int(self):\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n- def check_double(self):\n+ def check_double(self,level=5):\n a = {}\n a[1234.] = 12345\n code = \"\"\"\n@@ -53,7 +54,7 @@ def check_double(self):\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n- def check_complex(self):\n+ def check_complex(self,level=5):\n a = {}\n a[1+1j] = 12345\n key = 1+1j\n@@ -63,7 +64,7 @@ def check_complex(self):\n res = inline_tools.inline(code,['a','key'])\n assert res\n \n- def check_string(self):\n+ def check_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n@@ -71,7 +72,7 @@ def check_string(self):\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n- def check_std_string(self):\n+ def check_std_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n key_name = \"b\"\n@@ -80,7 +81,7 @@ def check_std_string(self):\n \"\"\"\n res = inline_tools.inline(code,['a','key_name'])\n assert res \n- def check_string_fail(self):\n+ def check_string_fail(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n@@ -98,10 +99,10 @@ def generic_get(self,code,args=['a']):\n res = inline_tools.inline(code,args)\n assert res == a['b']\n \n- def check_char(self):\n+ def check_char(self,level=5):\n self.generic_get('return_val = a[\"b\"];')\n \n- def DOESNT_WORK_check_char_fail(self):\n+ def DOESNT_WORK_check_char_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n@@ -109,18 +110,18 @@ def DOESNT_WORK_check_char_fail(self):\n except KeyError:\n pass\n \n- def check_string(self):\n+ def check_string(self,level=5):\n self.generic_get('return_val = a[std::string(\"b\")];')\n \n \n- def check_obj(self):\n+ def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n \n- def DOESNT_WORK_check_obj_fail(self):\n+ def DOESNT_WORK_check_obj_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n@@ -163,37 +164,37 @@ def generic_overwrite(self,key,val):\n assert before == after\n assert before_overwritten == after_overwritten\n \n- def check_new_int_int(self):\n+ def check_new_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_new(key,val)\n- def check_new_double_int(self):\n+ def check_new_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_new(key,val)\n- def check_new_std_string_int(self):\n+ def check_new_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_new(key,val)\n- def check_new_complex_int(self):\n+ def check_new_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_new(key,val)\n- def check_new_obj_int(self):\n+ def check_new_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_new(key,val)\n \n- def check_overwrite_int_int(self):\n+ def check_overwrite_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_overwrite(key,val)\n- def check_overwrite_double_int(self):\n+ def check_overwrite_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_overwrite(key,val)\n- def check_overwrite_std_string_int(self):\n+ def check_overwrite_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_overwrite(key,val)\n- def check_overwrite_complex_int(self):\n+ def check_overwrite_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_overwrite(key,val)\n- def check_overwrite_obj_int(self):\n+ def check_overwrite_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n@@ -215,71 +216,51 @@ def generic(self,key):\n after = sys.getrefcount(a), sys.getrefcount(key)\n assert before[0] == after[0]\n assert before[1] == after[1] + 1\n- def check_int(self):\n+ def check_int(self,level=5):\n key = 1234\n self.generic(key)\n- def check_double(self):\n+ def check_double(self,level=5):\n key = 1234.\n self.generic(key)\n- def check_std_string(self):\n+ def check_std_string(self,level=5):\n key = \"hello\"\n self.generic(key)\n- def check_complex(self):\n+ def check_complex(self,level=5):\n key = 1+1j\n self.generic(key)\n- def check_obj(self):\n+ def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n self.generic(key)\n \n class test_dict_others(unittest.TestCase):\n- def check_clear(self):\n+ def check_clear(self,level=5):\n a = {}\n a[\"hello\"] = 1\n inline_tools.inline(\"a.clear();\",['a'])\n assert not a\n- def check_items(self):\n+ def check_items(self,level=5):\n a = {}\n a[\"hello\"] = 1\n items = inline_tools.inline(\"return_val = a.items();\",['a'])\n assert items == a.items()\n- def check_values(self):\n+ def check_values(self,level=5):\n a = {}\n a[\"hello\"] = 1\n values = inline_tools.inline(\"return_val = a.values();\",['a'])\n assert values == a.values()\n- def check_keys(self):\n+ def check_keys(self,level=5):\n a = {}\n a[\"hello\"] = 1\n keys = inline_tools.inline(\"return_val = a.keys();\",['a'])\n assert keys == a.keys()\n- def check_update(self):\n+ def check_update(self,level=5):\n a,b = {},{}\n a[\"hello\"] = 1\n b[\"hello\"] = 2\n inline_tools.inline(\"a.update(b);\",['a','b'])\n assert a == b\n- \n-def test_suite(level=1):\n- from unittest import makeSuite\n- suites = [] \n- if level >= 5: \n- suites.append( makeSuite(test_dict_construct,'check_'))\n- suites.append( makeSuite(test_dict_has_key,'check_')) \n- suites.append( makeSuite(test_dict_get_item_op,'check_'))\n- suites.append( makeSuite(test_dict_set_operator,'check_'))\n- suites.append( makeSuite(test_dict_del,'check_'))\n- suites.append( makeSuite(test_dict_others,'check_'))\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10,verbose=2):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner(verbosity=verbose)\n- runner.run(all_tests)\n- return runner\n \n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.scxx').run()\n", "added_lines": 38, "deleted_lines": 57, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\n\nclass test_dict_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_empty(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::dict val;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == {}\n \n \nclass test_dict_has_key(unittest.TestCase):\n def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n a = {}\n a[key] = 12345\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n def check_int(self,level=5):\n a = {}\n a[1234] = 12345\n code = \"\"\"\n return_val = a.has_key(1234); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_double(self,level=5):\n a = {}\n a[1234.] = 12345\n code = \"\"\"\n return_val = a.has_key(1234.); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_complex(self,level=5):\n a = {}\n a[1+1j] = 12345\n key = 1+1j\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n \n def check_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self,level=5):\n a = {}\n a[\"b\"] = 12345\n key_name = \"b\"\n code = \"\"\"\n return_val = a.has_key(key_name); \n \"\"\"\n res = inline_tools.inline(code,['a','key_name'])\n assert res \n def check_string_fail(self,level=5):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n\nclass test_dict_get_item_op(unittest.TestCase):\n\n def generic_get(self,code,args=['a']):\n a = {}\n a['b'] = 12345\n \n res = inline_tools.inline(code,args)\n assert res == a['b']\n\n def check_char(self,level=5):\n self.generic_get('return_val = a[\"b\"];')\n\n def DOESNT_WORK_check_char_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n self.generic_get('return_val = a[\"c\"];')\n except KeyError:\n pass\n \n def check_string(self,level=5):\n self.generic_get('return_val = a[std::string(\"b\")];')\n\n\n def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n\n def DOESNT_WORK_check_obj_fail(self,level=5):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n except KeyError:\n pass \n \nclass test_dict_set_operator(unittest.TestCase):\n def generic_new(self,key,val):\n # test that value is set correctly and that reference counts\n # on dict, key, and val are being handled correctly.\n a = {}\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n assert before == after\n def generic_overwrite(self,key,val):\n a = {}\n overwritten = 1\n a[key] = overwritten # put an item in the dict to be overwritten\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n before_overwritten = sys.getrefcount(overwritten)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n after_overwritten = sys.getrefcount(overwritten)\n assert before == after\n assert before_overwritten == after_overwritten\n \n def check_new_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_new(key,val)\n def check_new_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_new(key,val)\n def check_new_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_new(key,val)\n def check_new_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_new(key,val)\n def check_new_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_new(key,val)\n\n def check_overwrite_int_int(self,level=5):\n key,val = 1234,12345\n self.generic_overwrite(key,val)\n def check_overwrite_double_int(self,level=5):\n key,val = 1234.,12345\n self.generic_overwrite(key,val)\n def check_overwrite_std_string_int(self,level=5):\n key,val = \"hello\",12345\n self.generic_overwrite(key,val)\n def check_overwrite_complex_int(self,level=5):\n key,val = 1+1j,12345\n self.generic_overwrite(key,val)\n def check_overwrite_obj_int(self,level=5):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_overwrite(key,val)\n \nclass test_dict_del(unittest.TestCase):\n def generic(self,key):\n # test that value is set correctly and that reference counts\n # on dict, key, are being handled correctly. after deletion,\n # the keys refcount should be one less than before.\n a = {}\n a[key] = 1\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n a[key] = 1\n before = sys.getrefcount(a), sys.getrefcount(key)\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n after = sys.getrefcount(a), sys.getrefcount(key)\n assert before[0] == after[0]\n assert before[1] == after[1] + 1\n def check_int(self,level=5):\n key = 1234\n self.generic(key)\n def check_double(self,level=5):\n key = 1234.\n self.generic(key)\n def check_std_string(self,level=5):\n key = \"hello\"\n self.generic(key)\n def check_complex(self,level=5):\n key = 1+1j\n self.generic(key)\n def check_obj(self,level=5):\n class foo:\n pass\n key = foo()\n self.generic(key)\n\nclass test_dict_others(unittest.TestCase):\n def check_clear(self,level=5):\n a = {}\n a[\"hello\"] = 1\n inline_tools.inline(\"a.clear();\",['a'])\n assert not a\n def check_items(self,level=5):\n a = {}\n a[\"hello\"] = 1\n items = inline_tools.inline(\"return_val = a.items();\",['a'])\n assert items == a.items()\n def check_values(self,level=5):\n a = {}\n a[\"hello\"] = 1\n values = inline_tools.inline(\"return_val = a.values();\",['a'])\n assert values == a.values()\n def check_keys(self,level=5):\n a = {}\n a[\"hello\"] = 1\n keys = inline_tools.inline(\"return_val = a.keys();\",['a'])\n assert keys == a.keys()\n def check_update(self,level=5):\n a,b = {},{}\n a[\"hello\"] = 1\n b[\"hello\"] = 2\n inline_tools.inline(\"a.update(b);\",['a','b'])\n assert a == b\n\nif __name__ == \"__main__\":\n ScipyTest('weave.scxx').run()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\nclass test_dict_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_empty(self):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::dict val;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == {}\n \n \nclass test_dict_has_key(unittest.TestCase):\n def check_obj(self):\n class foo:\n pass\n key = foo()\n a = {}\n a[key] = 12345\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n def check_int(self):\n a = {}\n a[1234] = 12345\n code = \"\"\"\n return_val = a.has_key(1234); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_double(self):\n a = {}\n a[1234.] = 12345\n code = \"\"\"\n return_val = a.has_key(1234.); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_complex(self):\n a = {}\n a[1+1j] = 12345\n key = 1+1j\n code = \"\"\"\n return_val = a.has_key(key); \n \"\"\"\n res = inline_tools.inline(code,['a','key'])\n assert res\n \n def check_string(self):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self):\n a = {}\n a[\"b\"] = 12345\n key_name = \"b\"\n code = \"\"\"\n return_val = a.has_key(key_name); \n \"\"\"\n res = inline_tools.inline(code,['a','key_name'])\n assert res \n def check_string_fail(self):\n a = {}\n a[\"b\"] = 12345\n code = \"\"\"\n return_val = a.has_key(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n\nclass test_dict_get_item_op(unittest.TestCase):\n\n def generic_get(self,code,args=['a']):\n a = {}\n a['b'] = 12345\n \n res = inline_tools.inline(code,args)\n assert res == a['b']\n\n def check_char(self):\n self.generic_get('return_val = a[\"b\"];')\n\n def DOESNT_WORK_check_char_fail(self):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n self.generic_get('return_val = a[\"c\"];')\n except KeyError:\n pass\n \n def check_string(self):\n self.generic_get('return_val = a[std::string(\"b\")];')\n\n\n def check_obj(self):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n\n def DOESNT_WORK_check_obj_fail(self):\n # We can't through a KeyError for dicts on RHS of\n # = but not on LHS. Not sure how to deal with this.\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a[name];\n \"\"\" \n self.generic_get(code,['a'])\n except KeyError:\n pass \n \nclass test_dict_set_operator(unittest.TestCase):\n def generic_new(self,key,val):\n # test that value is set correctly and that reference counts\n # on dict, key, and val are being handled correctly.\n a = {}\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n assert before == after\n def generic_overwrite(self,key,val):\n a = {}\n overwritten = 1\n a[key] = overwritten # put an item in the dict to be overwritten\n # call once to handle mysterious addition of one ref count\n # on first call to inline.\n before_overwritten = sys.getrefcount(overwritten)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n before = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n inline_tools.inline(\"a[key] = val;\",['a','key','val'])\n assert a[key] == val\n after = sys.getrefcount(a), sys.getrefcount(key), sys.getrefcount(val)\n after_overwritten = sys.getrefcount(overwritten)\n assert before == after\n assert before_overwritten == after_overwritten\n \n def check_new_int_int(self):\n key,val = 1234,12345\n self.generic_new(key,val)\n def check_new_double_int(self):\n key,val = 1234.,12345\n self.generic_new(key,val)\n def check_new_std_string_int(self):\n key,val = \"hello\",12345\n self.generic_new(key,val)\n def check_new_complex_int(self):\n key,val = 1+1j,12345\n self.generic_new(key,val)\n def check_new_obj_int(self):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_new(key,val)\n\n def check_overwrite_int_int(self):\n key,val = 1234,12345\n self.generic_overwrite(key,val)\n def check_overwrite_double_int(self):\n key,val = 1234.,12345\n self.generic_overwrite(key,val)\n def check_overwrite_std_string_int(self):\n key,val = \"hello\",12345\n self.generic_overwrite(key,val)\n def check_overwrite_complex_int(self):\n key,val = 1+1j,12345\n self.generic_overwrite(key,val)\n def check_overwrite_obj_int(self):\n class foo:\n pass\n key,val = foo(),12345\n self.generic_overwrite(key,val)\n \nclass test_dict_del(unittest.TestCase):\n def generic(self,key):\n # test that value is set correctly and that reference counts\n # on dict, key, are being handled correctly. after deletion,\n # the keys refcount should be one less than before.\n a = {}\n a[key] = 1\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n a[key] = 1\n before = sys.getrefcount(a), sys.getrefcount(key)\n inline_tools.inline(\"a.del(key);\",['a','key'])\n assert not a.has_key(key)\n after = sys.getrefcount(a), sys.getrefcount(key)\n assert before[0] == after[0]\n assert before[1] == after[1] + 1\n def check_int(self):\n key = 1234\n self.generic(key)\n def check_double(self):\n key = 1234.\n self.generic(key)\n def check_std_string(self):\n key = \"hello\"\n self.generic(key)\n def check_complex(self):\n key = 1+1j\n self.generic(key)\n def check_obj(self):\n class foo:\n pass\n key = foo()\n self.generic(key)\n\nclass test_dict_others(unittest.TestCase):\n def check_clear(self):\n a = {}\n a[\"hello\"] = 1\n inline_tools.inline(\"a.clear();\",['a'])\n assert not a\n def check_items(self):\n a = {}\n a[\"hello\"] = 1\n items = inline_tools.inline(\"return_val = a.items();\",['a'])\n assert items == a.items()\n def check_values(self):\n a = {}\n a[\"hello\"] = 1\n values = inline_tools.inline(\"return_val = a.values();\",['a'])\n assert values == a.values()\n def check_keys(self):\n a = {}\n a[\"hello\"] = 1\n keys = inline_tools.inline(\"return_val = a.keys();\",['a'])\n assert keys == a.keys()\n def check_update(self):\n a,b = {},{}\n a[\"hello\"] = 1\n b[\"hello\"] = 2\n inline_tools.inline(\"a.update(b);\",['a','b'])\n assert a == b\n \ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5: \n suites.append( makeSuite(test_dict_construct,'check_'))\n suites.append( makeSuite(test_dict_has_key,'check_')) \n suites.append( makeSuite(test_dict_get_item_op,'check_'))\n suites.append( makeSuite(test_dict_set_operator,'check_'))\n suites.append( makeSuite(test_dict_del,'check_'))\n suites.append( makeSuite(test_dict_others,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_empty", "long_name": "check_empty( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 34, "parameters": [ "self", "level" ], "start_line": 18, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 11, "complexity": 1, "token_count": 47, "parameters": [ "self", "level" ], "start_line": 30, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 36, "parameters": [ "self", "level" ], "start_line": 41, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 49, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "self", "level" ], "start_line": 57, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 36, "parameters": [ "self", "level" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 41, "parameters": [ "self", "level" ], "start_line": 75, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 84, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_get", "long_name": "generic_get( self , code , args = [ 'a' ] )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "args" ], "start_line": 95, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "level" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_char_fail", "long_name": "DOESNT_WORK_check_char_fail( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 2, "token_count": 21, "parameters": [ "self", "level" ], "start_line": 105, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "level" ], "start_line": 113, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 22, "parameters": [ "self", "level" ], "start_line": 117, "end_line": 122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_obj_fail", "long_name": "DOESNT_WORK_check_obj_fail( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 124, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 103, "parameters": [ "self", "key", "val" ], "start_line": 137, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "generic_overwrite", "long_name": "generic_overwrite( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 14, "complexity": 1, "token_count": 132, "parameters": [ "self", "key", "val" ], "start_line": 150, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_new_int_int", "long_name": "check_new_int_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_double_int", "long_name": "check_new_double_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_std_string_int", "long_name": "check_new_std_string_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_complex_int", "long_name": "check_new_complex_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_obj_int", "long_name": "check_new_obj_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "level" ], "start_line": 179, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_overwrite_int_int", "long_name": "check_overwrite_int_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 185, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_double_int", "long_name": "check_overwrite_double_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_std_string_int", "long_name": "check_overwrite_std_string_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 191, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_complex_int", "long_name": "check_overwrite_complex_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 194, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_obj_int", "long_name": "check_overwrite_obj_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "level" ], "start_line": 197, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , key )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 1, "token_count": 115, "parameters": [ "self", "key" ], "start_line": 204, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 219, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 19, "parameters": [ "self", "level" ], "start_line": 222, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 225, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 228, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear", "long_name": "check_clear( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 238, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_items", "long_name": "check_items( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 243, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_values", "long_name": "check_values( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_keys", "long_name": "check_keys( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_update", "long_name": "check_update( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 46, "parameters": [ "self", "level" ], "start_line": 258, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_empty", "long_name": "check_empty( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 11, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 29, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 40, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 48, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 56, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 66, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 74, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_get", "long_name": "generic_get( self , code , args = [ 'a' ] )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "args" ], "start_line": 94, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 101, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_char_fail", "long_name": "DOESNT_WORK_check_char_fail( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 112, "end_line": 113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 116, "end_line": 121, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_obj_fail", "long_name": "DOESNT_WORK_check_obj_fail( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 123, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 103, "parameters": [ "self", "key", "val" ], "start_line": 136, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "generic_overwrite", "long_name": "generic_overwrite( self , key , val )", "filename": "test_scxx_dict.py", "nloc": 14, "complexity": 1, "token_count": 132, "parameters": [ "self", "key", "val" ], "start_line": 149, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "check_new_int_int", "long_name": "check_new_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 166, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_double_int", "long_name": "check_new_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 169, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_std_string_int", "long_name": "check_new_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_complex_int", "long_name": "check_new_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_obj_int", "long_name": "check_new_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 178, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_overwrite_int_int", "long_name": "check_overwrite_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_double_int", "long_name": "check_overwrite_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 187, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_std_string_int", "long_name": "check_overwrite_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 190, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_complex_int", "long_name": "check_overwrite_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_obj_int", "long_name": "check_overwrite_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 196, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , key )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 1, "token_count": 115, "parameters": [ "self", "key" ], "start_line": 203, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 221, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 224, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 227, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 230, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_clear", "long_name": "check_clear( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_items", "long_name": "check_items( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 242, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_values", "long_name": "check_values( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 247, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_keys", "long_name": "check_keys( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 252, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_update", "long_name": "check_update( self )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 2, "token_count": 96, "parameters": [ "level" ], "start_line": 264, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 278, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_std_string", "long_name": "check_std_string( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 41, "parameters": [ "self", "level" ], "start_line": 75, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 40, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_dict.py", "nloc": 11, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 29, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_keys", "long_name": "check_keys( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 253, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_obj_fail", "long_name": "DOESNT_WORK_check_obj_fail( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 123, "end_line": 133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_new_double_int", "long_name": "check_new_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 169, "end_line": 171, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_std_string_int", "long_name": "check_new_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 172, "end_line": 174, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_std_string_int", "long_name": "check_overwrite_std_string_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 190, "end_line": 192, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_empty", "long_name": "check_empty( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_overwrite_double_int", "long_name": "check_overwrite_double_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self" ], "start_line": 187, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_keys", "long_name": "check_keys( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 252, "end_line": 256, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_overwrite_obj_int", "long_name": "check_overwrite_obj_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "level" ], "start_line": 197, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_overwrite_double_int", "long_name": "check_overwrite_double_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 188, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_obj_int", "long_name": "check_new_obj_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 30, "parameters": [ "self", "level" ], "start_line": 179, "end_line": 183, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 45, "parameters": [ "self", "level" ], "start_line": 57, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "level" ], "start_line": 102, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_char_fail", "long_name": "DOESNT_WORK_check_char_fail( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 104, "end_line": 110, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_empty", "long_name": "check_empty( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 34, "parameters": [ "self", "level" ], "start_line": 18, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_overwrite_int_int", "long_name": "check_overwrite_int_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 185, "end_line": 187, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_new_int_int", "long_name": "check_new_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 166, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_complex_int", "long_name": "check_overwrite_complex_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 194, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_items", "long_name": "check_items( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 243, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 36, "parameters": [ "self", "level" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_new_std_string_int", "long_name": "check_new_std_string_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 173, "end_line": 175, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_obj_int", "long_name": "check_overwrite_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 196, "end_line": 200, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 83, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_char_fail", "long_name": "DOESNT_WORK_check_char_fail( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 2, "token_count": 21, "parameters": [ "self", "level" ], "start_line": 105, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_new_double_int", "long_name": "check_new_double_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 170, "end_line": 172, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 74, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_new_obj_int", "long_name": "check_new_obj_int( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 178, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "DOESNT_WORK_check_obj_fail", "long_name": "DOESNT_WORK_check_obj_fail( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 124, "end_line": 134, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_dict.py", "nloc": 9, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 56, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 84, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 66, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_values", "long_name": "check_values( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 247, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_dict.py", "nloc": 12, "complexity": 2, "token_count": 96, "parameters": [ "level" ], "start_line": 264, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_dict.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 101, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_overwrite_std_string_int", "long_name": "check_overwrite_std_string_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 191, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 11, "complexity": 1, "token_count": 47, "parameters": [ "self", "level" ], "start_line": 30, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_new_complex_int", "long_name": "check_new_complex_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 176, "end_line": 178, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_overwrite_complex_int", "long_name": "check_overwrite_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 48, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 36, "parameters": [ "self", "level" ], "start_line": 41, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 8, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 49, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_items", "long_name": "check_items( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 242, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_new_int_int", "long_name": "check_new_int_int( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self", "level" ], "start_line": 167, "end_line": 169, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_update", "long_name": "check_update( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 46, "parameters": [ "self", "level" ], "start_line": 258, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_values", "long_name": "check_values( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 248, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_overwrite_int_int", "long_name": "check_overwrite_int_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 184, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_clear", "long_name": "check_clear( self )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 237, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_update", "long_name": "check_update( self )", "filename": "test_scxx_dict.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 257, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_complex_int", "long_name": "check_new_complex_int( self )", "filename": "test_scxx_dict.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 175, "end_line": 177, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_clear", "long_name": "check_clear( self , level = 5 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 238, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_dict.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 278, "end_line": 282, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 227, "complexity": 39, "token_count": 1479, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import inline_tools", "", " def check_empty(self,level=5):", " def check_obj(self,level=5):", " def check_int(self,level=5):", " def check_double(self,level=5):", " def check_complex(self,level=5):", " def check_string(self,level=5):", " def check_std_string(self,level=5):", " def check_string_fail(self,level=5):", " def check_char(self,level=5):", " def DOESNT_WORK_check_char_fail(self,level=5):", " def check_string(self,level=5):", " def check_obj(self,level=5):", " def DOESNT_WORK_check_obj_fail(self,level=5):", " def check_new_int_int(self,level=5):", " def check_new_double_int(self,level=5):", " def check_new_std_string_int(self,level=5):", " def check_new_complex_int(self,level=5):", " def check_new_obj_int(self,level=5):", " def check_overwrite_int_int(self,level=5):", " def check_overwrite_double_int(self,level=5):", " def check_overwrite_std_string_int(self,level=5):", " def check_overwrite_complex_int(self,level=5):", " def check_overwrite_obj_int(self,level=5):", " def check_int(self,level=5):", " def check_double(self,level=5):", " def check_std_string(self,level=5):", " def check_complex(self,level=5):", " def check_obj(self,level=5):", " def check_clear(self,level=5):", " def check_items(self,level=5):", " def check_values(self,level=5):", " def check_keys(self,level=5):", " def check_update(self,level=5):", " ScipyTest('weave.scxx').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "add_grandparent_to_path(__name__)", "import inline_tools", " def check_empty(self):", " def check_obj(self):", " def check_int(self):", " def check_double(self):", " def check_complex(self):", " def check_string(self):", " def check_std_string(self):", " def check_string_fail(self):", " def check_char(self):", " def DOESNT_WORK_check_char_fail(self):", " def check_string(self):", " def check_obj(self):", " def DOESNT_WORK_check_obj_fail(self):", " def check_new_int_int(self):", " def check_new_double_int(self):", " def check_new_std_string_int(self):", " def check_new_complex_int(self):", " def check_new_obj_int(self):", " def check_overwrite_int_int(self):", " def check_overwrite_double_int(self):", " def check_overwrite_std_string_int(self):", " def check_overwrite_complex_int(self):", " def check_overwrite_obj_int(self):", " def check_int(self):", " def check_double(self):", " def check_std_string(self):", " def check_complex(self):", " def check_obj(self):", " def check_clear(self):", " def check_items(self):", " def check_values(self):", " def check_keys(self):", " def check_update(self):", "", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " suites.append( makeSuite(test_dict_construct,'check_'))", " suites.append( makeSuite(test_dict_has_key,'check_'))", " suites.append( makeSuite(test_dict_get_item_op,'check_'))", " suites.append( makeSuite(test_dict_set_operator,'check_'))", " suites.append( makeSuite(test_dict_del,'check_'))", " suites.append( makeSuite(test_dict_others,'check_'))", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbose=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbose)", " runner.run(all_tests)", " return runner", " test()" ] } }, { "old_path": "weave/tests/test_scxx_object.py", "new_path": "weave/tests/test_scxx_object.py", "filename": "test_scxx_object.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,10 +3,10 @@\n import unittest\n import time\n import os,sys\n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n \n-add_grandparent_to_path(__name__)\n-import inline_tools\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import inline_tools\n restore_path()\n \n class test_object_construct(unittest.TestCase):\n@@ -14,7 +14,7 @@ class test_object_construct(unittest.TestCase):\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n- def check_int(self):\n+ def check_int(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n@@ -23,7 +23,7 @@ def check_int(self):\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n- def check_float(self):\n+ def check_float(self,level=5):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n@@ -31,7 +31,7 @@ def check_float(self):\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n- def check_double(self):\n+ def check_double(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n@@ -39,7 +39,7 @@ def check_double(self):\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n- def check_complex(self):\n+ def check_complex(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n@@ -48,7 +48,7 @@ def check_complex(self):\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n- def check_string(self):\n+ def check_string(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n@@ -57,7 +57,7 @@ def check_string(self):\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \n- def check_std_string(self):\n+ def check_std_string(self,level=5):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n@@ -71,14 +71,14 @@ class test_object_print(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check the object print protocol. \n #------------------------------------------------------------------------\n- def check_stdout(self):\n+ def check_stdout(self,level=5):\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(stdout);\n \"\"\"\n res = inline_tools.inline(code)\n # visual check on this one.\n- def check_stringio(self):\n+ def check_stringio(self,level=5):\n import cStringIO\n file_imposter = cStringIO.StringIO()\n code = \"\"\"\n@@ -89,7 +89,7 @@ def check_stringio(self):\n print file_imposter.getvalue()\n assert file_imposter.getvalue() == \"'how now brown cow'\"\n \n- def check_failure(self):\n+ def check_failure(self,level=5):\n code = \"\"\"\n FILE* file = 0;\n py::object val = \"how now brown cow\";\n@@ -103,32 +103,32 @@ def check_failure(self):\n \n \n class test_object_cast(unittest.TestCase):\n- def check_int_cast(self):\n+ def check_int_cast(self,level=5):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n- def check_double_cast(self):\n+ def check_double_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n- def check_float_cast(self):\n+ def check_float_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n- def check_complex_cast(self):\n+ def check_complex_cast(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n- def check_string_cast(self):\n+ def check_string_cast(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n@@ -149,7 +149,7 @@ def __str__(self):\n return \"b\"\n \n class test_object_hasattr(unittest.TestCase):\n- def check_string(self):\n+ def check_string(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n@@ -157,7 +157,7 @@ def check_string(self):\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n- def check_std_string(self):\n+ def check_std_string(self,level=5):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n@@ -166,7 +166,7 @@ def check_std_string(self):\n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n- def check_string_fail(self):\n+ def check_string_fail(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n@@ -174,7 +174,7 @@ def check_string_fail(self):\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n- def check_inline(self):\n+ def check_inline(self,level=5):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n@@ -195,7 +195,7 @@ def check_inline(self):\n print 'before, after, after2:', before, after, after2\n pass \n \n- def check_func(self):\n+ def check_func(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n@@ -217,32 +217,32 @@ def generic_attr(self,code,args=['a']):\n after = sys.getrefcount(a.b)\n assert after == before\n \n- def check_char(self):\n+ def check_char(self,level=5):\n self.generic_attr('return_val = a.attr(\"b\");')\n \n- def check_char_fail(self):\n+ def check_char_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(\"c\");')\n except AttributeError:\n pass\n \n- def check_string(self):\n+ def check_string(self,level=5):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n \n- def check_string_fail(self):\n+ def check_string_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(std::string(\"c\"));')\n except AttributeError:\n pass \n \n- def check_obj(self):\n+ def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n \n- def check_obj_fail(self):\n+ def check_obj_fail(self,level=5):\n try:\n code = \"\"\"\n py::object name = \"c\";\n@@ -252,7 +252,7 @@ def check_obj_fail(self):\n except AttributeError:\n pass \n \n- def check_attr_call(self):\n+ def check_attr_call(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n@@ -277,27 +277,27 @@ def generic_new(self, code, desired):\n res = inline_tools.inline(code,args)\n assert a.b == desired\n \n- def check_existing_char(self):\n+ def check_existing_char(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")\n- def check_new_char(self):\n+ def check_new_char(self,level=5):\n self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")\n- def check_existing_string(self):\n+ def check_existing_string(self,level=5):\n self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n- def check_new_string(self):\n+ def check_new_string(self,level=5):\n self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n- def check_existing_object(self):\n+ def check_existing_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n- def check_new_object(self):\n+ def check_new_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_new(code,\"hello\")\n- def check_new_fail(self):\n+ def check_new_fail(self,level=5):\n try:\n code = \"\"\"\n py::object obj = 1;\n@@ -307,19 +307,19 @@ def check_new_fail(self):\n except:\n pass \n \n- def check_existing_int(self):\n+ def check_existing_int(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1);',1)\n- def check_existing_double(self):\n+ def check_existing_double(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1.0);',1.0)\n- def check_existing_complex(self):\n+ def check_existing_complex(self,level=5):\n code = \"\"\"\n std::complex obj = std::complex(1,1);\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,1+1j)\n- def check_existing_char1(self):\n+ def check_existing_char1(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\") \n- def check_existing_string1(self):\n+ def check_existing_string1(self,level=5):\n code = \"\"\"\n std::string obj = std::string(\"hello\");\n a.set_attr(\"b\",obj);\n@@ -334,15 +334,15 @@ def generic(self, code):\n res = inline_tools.inline(code,args)\n assert not hasattr(a,\"b\")\n \n- def check_char(self):\n+ def check_char(self,level=5):\n self.generic('a.del(\"b\");')\n- def check_string(self):\n+ def check_string(self,level=5):\n code = \"\"\"\n std::string name = std::string(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n- def check_object(self):\n+ def check_object(self,level=5):\n code = \"\"\"\n py::object name = py::object(\"b\");\n a.del(name);\n@@ -350,11 +350,11 @@ def check_object(self):\n self.generic(code)\n \n class test_object_cmp(unittest.TestCase):\n- def check_equal(self):\n+ def check_equal(self,level=5):\n a,b = 1,1\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n- def check_equal_objects(self):\n+ def check_equal_objects(self,level=5):\n class foo:\n def __init__(self,x):\n self.x = x\n@@ -363,47 +363,47 @@ def __cmp__(self,other):\n a,b = foo(1),foo(2)\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n- def check_lt(self):\n+ def check_lt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a < b);',['a','b'])\n assert res == (a < b)\n- def check_gt(self):\n+ def check_gt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a > b);',['a','b'])\n assert res == (a > b)\n- def check_gte(self):\n+ def check_gte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a >= b);',['a','b'])\n assert res == (a >= b)\n- def check_lte(self):\n+ def check_lte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a <= b);',['a','b'])\n assert res == (a <= b)\n- def check_not_equal(self):\n+ def check_not_equal(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a != b);',['a','b'])\n assert res == (a != b)\n- def check_int(self):\n+ def check_int(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1);',['a'])\n assert res == (a == 1)\n- def check_int2(self):\n+ def check_int2(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (1 == a);',['a'])\n assert res == (a == 1)\n- def check_unsigned_long(self):\n+ def check_unsigned_long(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])\n assert res == (a == 1)\n- def check_double(self):\n+ def check_double(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1.0);',['a'])\n assert res == (a == 1.0)\n- def check_char(self):\n+ def check_char(self,level=5):\n a = \"hello\"\n res = inline_tools.inline('return_val = (a == \"hello\");',['a'])\n assert res == (a == \"hello\")\n- def check_std_string(self):\n+ def check_std_string(self,level=5):\n a = \"hello\"\n code = \"\"\"\n std::string hello = std::string(\"hello\");\n@@ -413,7 +413,7 @@ def check_std_string(self):\n assert res == (a == \"hello\")\n \n class test_object_repr(unittest.TestCase):\n- def check_repr(self):\n+ def check_repr(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n@@ -429,7 +429,7 @@ def __repr__(self):\n assert res == \"repr return\"\n \n class test_object_str(unittest.TestCase):\n- def check_str(self):\n+ def check_str(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n@@ -447,7 +447,7 @@ def __repr__(self):\n \n class test_object_unicode(unittest.TestCase):\n # This ain't going to win awards for test of the year...\n- def check_unicode(self):\n+ def check_unicode(self,level=5):\n class foo:\n def __repr__(self):\n return \"repr return\"\n@@ -463,14 +463,14 @@ def __str__(self):\n assert res == \"unicode\"\n \n class test_object_is_callable(unittest.TestCase):\n- def check_true(self):\n+ def check_true(self,level=5):\n class foo:\n def __call__(self):\n return 0\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert res\n- def check_false(self):\n+ def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n@@ -478,13 +478,13 @@ class foo:\n assert not res\n \n class test_object_call(unittest.TestCase):\n- def check_noargs(self):\n+ def check_noargs(self,level=5):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n- def check_args(self):\n+ def check_args(self,level=5):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n@@ -496,7 +496,7 @@ def foo(val1,val2):\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n- def check_args_kw(self):\n+ def check_args_kw(self,level=5):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n@@ -510,7 +510,7 @@ def foo(val1,val2,val3=1):\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n- def check_noargs_with_args(self):\n+ def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n def foo():\n@@ -534,7 +534,7 @@ def foo():\n assert second == third\n \n class test_object_mcall(unittest.TestCase):\n- def check_noargs(self):\n+ def check_noargs(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n@@ -544,7 +544,7 @@ def check_noargs(self):\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n- def check_args(self):\n+ def check_args(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n@@ -555,7 +555,7 @@ def check_args(self):\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n- def check_args_kw(self):\n+ def check_args_kw(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n@@ -568,7 +568,7 @@ def check_args_kw(self):\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n- def check_std_noargs(self):\n+ def check_std_noargs(self,level=5):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n@@ -579,7 +579,7 @@ def check_std_noargs(self):\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n- def check_std_args(self):\n+ def check_std_args(self,level=5):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n@@ -591,7 +591,7 @@ def check_std_args(self):\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n- def check_std_args_kw(self):\n+ def check_std_args_kw(self,level=5):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n@@ -605,7 +605,7 @@ def check_std_args_kw(self):\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n- def check_noargs_with_args(self):\n+ def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n@@ -628,7 +628,7 @@ def check_noargs_with_args(self):\n assert second == third\n \n class test_object_hash(unittest.TestCase):\n- def check_hash(self):\n+ def check_hash(self,level=5):\n class foo:\n def __hash__(self):\n return 123\n@@ -638,31 +638,31 @@ def __hash__(self):\n assert res == 123\n \n class test_object_is_true(unittest.TestCase):\n- def check_true(self):\n+ def check_true(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 1\n- def check_false(self):\n+ def check_false(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 0\n \n class test_object_is_true(unittest.TestCase):\n- def check_false(self):\n+ def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 0\n- def check_true(self):\n+ def check_true(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 1 \n \n class test_object_type(unittest.TestCase):\n- def check_type(self):\n+ def check_type(self,level=5):\n class foo:\n pass\n a= foo() \n@@ -670,21 +670,21 @@ class foo:\n assert res == type(a)\n \n class test_object_size(unittest.TestCase):\n- def check_size(self):\n+ def check_size(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.size();',['a'])\n assert res == len(a)\n- def check_len(self):\n+ def check_len(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.len();',['a'])\n assert res == len(a)\n- def check_length(self):\n+ def check_length(self,level=5):\n class foo:\n def __len__(self):\n return 10\n@@ -694,34 +694,34 @@ def __len__(self):\n \n from UserList import UserList\n class test_object_set_item_op_index(unittest.TestCase):\n- def check_list_refcount(self):\n+ def check_list_refcount(self,level=5):\n a = UserList([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n before1 = sys.getrefcount(a)\n after1 = sys.getrefcount(a)\n assert after1 == before1\n- def check_set_int(self):\n+ def check_set_int(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n- def check_set_double(self):\n+ def check_set_double(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0 \n- def check_set_char(self):\n+ def check_set_char(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n- def check_set_string(self):\n+ def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n- def check_set_string(self):\n+ def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::complex(1,1);',['a'])\n assert sys.getrefcount(a[1]) == 2 \n@@ -729,7 +729,7 @@ def check_set_string(self):\n \n from UserDict import UserDict\n class test_object_set_item_op_key(unittest.TestCase):\n- def check_key_refcount(self):\n+ def check_key_refcount(self,level=5):\n a = UserDict()\n code = \"\"\"\n py::object one = 1;\n@@ -760,7 +760,7 @@ def check_key_refcount(self):\n assert key[0] + 1 == key[1] and key[1] == key[2]\n assert val[0] + 1 == val[1] and val[1] == val[2]\n \n- def check_set_double_exists(self):\n+ def check_set_double_exists(self,level=5):\n a = UserDict() \n key = 10.0 \n a[key] = 100.0\n@@ -773,27 +773,27 @@ def check_set_double_exists(self):\n assert sys.getrefcount(key) == 5\n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n- def check_set_double_new(self):\n+ def check_set_double_new(self,level=5):\n a = UserDict() \n key = 1.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n assert sys.getrefcount(key) == 4 # should be 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n- def check_set_complex(self):\n+ def check_set_complex(self,level=5):\n a = UserDict()\n key = 1+1j \n inline_tools.inline(\"a[key] = 1234;\",['a','key'])\n assert sys.getrefcount(key) == 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 1234\n- def check_set_char(self):\n+ def check_set_char(self,level=5):\n a = UserDict() \n inline_tools.inline('a[\"hello\"] = 123.0;',['a'])\n assert sys.getrefcount(a[\"hello\"]) == 2 \n assert a[\"hello\"] == 123.0\n \n- def check_set_class(self):\n+ def check_set_class(self,level=5):\n a = UserDict() \n class foo:\n def __init__(self,val):\n@@ -811,46 +811,12 @@ def __hash__(self):\n assert sys.getrefcount(key) == 4 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 'bubba'\n- def check_set_from_member(self):\n+ def check_set_from_member(self,level=5):\n a = UserDict() \n a['first'] = 1\n a['second'] = 2\n inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])\n assert a['first'] == a['second']\n \n-def test_suite(level=1):\n- from unittest import makeSuite\n- suites = [] \n- if level >= 5:\n- suites.append( makeSuite(test_object_construct,'check_'))\n- suites.append( makeSuite(test_object_print,'check_'))\n- suites.append( makeSuite(test_object_cast,'check_'))\n- suites.append( makeSuite(test_object_hasattr,'check_')) \n- suites.append( makeSuite(test_object_attr,'check_'))\n- suites.append( makeSuite(test_object_set_attr,'check_'))\n- suites.append( makeSuite(test_object_del,'check_'))\n- suites.append( makeSuite(test_object_cmp,'check_'))\n- suites.append( makeSuite(test_object_repr,'check_'))\n- suites.append( makeSuite(test_object_str,'check_'))\n- suites.append( makeSuite(test_object_unicode,'check_'))\n- suites.append( makeSuite(test_object_is_callable,'check_')) \n- suites.append( makeSuite(test_object_call,'check_'))\n- suites.append( makeSuite(test_object_mcall,'check_'))\n- suites.append( makeSuite(test_object_hash,'check_'))\n- suites.append( makeSuite(test_object_is_true,'check_'))\n- suites.append( makeSuite(test_object_type,'check_'))\n- suites.append( makeSuite(test_object_size,'check_'))\n- suites.append( makeSuite(test_object_set_item_op_index,'check_'))\n- suites.append( makeSuite(test_object_set_item_op_key,'check_'))\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10,verbose=2):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner(verbosity=verbose)\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.scxx').run()\n", "added_lines": 96, "deleted_lines": 130, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\nclass test_object_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_int(self,level=5):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n def check_float(self,level=5):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_double(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_complex(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n def check_string(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n\n def check_std_string(self,level=5):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \nclass test_object_print(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check the object print protocol. \n #------------------------------------------------------------------------\n def check_stdout(self,level=5):\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(stdout);\n \"\"\"\n res = inline_tools.inline(code)\n # visual check on this one.\n def check_stringio(self,level=5):\n import cStringIO\n file_imposter = cStringIO.StringIO()\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(file_imposter);\n \"\"\"\n res = inline_tools.inline(code,['file_imposter'])\n print file_imposter.getvalue()\n assert file_imposter.getvalue() == \"'how now brown cow'\"\n\n def check_failure(self,level=5):\n code = \"\"\"\n FILE* file = 0;\n py::object val = \"how now brown cow\";\n val.print(file);\n \"\"\"\n try: \n res = inline_tools.inline(code)\n except:\n # error was supposed to occur.\n pass \n\n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self,level=5):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self,level=5):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_complex_cast(self,level=5):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self,level=5):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n def bar2(self,val1,val2):\n return val1, val2\n def bar3(self,val1,val2,val3=1):\n return val1, val2, val3\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_hasattr(unittest.TestCase):\n def check_string(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self,level=5):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n code = \"\"\"\n return_val = a.hasattr(attr_name); \n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n def check_string_fail(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n def check_inline(self,level=5):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n a.b = 12345\n code = \"\"\"\n throw_error(PyExc_AttributeError,\"bummer\"); \n \"\"\"\n try:\n before = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except AttributeError:\n after = sys.getrefcount(a)\n try: \n res = inline_tools.inline(code,['a'])\n except:\n after2 = sys.getrefcount(a)\n print \"after and after2 should be equal in the following\" \n print 'before, after, after2:', before, after, after2\n pass \n\n def check_func(self,level=5):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"bar\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self,level=5):\n self.generic_attr('return_val = a.attr(\"b\");')\n\n def check_char_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(\"c\");')\n except AttributeError:\n pass\n \n def check_string(self,level=5):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n\n def check_string_fail(self,level=5):\n try:\n self.generic_attr('return_val = a.attr(std::string(\"c\"));')\n except AttributeError:\n pass \n\n def check_obj(self,level=5):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n\n def check_obj_fail(self,level=5):\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n except AttributeError:\n pass \n \n def check_attr_call(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n second = sys.getrefcount(res)\n assert res == \"bar results\"\n assert first == second\n\nclass test_object_set_attr(unittest.TestCase):\n\n def generic_existing(self, code, desired):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def generic_new(self, code, desired):\n args = ['a']\n a = foo()\n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def check_existing_char(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_new_char(self,level=5):\n self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_existing_string(self,level=5):\n self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_new_string(self,level=5):\n self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_existing_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n def check_new_object(self,level=5):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_new(code,\"hello\")\n def check_new_fail(self,level=5):\n try:\n code = \"\"\"\n py::object obj = 1;\n a.set_attr(obj,\"hello\");\n \"\"\"\n self.generic_new(code,\"hello\")\n except:\n pass \n\n def check_existing_int(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1);',1)\n def check_existing_double(self,level=5):\n self.generic_existing('a.set_attr(\"b\",1.0);',1.0)\n def check_existing_complex(self,level=5):\n code = \"\"\"\n std::complex obj = std::complex(1,1);\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,1+1j)\n def check_existing_char1(self,level=5):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\") \n def check_existing_string1(self,level=5):\n code = \"\"\"\n std::string obj = std::string(\"hello\");\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n\nclass test_object_del(unittest.TestCase):\n def generic(self, code):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert not hasattr(a,\"b\")\n\n def check_char(self,level=5):\n self.generic('a.del(\"b\");')\n def check_string(self,level=5):\n code = \"\"\"\n std::string name = std::string(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n def check_object(self,level=5):\n code = \"\"\"\n py::object name = py::object(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n\nclass test_object_cmp(unittest.TestCase):\n def check_equal(self,level=5):\n a,b = 1,1\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_equal_objects(self,level=5):\n class foo:\n def __init__(self,x):\n self.x = x\n def __cmp__(self,other):\n return cmp(self.x,other.x)\n a,b = foo(1),foo(2)\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_lt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a < b);',['a','b'])\n assert res == (a < b)\n def check_gt(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a > b);',['a','b'])\n assert res == (a > b)\n def check_gte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a >= b);',['a','b'])\n assert res == (a >= b)\n def check_lte(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a <= b);',['a','b'])\n assert res == (a <= b)\n def check_not_equal(self,level=5):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a != b);',['a','b'])\n assert res == (a != b)\n def check_int(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1);',['a'])\n assert res == (a == 1)\n def check_int2(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (1 == a);',['a'])\n assert res == (a == 1)\n def check_unsigned_long(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])\n assert res == (a == 1)\n def check_double(self,level=5):\n a = 1\n res = inline_tools.inline('return_val = (a == 1.0);',['a'])\n assert res == (a == 1.0)\n def check_char(self,level=5):\n a = \"hello\"\n res = inline_tools.inline('return_val = (a == \"hello\");',['a'])\n assert res == (a == \"hello\")\n def check_std_string(self,level=5):\n a = \"hello\"\n code = \"\"\"\n std::string hello = std::string(\"hello\");\n return_val = (a == hello);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (a == \"hello\")\n\nclass test_object_repr(unittest.TestCase):\n def check_repr(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.repr();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.repr();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"repr return\"\n\nclass test_object_str(unittest.TestCase):\n def check_str(self,level=5):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.str();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.str();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n print res\n assert res == \"str return\"\n\nclass test_object_unicode(unittest.TestCase):\n # This ain't going to win awards for test of the year...\n def check_unicode(self,level=5):\n class foo:\n def __repr__(self):\n return \"repr return\"\n def __str__(self):\n return \"unicode\"\n a= foo() \n res = inline_tools.inline('return_val = a.unicode();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.unicode();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"unicode\"\n\nclass test_object_is_callable(unittest.TestCase):\n def check_true(self,level=5):\n class foo:\n def __call__(self):\n return 0\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert res\n def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert not res\n\nclass test_object_call(unittest.TestCase):\n def check_noargs(self,level=5):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n def check_args(self,level=5):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self,level=5):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3; \n return_val = foo.call(args,kw);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n def foo():\n return \"blah\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n try:\n first = sys.getrefcount(foo)\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n second = sys.getrefcount(foo) \n try:\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n third = sys.getrefcount(foo) \n # first should == second, but the weird refcount error \n assert second == third\n \nclass test_object_mcall(unittest.TestCase):\n def check_noargs(self,level=5):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_args(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar2\",args);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self,level=5):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(\"bar3\",args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_std_noargs(self,level=5):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_std_args(self,level=5):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(method,args);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_std_args_kw(self,level=5):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(method,args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self,level=5):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar\",args);\n \"\"\"\n try:\n first = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except TypeError:\n second = sys.getrefcount(a) \n try:\n res = inline_tools.inline(code,['a'])\n except TypeError:\n third = sys.getrefcount(a) \n # first should == second, but the weird refcount error \n assert second == third\n\nclass test_object_hash(unittest.TestCase):\n def check_hash(self,level=5):\n class foo:\n def __hash__(self):\n return 123\n a= foo() \n res = inline_tools.inline('return_val = a.hash(); ',['a'])\n print 'hash:', res\n assert res == 123\n\nclass test_object_is_true(unittest.TestCase):\n def check_true(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 1\n def check_false(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 0\n\nclass test_object_is_true(unittest.TestCase):\n def check_false(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 0\n def check_true(self,level=5):\n a= None \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 1 \n\nclass test_object_type(unittest.TestCase):\n def check_type(self,level=5):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.type();',['a'])\n assert res == type(a)\n\nclass test_object_size(unittest.TestCase):\n def check_size(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.size();',['a'])\n assert res == len(a)\n def check_len(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.len();',['a'])\n assert res == len(a)\n def check_length(self,level=5):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.length();',['a'])\n assert res == len(a) \n\nfrom UserList import UserList\nclass test_object_set_item_op_index(unittest.TestCase):\n def check_list_refcount(self,level=5):\n a = UserList([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n before1 = sys.getrefcount(a)\n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_int(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n def check_set_double(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0 \n def check_set_char(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n def check_set_string(self,level=5):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::complex(1,1);',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1+1j\n\nfrom UserDict import UserDict\nclass test_object_set_item_op_key(unittest.TestCase):\n def check_key_refcount(self,level=5):\n a = UserDict()\n code = \"\"\"\n py::object one = 1;\n py::object two = 2;\n py::tuple ref_counts(3);\n py::tuple obj_counts(3);\n py::tuple val_counts(3);\n py::tuple key_counts(3);\n obj_counts[0] = a.refcount();\n key_counts[0] = one.refcount();\n val_counts[0] = two.refcount();\n a[1] = 2;\n obj_counts[1] = a.refcount();\n key_counts[1] = one.refcount();\n val_counts[1] = two.refcount();\n a[1] = 2;\n obj_counts[2] = a.refcount();\n key_counts[2] = one.refcount();\n val_counts[2] = two.refcount();\n \n ref_counts[0] = obj_counts;\n ref_counts[1] = key_counts;\n ref_counts[2] = val_counts;\n return_val = ref_counts;\n \"\"\"\n obj,key,val = inline_tools.inline(code,['a'])\n assert obj[0] == obj[1] and obj[1] == obj[2]\n assert key[0] + 1 == key[1] and key[1] == key[2]\n assert val[0] + 1 == val[1] and val[1] == val[2]\n \n def check_set_double_exists(self,level=5):\n a = UserDict() \n key = 10.0 \n a[key] = 100.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n first = sys.getrefcount(key)\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n second = sys.getrefcount(key)\n assert first == second\n # !! I think the following should be 3\n assert sys.getrefcount(key) == 5\n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_double_new(self,level=5):\n a = UserDict() \n key = 1.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n assert sys.getrefcount(key) == 4 # should be 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_complex(self,level=5):\n a = UserDict()\n key = 1+1j \n inline_tools.inline(\"a[key] = 1234;\",['a','key'])\n assert sys.getrefcount(key) == 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 1234\n def check_set_char(self,level=5):\n a = UserDict() \n inline_tools.inline('a[\"hello\"] = 123.0;',['a'])\n assert sys.getrefcount(a[\"hello\"]) == 2 \n assert a[\"hello\"] == 123.0\n \n def check_set_class(self,level=5):\n a = UserDict() \n class foo:\n def __init__(self,val):\n self.val = val\n def __hash__(self):\n return self.val\n key = foo(4)\n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n first = sys.getrefcount(key) \n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n second = sys.getrefcount(key) \n # I don't think we're leaking if this is true\n assert first == second \n # !! BUT -- I think this should be 3\n assert sys.getrefcount(key) == 4 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 'bubba'\n def check_set_from_member(self,level=5):\n a = UserDict() \n a['first'] = 1\n a['second'] = 2\n inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])\n assert a['first'] == a['second']\n\nif __name__ == \"__main__\":\n ScipyTest('weave.scxx').run()\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\nclass test_object_construct(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check that construction from basic types is allowed and have correct\n # reference counts\n #------------------------------------------------------------------------\n def check_int(self):\n # strange int value used to try and make sure refcount is 2.\n code = \"\"\"\n py::object val = 1001;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1001\n def check_float(self):\n code = \"\"\"\n py::object val = (float)1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_double(self):\n code = \"\"\"\n py::object val = 1.0;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0\n def check_complex(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == 1.0+1.0j\n def check_string(self):\n code = \"\"\"\n py::object val = \"hello\";\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n\n def check_std_string(self):\n code = \"\"\"\n std::string s = std::string(\"hello\");\n py::object val = s;\n return_val = val;\n \"\"\"\n res = inline_tools.inline(code)\n assert sys.getrefcount(res) == 2\n assert res == \"hello\"\n \nclass test_object_print(unittest.TestCase):\n #------------------------------------------------------------------------\n # Check the object print protocol. \n #------------------------------------------------------------------------\n def check_stdout(self):\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(stdout);\n \"\"\"\n res = inline_tools.inline(code)\n # visual check on this one.\n def check_stringio(self):\n import cStringIO\n file_imposter = cStringIO.StringIO()\n code = \"\"\"\n py::object val = \"how now brown cow\";\n val.print(file_imposter);\n \"\"\"\n res = inline_tools.inline(code,['file_imposter'])\n print file_imposter.getvalue()\n assert file_imposter.getvalue() == \"'how now brown cow'\"\n\n def check_failure(self):\n code = \"\"\"\n FILE* file = 0;\n py::object val = \"how now brown cow\";\n val.print(file);\n \"\"\"\n try: \n res = inline_tools.inline(code)\n except:\n # error was supposed to occur.\n pass \n\n \nclass test_object_cast(unittest.TestCase):\n def check_int_cast(self):\n code = \"\"\"\n py::object val = 1;\n int raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_double_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n double raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_float_cast(self):\n code = \"\"\"\n py::object val = 1.0;\n float raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_complex_cast(self):\n code = \"\"\"\n std::complex num = std::complex(1.0,1.0);\n py::object val = num;\n std::complex raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n def check_string_cast(self):\n code = \"\"\"\n py::object val = \"hello\";\n std::string raw_val = val;\n \"\"\"\n inline_tools.inline(code)\n \n# test class used for testing python class access from C++.\nclass foo:\n def bar(self):\n return \"bar results\"\n def bar2(self,val1,val2):\n return val1, val2\n def bar3(self,val1,val2,val3=1):\n return val1, val2, val3\n\nclass str_obj:\n def __str__(self):\n return \"b\"\n\nclass test_object_hasattr(unittest.TestCase):\n def check_string(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"b\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n def check_std_string(self):\n a = foo()\n a.b = 12345\n attr_name = \"b\"\n code = \"\"\"\n return_val = a.hasattr(attr_name); \n \"\"\"\n res = inline_tools.inline(code,['a','attr_name'])\n assert res \n def check_string_fail(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"c\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert not res\n def check_inline(self):\n \"\"\" THIS NEEDS TO MOVE TO THE INLINE TEST SUITE\n \"\"\"\n a = foo()\n a.b = 12345\n code = \"\"\"\n throw_error(PyExc_AttributeError,\"bummer\"); \n \"\"\"\n try:\n before = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except AttributeError:\n after = sys.getrefcount(a)\n try: \n res = inline_tools.inline(code,['a'])\n except:\n after2 = sys.getrefcount(a)\n print \"after and after2 should be equal in the following\" \n print 'before, after, after2:', before, after, after2\n pass \n\n def check_func(self):\n a = foo()\n a.b = 12345\n code = \"\"\"\n return_val = a.hasattr(\"bar\"); \n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res\n\nclass test_object_attr(unittest.TestCase):\n\n def generic_attr(self,code,args=['a']):\n a = foo()\n a.b = 12345\n \n before = sys.getrefcount(a.b)\n res = inline_tools.inline(code,args)\n assert res == a.b\n del res\n after = sys.getrefcount(a.b)\n assert after == before\n\n def check_char(self):\n self.generic_attr('return_val = a.attr(\"b\");')\n\n def check_char_fail(self):\n try:\n self.generic_attr('return_val = a.attr(\"c\");')\n except AttributeError:\n pass\n \n def check_string(self):\n self.generic_attr('return_val = a.attr(std::string(\"b\"));')\n\n def check_string_fail(self):\n try:\n self.generic_attr('return_val = a.attr(std::string(\"c\"));')\n except AttributeError:\n pass \n\n def check_obj(self):\n code = \"\"\"\n py::object name = \"b\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n\n def check_obj_fail(self):\n try:\n code = \"\"\"\n py::object name = \"c\";\n return_val = a.attr(name);\n \"\"\" \n self.generic_attr(code,['a'])\n except AttributeError:\n pass \n \n def check_attr_call(self):\n a = foo()\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.attr(\"bar\").call();',['a'])\n second = sys.getrefcount(res)\n assert res == \"bar results\"\n assert first == second\n\nclass test_object_set_attr(unittest.TestCase):\n\n def generic_existing(self, code, desired):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def generic_new(self, code, desired):\n args = ['a']\n a = foo()\n res = inline_tools.inline(code,args)\n assert a.b == desired\n\n def check_existing_char(self):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_new_char(self):\n self.generic_new('a.set_attr(\"b\",\"hello\");',\"hello\")\n def check_existing_string(self):\n self.generic_existing('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_new_string(self):\n self.generic_new('a.set_attr(\"b\",std::string(\"hello\"));',\"hello\")\n def check_existing_object(self):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n def check_new_object(self):\n code = \"\"\"\n py::object obj = \"hello\";\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_new(code,\"hello\")\n def check_new_fail(self):\n try:\n code = \"\"\"\n py::object obj = 1;\n a.set_attr(obj,\"hello\");\n \"\"\"\n self.generic_new(code,\"hello\")\n except:\n pass \n\n def check_existing_int(self):\n self.generic_existing('a.set_attr(\"b\",1);',1)\n def check_existing_double(self):\n self.generic_existing('a.set_attr(\"b\",1.0);',1.0)\n def check_existing_complex(self):\n code = \"\"\"\n std::complex obj = std::complex(1,1);\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,1+1j)\n def check_existing_char1(self):\n self.generic_existing('a.set_attr(\"b\",\"hello\");',\"hello\") \n def check_existing_string1(self):\n code = \"\"\"\n std::string obj = std::string(\"hello\");\n a.set_attr(\"b\",obj);\n \"\"\"\n self.generic_existing(code,\"hello\")\n\nclass test_object_del(unittest.TestCase):\n def generic(self, code):\n args = ['a']\n a = foo()\n a.b = 12345 \n res = inline_tools.inline(code,args)\n assert not hasattr(a,\"b\")\n\n def check_char(self):\n self.generic('a.del(\"b\");')\n def check_string(self):\n code = \"\"\"\n std::string name = std::string(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n def check_object(self):\n code = \"\"\"\n py::object name = py::object(\"b\");\n a.del(name);\n \"\"\"\n self.generic(code)\n\nclass test_object_cmp(unittest.TestCase):\n def check_equal(self):\n a,b = 1,1\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_equal_objects(self):\n class foo:\n def __init__(self,x):\n self.x = x\n def __cmp__(self,other):\n return cmp(self.x,other.x)\n a,b = foo(1),foo(2)\n res = inline_tools.inline('return_val = (a == b);',['a','b'])\n assert res == (a == b)\n def check_lt(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a < b);',['a','b'])\n assert res == (a < b)\n def check_gt(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a > b);',['a','b'])\n assert res == (a > b)\n def check_gte(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a >= b);',['a','b'])\n assert res == (a >= b)\n def check_lte(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a <= b);',['a','b'])\n assert res == (a <= b)\n def check_not_equal(self):\n a,b = 1,2\n res = inline_tools.inline('return_val = (a != b);',['a','b'])\n assert res == (a != b)\n def check_int(self):\n a = 1\n res = inline_tools.inline('return_val = (a == 1);',['a'])\n assert res == (a == 1)\n def check_int2(self):\n a = 1\n res = inline_tools.inline('return_val = (1 == a);',['a'])\n assert res == (a == 1)\n def check_unsigned_long(self):\n a = 1\n res = inline_tools.inline('return_val = (a == (unsigned long)1);',['a'])\n assert res == (a == 1)\n def check_double(self):\n a = 1\n res = inline_tools.inline('return_val = (a == 1.0);',['a'])\n assert res == (a == 1.0)\n def check_char(self):\n a = \"hello\"\n res = inline_tools.inline('return_val = (a == \"hello\");',['a'])\n assert res == (a == \"hello\")\n def check_std_string(self):\n a = \"hello\"\n code = \"\"\"\n std::string hello = std::string(\"hello\");\n return_val = (a == hello);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (a == \"hello\")\n\nclass test_object_repr(unittest.TestCase):\n def check_repr(self):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.repr();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.repr();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"repr return\"\n\nclass test_object_str(unittest.TestCase):\n def check_str(self):\n class foo:\n def __str__(self):\n return \"str return\"\n def __repr__(self):\n return \"repr return\"\n a = foo() \n res = inline_tools.inline('return_val = a.str();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.str();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n print res\n assert res == \"str return\"\n\nclass test_object_unicode(unittest.TestCase):\n # This ain't going to win awards for test of the year...\n def check_unicode(self):\n class foo:\n def __repr__(self):\n return \"repr return\"\n def __str__(self):\n return \"unicode\"\n a= foo() \n res = inline_tools.inline('return_val = a.unicode();',['a'])\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.unicode();',['a'])\n second = sys.getrefcount(res)\n assert first == second\n assert res == \"unicode\"\n\nclass test_object_is_callable(unittest.TestCase):\n def check_true(self):\n class foo:\n def __call__(self):\n return 0\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert res\n def check_false(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_callable();',['a'])\n assert not res\n\nclass test_object_call(unittest.TestCase):\n def check_noargs(self):\n def foo():\n return (1,2,3)\n res = inline_tools.inline('return_val = foo.call();',['foo'])\n assert res == (1,2,3)\n assert sys.getrefcount(res) == 2\n def check_args(self):\n def foo(val1,val2):\n return (val1,val2)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n def foo(val1,val2,val3=1):\n return (val1,val2,val3)\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3; \n return_val = foo.call(args,kw);\n \"\"\"\n res = inline_tools.inline(code,['foo'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n def foo():\n return \"blah\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = foo.call(args);\n \"\"\"\n try:\n first = sys.getrefcount(foo)\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n second = sys.getrefcount(foo) \n try:\n res = inline_tools.inline(code,['foo'])\n except TypeError:\n third = sys.getrefcount(foo) \n # first should == second, but the weird refcount error \n assert second == third\n \nclass test_object_mcall(unittest.TestCase):\n def check_noargs(self):\n a = foo()\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(\"bar\");',['a'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_args(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar2\",args);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_args_kw(self):\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(\"bar3\",args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_std_noargs(self):\n a = foo()\n method = \"bar\"\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n first = sys.getrefcount(res)\n del res\n res = inline_tools.inline('return_val = a.mcall(method);',['a','method'])\n assert res == \"bar results\"\n second = sys.getrefcount(res)\n assert first == second\n def check_std_args(self):\n a = foo()\n method = \"bar2\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(method,args);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\")\n assert sys.getrefcount(res) == 2\n def check_std_args_kw(self):\n a = foo()\n method = \"bar3\"\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n py::dict kw;\n kw[\"val3\"] = 3;\n return_val = a.mcall(method,args,kw);\n \"\"\"\n res = inline_tools.inline(code,['a','method'])\n assert res == (1,\"hello\",3)\n assert sys.getrefcount(res) == 2\n def check_noargs_with_args(self):\n # calling a function that does take args with args \n # should fail.\n a = foo()\n code = \"\"\"\n py::tuple args(2);\n args[0] = 1;\n args[1] = \"hello\";\n return_val = a.mcall(\"bar\",args);\n \"\"\"\n try:\n first = sys.getrefcount(a)\n res = inline_tools.inline(code,['a'])\n except TypeError:\n second = sys.getrefcount(a) \n try:\n res = inline_tools.inline(code,['a'])\n except TypeError:\n third = sys.getrefcount(a) \n # first should == second, but the weird refcount error \n assert second == third\n\nclass test_object_hash(unittest.TestCase):\n def check_hash(self):\n class foo:\n def __hash__(self):\n return 123\n a= foo() \n res = inline_tools.inline('return_val = a.hash(); ',['a'])\n print 'hash:', res\n assert res == 123\n\nclass test_object_is_true(unittest.TestCase):\n def check_true(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 1\n def check_false(self):\n a= None \n res = inline_tools.inline('return_val = a.is_true();',['a'])\n assert res == 0\n\nclass test_object_is_true(unittest.TestCase):\n def check_false(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 0\n def check_true(self):\n a= None \n res = inline_tools.inline('return_val = a.not();',['a'])\n assert res == 1 \n\nclass test_object_type(unittest.TestCase):\n def check_type(self):\n class foo:\n pass\n a= foo() \n res = inline_tools.inline('return_val = a.type();',['a'])\n assert res == type(a)\n\nclass test_object_size(unittest.TestCase):\n def check_size(self):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.size();',['a'])\n assert res == len(a)\n def check_len(self):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.len();',['a'])\n assert res == len(a)\n def check_length(self):\n class foo:\n def __len__(self):\n return 10\n a= foo() \n res = inline_tools.inline('return_val = a.length();',['a'])\n assert res == len(a) \n\nfrom UserList import UserList\nclass test_object_set_item_op_index(unittest.TestCase):\n def check_list_refcount(self):\n a = UserList([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n before1 = sys.getrefcount(a)\n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_int(self):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n def check_set_double(self):\n a = UserList([1,2,3]) \n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0 \n def check_set_char(self):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n def check_set_string(self):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::string(\"sissy\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n def check_set_string(self):\n a = UserList([1,2,3]) \n inline_tools.inline('a[1] = std::complex(1,1);',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1+1j\n\nfrom UserDict import UserDict\nclass test_object_set_item_op_key(unittest.TestCase):\n def check_key_refcount(self):\n a = UserDict()\n code = \"\"\"\n py::object one = 1;\n py::object two = 2;\n py::tuple ref_counts(3);\n py::tuple obj_counts(3);\n py::tuple val_counts(3);\n py::tuple key_counts(3);\n obj_counts[0] = a.refcount();\n key_counts[0] = one.refcount();\n val_counts[0] = two.refcount();\n a[1] = 2;\n obj_counts[1] = a.refcount();\n key_counts[1] = one.refcount();\n val_counts[1] = two.refcount();\n a[1] = 2;\n obj_counts[2] = a.refcount();\n key_counts[2] = one.refcount();\n val_counts[2] = two.refcount();\n \n ref_counts[0] = obj_counts;\n ref_counts[1] = key_counts;\n ref_counts[2] = val_counts;\n return_val = ref_counts;\n \"\"\"\n obj,key,val = inline_tools.inline(code,['a'])\n assert obj[0] == obj[1] and obj[1] == obj[2]\n assert key[0] + 1 == key[1] and key[1] == key[2]\n assert val[0] + 1 == val[1] and val[1] == val[2]\n \n def check_set_double_exists(self):\n a = UserDict() \n key = 10.0 \n a[key] = 100.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n first = sys.getrefcount(key)\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n second = sys.getrefcount(key)\n assert first == second\n # !! I think the following should be 3\n assert sys.getrefcount(key) == 5\n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_double_new(self):\n a = UserDict() \n key = 1.0\n inline_tools.inline('a[key] = 123.0;',['a','key'])\n assert sys.getrefcount(key) == 4 # should be 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 123.0\n def check_set_complex(self):\n a = UserDict()\n key = 1+1j \n inline_tools.inline(\"a[key] = 1234;\",['a','key'])\n assert sys.getrefcount(key) == 3 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 1234\n def check_set_char(self):\n a = UserDict() \n inline_tools.inline('a[\"hello\"] = 123.0;',['a'])\n assert sys.getrefcount(a[\"hello\"]) == 2 \n assert a[\"hello\"] == 123.0\n \n def check_set_class(self):\n a = UserDict() \n class foo:\n def __init__(self,val):\n self.val = val\n def __hash__(self):\n return self.val\n key = foo(4)\n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n first = sys.getrefcount(key) \n inline_tools.inline('a[key] = \"bubba\";',['a','key'])\n second = sys.getrefcount(key) \n # I don't think we're leaking if this is true\n assert first == second \n # !! BUT -- I think this should be 3\n assert sys.getrefcount(key) == 4 \n assert sys.getrefcount(a[key]) == 2 \n assert a[key] == 'bubba'\n def check_set_from_member(self):\n a = UserDict() \n a['first'] = 1\n a['second'] = 2\n inline_tools.inline('a[\"first\"] = a[\"second\"];',['a'])\n assert a['first'] == a['second']\n\ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n suites.append( makeSuite(test_object_construct,'check_'))\n suites.append( makeSuite(test_object_print,'check_'))\n suites.append( makeSuite(test_object_cast,'check_'))\n suites.append( makeSuite(test_object_hasattr,'check_')) \n suites.append( makeSuite(test_object_attr,'check_'))\n suites.append( makeSuite(test_object_set_attr,'check_'))\n suites.append( makeSuite(test_object_del,'check_'))\n suites.append( makeSuite(test_object_cmp,'check_'))\n suites.append( makeSuite(test_object_repr,'check_'))\n suites.append( makeSuite(test_object_str,'check_'))\n suites.append( makeSuite(test_object_unicode,'check_'))\n suites.append( makeSuite(test_object_is_callable,'check_')) \n suites.append( makeSuite(test_object_call,'check_'))\n suites.append( makeSuite(test_object_mcall,'check_'))\n suites.append( makeSuite(test_object_hash,'check_'))\n suites.append( makeSuite(test_object_is_true,'check_'))\n suites.append( makeSuite(test_object_type,'check_'))\n suites.append( makeSuite(test_object_size,'check_'))\n suites.append( makeSuite(test_object_set_item_op_index,'check_'))\n suites.append( makeSuite(test_object_set_item_op_key,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_int", "long_name": "check_int( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 35, "parameters": [ "self", "level" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 35, "parameters": [ "self", "level" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 42, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 51, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 60, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_stdout", "long_name": "check_stdout( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_stringio", "long_name": "check_stringio( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 47, "parameters": [ "self", "level" ], "start_line": 81, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_failure", "long_name": "check_failure( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 2, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 92, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 118, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 124, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 131, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 142, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 144, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 36, "parameters": [ "self", "level" ], "start_line": 152, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 41, "parameters": [ "self", "level" ], "start_line": 160, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 91, "parameters": [ "self", "level" ], "start_line": 177, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 36, "parameters": [ "self", "level" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 209, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "level" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_char_fail", "long_name": "check_char_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 21, "parameters": [ "self", "level" ], "start_line": 223, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "level" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 21, "parameters": [ "self", "level" ], "start_line": 232, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 22, "parameters": [ "self", "level" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_obj_fail", "long_name": "check_obj_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_attr_call", "long_name": "check_attr_call( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 64, "parameters": [ "self", "level" ], "start_line": 255, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generic_existing", "long_name": "generic_existing( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "desired" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self", "code", "desired" ], "start_line": 274, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_existing_char", "long_name": "check_existing_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_new_char", "long_name": "check_new_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_string", "long_name": "check_existing_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 284, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_new_string", "long_name": "check_new_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 286, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_object", "long_name": "check_existing_object( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 288, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_object", "long_name": "check_new_object( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_fail", "long_name": "check_new_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 300, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_existing_int", "long_name": "check_existing_int( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 310, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_double", "long_name": "check_existing_double( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "level" ], "start_line": 312, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_complex", "long_name": "check_existing_complex( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 22, "parameters": [ "self", "level" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_existing_char1", "long_name": "check_existing_char1( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 320, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_string1", "long_name": "check_existing_string1( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , code )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code" ], "start_line": 330, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "level" ], "start_line": 337, "end_line": 338, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 339, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_object", "long_name": "check_object( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_equal", "long_name": "check_equal( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 353, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_equal_objects.__init__", "long_name": "check_equal_objects.__init__( self , x )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "x" ], "start_line": 359, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_equal_objects.__cmp__", "long_name": "check_equal_objects.__cmp__( self , other )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "other" ], "start_line": 361, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_equal_objects", "long_name": "check_equal_objects( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_lt", "long_name": "check_lt( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 366, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_gt", "long_name": "check_gt( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 370, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_gte", "long_name": "check_gte( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 374, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_lte", "long_name": "check_lte( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 378, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_not_equal", "long_name": "check_not_equal( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 382, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 386, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_int2", "long_name": "check_int2( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 390, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_unsigned_long", "long_name": "check_unsigned_long( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 394, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self", "level" ], "start_line": 398, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 402, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 35, "parameters": [ "self", "level" ], "start_line": 406, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_repr.__str__", "long_name": "check_repr.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 418, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_repr.__repr__", "long_name": "check_repr.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 420, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_repr", "long_name": "check_repr( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 71, "parameters": [ "self", "level" ], "start_line": 416, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_str.__str__", "long_name": "check_str.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 434, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_str.__repr__", "long_name": "check_str.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_str", "long_name": "check_str( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 73, "parameters": [ "self", "level" ], "start_line": 432, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_unicode.__repr__", "long_name": "check_unicode.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_unicode.__str__", "long_name": "check_unicode.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_unicode", "long_name": "check_unicode( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 71, "parameters": [ "self", "level" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_true.__call__", "long_name": "check_true.__call__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 468, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_true", "long_name": "check_true( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 473, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 482, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs", "long_name": "check_noargs( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 42, "parameters": [ "self", "level" ], "start_line": 481, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 488, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args", "long_name": "check_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 43, "parameters": [ "self", "level" ], "start_line": 487, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 500, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args_kw", "long_name": "check_args_kw( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 45, "parameters": [ "self", "level" ], "start_line": 499, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 76, "parameters": [ "self", "level" ], "start_line": 513, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 68, "parameters": [ "self", "level" ], "start_line": 537, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 46, "parameters": [ "self", "level" ], "start_line": 547, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 48, "parameters": [ "self", "level" ], "start_line": 558, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 75, "parameters": [ "self", "level" ], "start_line": 571, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 582, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 53, "parameters": [ "self", "level" ], "start_line": 594, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 79, "parameters": [ "self", "level" ], "start_line": 608, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_hash.__hash__", "long_name": "check_hash.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 633, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_hash", "long_name": "check_hash( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 631, "end_line": 638, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self", "level" ], "start_line": 641, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 647, "end_line": 650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self", "level" ], "start_line": 653, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 659, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_type", "long_name": "check_type( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 665, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_size.__len__", "long_name": "check_size.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_size", "long_name": "check_size( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 673, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_len.__len__", "long_name": "check_len.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 682, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_len", "long_name": "check_len( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 680, "end_line": 686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_length.__len__", "long_name": "check_length.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 689, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_length", "long_name": "check_length( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 687, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_list_refcount", "long_name": "check_list_refcount( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 697, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_int", "long_name": "check_set_int( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self", "level" ], "start_line": 704, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_double", "long_name": "check_set_double( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "level" ], "start_line": 709, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self", "level" ], "start_line": 714, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self", "level" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "level" ], "start_line": 724, "end_line": 728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_key_refcount", "long_name": "check_key_refcount( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 30, "complexity": 4, "token_count": 97, "parameters": [ "self", "level" ], "start_line": 732, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_double_exists", "long_name": "check_set_double_exists( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 101, "parameters": [ "self", "level" ], "start_line": 763, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_set_double_new", "long_name": "check_set_double_new( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 61, "parameters": [ "self", "level" ], "start_line": 776, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_complex", "long_name": "check_set_complex( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 59, "parameters": [ "self", "level" ], "start_line": 783, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 45, "parameters": [ "self", "level" ], "start_line": 790, "end_line": 794, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_class.__init__", "long_name": "check_set_class.__init__( self , val )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 799, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class.__hash__", "long_name": "check_set_class.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 801, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class", "long_name": "check_set_class( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 99, "parameters": [ "self", "level" ], "start_line": 796, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_set_from_member", "long_name": "check_set_from_member( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 46, "parameters": [ "self", "level" ], "start_line": 814, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 42, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 51, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 60, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_stdout", "long_name": "check_stdout( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_stringio", "long_name": "check_stringio( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 81, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_failure", "long_name": "check_failure( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 92, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 118, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 124, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 131, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "bar", "long_name": "bar( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 140, "end_line": 141, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar2", "long_name": "bar2( self , val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "val1", "val2" ], "start_line": 142, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "bar3", "long_name": "bar3( self , val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val1", "val2", "val3" ], "start_line": 144, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 148, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 152, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 160, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 177, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generic_attr", "long_name": "generic_attr( self , code , args = [ 'a' ] )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 65, "parameters": [ "self", "code", "args" ], "start_line": 209, "end_line": 218, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_char_fail", "long_name": "check_char_fail( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 223, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 229, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 232, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_obj_fail", "long_name": "check_obj_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 255, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generic_existing", "long_name": "generic_existing( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code", "desired" ], "start_line": 267, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "generic_new", "long_name": "generic_new( self , code , desired )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "self", "code", "desired" ], "start_line": 274, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_existing_char", "long_name": "check_existing_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_new_char", "long_name": "check_new_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_string", "long_name": "check_existing_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 284, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_new_string", "long_name": "check_new_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 286, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_object", "long_name": "check_existing_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 288, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_object", "long_name": "check_new_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_fail", "long_name": "check_new_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 300, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_existing_int", "long_name": "check_existing_int( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 310, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_double", "long_name": "check_existing_double( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "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": "check_existing_complex", "long_name": "check_existing_complex( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_existing_char1", "long_name": "check_existing_char1( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 320, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_string1", "long_name": "check_existing_string1( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "generic", "long_name": "generic( self , code )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 40, "parameters": [ "self", "code" ], "start_line": 330, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.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": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 339, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_object", "long_name": "check_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_equal", "long_name": "check_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 353, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_equal_objects.__init__", "long_name": "check_equal_objects.__init__( self , x )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "x" ], "start_line": 359, "end_line": 360, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_equal_objects.__cmp__", "long_name": "check_equal_objects.__cmp__( self , other )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 18, "parameters": [ "self", "other" ], "start_line": 361, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_equal_objects", "long_name": "check_equal_objects( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_lt", "long_name": "check_lt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 366, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_gt", "long_name": "check_gt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 370, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_gte", "long_name": "check_gte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 374, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_lte", "long_name": "check_lte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 378, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_not_equal", "long_name": "check_not_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 382, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 386, "end_line": 389, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_int2", "long_name": "check_int2( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 390, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_unsigned_long", "long_name": "check_unsigned_long( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 394, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 398, "end_line": 401, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 402, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 406, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_repr.__str__", "long_name": "check_repr.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 418, "end_line": 419, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_repr.__repr__", "long_name": "check_repr.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 420, "end_line": 421, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_repr", "long_name": "check_repr( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 416, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_str.__str__", "long_name": "check_str.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 434, "end_line": 435, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_str.__repr__", "long_name": "check_str.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 436, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_str", "long_name": "check_str( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 432, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_unicode.__repr__", "long_name": "check_unicode.__repr__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 452, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_unicode.__str__", "long_name": "check_unicode.__str__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 454, "end_line": 455, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_unicode", "long_name": "check_unicode( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_true.__call__", "long_name": "check_true.__call__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 468, "end_line": 469, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 473, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_noargs.foo", "long_name": "check_noargs.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [], "start_line": 482, "end_line": 483, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 481, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args.foo", "long_name": "check_args.foo( val1 , val2 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "val1", "val2" ], "start_line": 488, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 487, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_args_kw.foo", "long_name": "check_args_kw.foo( val1 , val2 , val3 = 1 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "val1", "val2", "val3" ], "start_line": 500, "end_line": 501, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 499, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args.foo", "long_name": "check_noargs_with_args.foo( )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [], "start_line": 516, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 513, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 64, "parameters": [ "self" ], "start_line": 537, "end_line": 546, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 547, "end_line": 557, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 44, "parameters": [ "self" ], "start_line": 558, "end_line": 570, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 571, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 582, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 594, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 75, "parameters": [ "self" ], "start_line": 608, "end_line": 628, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "check_hash.__hash__", "long_name": "check_hash.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 633, "end_line": 634, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_hash", "long_name": "check_hash( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 631, "end_line": 638, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 641, "end_line": 646, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 647, "end_line": 650, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 30, "parameters": [ "self" ], "start_line": 653, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 659, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_type", "long_name": "check_type( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 665, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_size.__len__", "long_name": "check_size.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 675, "end_line": 676, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_size", "long_name": "check_size( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 673, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_len.__len__", "long_name": "check_len.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 682, "end_line": 683, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_len", "long_name": "check_len( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 680, "end_line": 686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_length.__len__", "long_name": "check_length.__len__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 689, "end_line": 690, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_length", "long_name": "check_length( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 687, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_list_refcount", "long_name": "check_list_refcount( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 697, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_int", "long_name": "check_set_int( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 704, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_double", "long_name": "check_set_double( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 709, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 714, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 724, "end_line": 728, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_key_refcount", "long_name": "check_key_refcount( self )", "filename": "test_scxx_object.py", "nloc": 30, "complexity": 4, "token_count": 93, "parameters": [ "self" ], "start_line": 732, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_set_double_exists", "long_name": "check_set_double_exists( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 763, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_set_double_new", "long_name": "check_set_double_new( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 57, "parameters": [ "self" ], "start_line": 776, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_complex", "long_name": "check_set_complex( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 783, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 790, "end_line": 794, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_class.__init__", "long_name": "check_set_class.__init__( self , val )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 799, "end_line": 800, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class.__hash__", "long_name": "check_set_class.__hash__( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 801, "end_line": 802, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 3 }, { "name": "check_set_class", "long_name": "check_set_class( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 796, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_set_from_member", "long_name": "check_set_from_member( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 814, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_object.py", "nloc": 26, "complexity": 2, "token_count": 250, "parameters": [ "level" ], "start_line": 821, "end_line": 847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 849, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_attr_call", "long_name": "check_attr_call( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 60, "parameters": [ "self" ], "start_line": 255, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_object", "long_name": "check_object( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_existing_string", "long_name": "check_existing_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 284, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_equal_objects", "long_name": "check_equal_objects( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 42, "parameters": [ "self", "level" ], "start_line": 481, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_unicode", "long_name": "check_unicode( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 71, "parameters": [ "self", "level" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_existing_object", "long_name": "check_existing_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 288, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_new_object", "long_name": "check_new_object( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_unsigned_long", "long_name": "check_unsigned_long( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 394, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 177, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_existing_char", "long_name": "check_existing_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_new_fail", "long_name": "check_new_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 300, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_new_char", "long_name": "check_new_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 71, "parameters": [ "self" ], "start_line": 571, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 36, "parameters": [ "self", "level" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_std_args", "long_name": "check_std_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 582, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_equal_objects", "long_name": "check_equal_objects( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 357, "end_line": 365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_new_fail", "long_name": "check_new_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 300, "end_line": 308, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_existing_char1", "long_name": "check_existing_char1( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 320, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 473, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_existing_int", "long_name": "check_existing_int( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 310, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self", "level" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_set_class", "long_name": "check_set_class( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 95, "parameters": [ "self" ], "start_line": 796, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 131, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_char_fail", "long_name": "check_char_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 21, "parameters": [ "self", "level" ], "start_line": 223, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_func", "long_name": "check_func( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 32, "parameters": [ "self" ], "start_line": 198, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_int2", "long_name": "check_int2( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 390, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_stringio", "long_name": "check_stringio( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 43, "parameters": [ "self" ], "start_line": 81, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 49, "parameters": [ "self" ], "start_line": 594, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_set_int", "long_name": "check_set_int( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 704, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 51, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_existing_object", "long_name": "check_existing_object( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 288, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_str", "long_name": "check_str( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 69, "parameters": [ "self" ], "start_line": 432, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_set_double_new", "long_name": "check_set_double_new( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 57, "parameters": [ "self" ], "start_line": 776, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_stdout", "long_name": "check_stdout( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self", "level" ], "start_line": 714, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_existing_string", "long_name": "check_existing_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 284, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 60, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_stdout", "long_name": "check_stdout( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_int2", "long_name": "check_int2( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 390, "end_line": 393, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 42, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_existing_string1", "long_name": "check_existing_string1( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 20, "parameters": [ "self", "level" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_object.py", "nloc": 26, "complexity": 2, "token_count": 250, "parameters": [ "level" ], "start_line": 821, "end_line": 847, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 0 }, { "name": "check_existing_int", "long_name": "check_existing_int( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 310, "end_line": 311, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_false", "long_name": "check_false( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 473, "end_line": 478, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_obj_fail", "long_name": "check_obj_fail( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_lte", "long_name": "check_lte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 378, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_lt", "long_name": "check_lt( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 366, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 118, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_key_refcount", "long_name": "check_key_refcount( self )", "filename": "test_scxx_object.py", "nloc": 30, "complexity": 4, "token_count": 93, "parameters": [ "self" ], "start_line": 732, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_lt", "long_name": "check_lt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 366, "end_line": 369, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_equal", "long_name": "check_equal( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 353, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_new_string", "long_name": "check_new_string( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 286, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_stringio", "long_name": "check_stringio( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 1, "token_count": 47, "parameters": [ "self", "level" ], "start_line": 81, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_float_cast", "long_name": "check_float_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 118, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_existing_string1", "long_name": "check_existing_string1( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 322, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_gt", "long_name": "check_gt( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 370, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_repr", "long_name": "check_repr( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 71, "parameters": [ "self", "level" ], "start_line": 416, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_type", "long_name": "check_type( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 37, "parameters": [ "self", "level" ], "start_line": 665, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_size", "long_name": "check_size( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 673, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_new_char", "long_name": "check_new_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 282, "end_line": 283, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_hash", "long_name": "check_hash( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 631, "end_line": 638, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_new_string", "long_name": "check_new_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 286, "end_line": 287, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 45, "parameters": [ "self", "level" ], "start_line": 499, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_gt", "long_name": "check_gt( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 370, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_len", "long_name": "check_len( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 680, "end_line": 686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_noargs_with_args", "long_name": "check_noargs_with_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 76, "parameters": [ "self", "level" ], "start_line": 513, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_unsigned_long", "long_name": "check_unsigned_long( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "level" ], "start_line": 394, "end_line": 397, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_not_equal", "long_name": "check_not_equal( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 382, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_string_cast", "long_name": "check_string_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 131, "end_line": 136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_object", "long_name": "check_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 345, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_std_noargs", "long_name": "check_std_noargs( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 75, "parameters": [ "self", "level" ], "start_line": 571, "end_line": 581, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_set_int", "long_name": "check_set_int( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self", "level" ], "start_line": 704, "end_line": 708, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_std_string", "long_name": "check_std_string( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 60, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_failure", "long_name": "check_failure( self )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 2, "token_count": 21, "parameters": [ "self" ], "start_line": 92, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_set_complex", "long_name": "check_set_complex( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 59, "parameters": [ "self", "level" ], "start_line": 783, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_new_object", "long_name": "check_new_object( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 16, "parameters": [ "self" ], "start_line": 294, "end_line": 299, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_key_refcount", "long_name": "check_key_refcount( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 30, "complexity": 4, "token_count": 97, "parameters": [ "self", "level" ], "start_line": 732, "end_line": 761, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 124, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_lte", "long_name": "check_lte( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 378, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_set_double_new", "long_name": "check_set_double_new( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 61, "parameters": [ "self", "level" ], "start_line": 776, "end_line": 782, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_existing_char", "long_name": "check_existing_char( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 280, "end_line": 281, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_set_double_exists", "long_name": "check_set_double_exists( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 97, "parameters": [ "self" ], "start_line": 763, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_set_from_member", "long_name": "check_set_from_member( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 814, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_complex", "long_name": "check_complex( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 42, "end_line": 50, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_set_char", "long_name": "check_set_char( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 714, "end_line": 718, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_char", "long_name": "check_char( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self", "level" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_existing_complex", "long_name": "check_existing_complex( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 22, "parameters": [ "self", "level" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 849, "end_line": 853, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_std_args", "long_name": "check_std_args( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 582, "end_line": 593, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_obj_fail", "long_name": "check_obj_fail( self )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_set_string", "long_name": "check_set_string( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 719, "end_line": 723, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_existing_complex", "long_name": "check_existing_complex( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 314, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_std_args_kw", "long_name": "check_std_args_kw( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 53, "parameters": [ "self", "level" ], "start_line": 594, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_gte", "long_name": "check_gte( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 374, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_double_cast", "long_name": "check_double_cast( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 18, "parameters": [ "self", "level" ], "start_line": 112, "end_line": 117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 43, "parameters": [ "self", "level" ], "start_line": 487, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_args_kw", "long_name": "check_args_kw( self )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 41, "parameters": [ "self" ], "start_line": 499, "end_line": 512, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_unicode", "long_name": "check_unicode( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 450, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_length", "long_name": "check_length( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 687, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_double", "long_name": "check_set_double( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 48, "parameters": [ "self" ], "start_line": 709, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_string_fail", "long_name": "check_string_fail( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_attr_call", "long_name": "check_attr_call( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 9, "complexity": 1, "token_count": 64, "parameters": [ "self", "level" ], "start_line": 255, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_size", "long_name": "check_size( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 673, "end_line": 679, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_type", "long_name": "check_type( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 665, "end_line": 670, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_inline", "long_name": "check_inline( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 91, "parameters": [ "self", "level" ], "start_line": 177, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "check_string", "long_name": "check_string( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 51, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_gte", "long_name": "check_gte( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 374, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_length", "long_name": "check_length( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 687, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_len", "long_name": "check_len( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 38, "parameters": [ "self", "level" ], "start_line": 680, "end_line": 686, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_list_refcount", "long_name": "check_list_refcount( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 51, "parameters": [ "self", "level" ], "start_line": 697, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_str", "long_name": "check_str( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 13, "complexity": 1, "token_count": 73, "parameters": [ "self", "level" ], "start_line": 432, "end_line": 446, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_set_double_exists", "long_name": "check_set_double_exists( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 101, "parameters": [ "self", "level" ], "start_line": 763, "end_line": 775, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_repr", "long_name": "check_repr( self )", "filename": "test_scxx_object.py", "nloc": 12, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 416, "end_line": 429, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_int_cast", "long_name": "check_int_cast( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 106, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_obj", "long_name": "check_obj( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 22, "parameters": [ "self", "level" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_true", "long_name": "check_true( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 466, "end_line": 472, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_set_double", "long_name": "check_set_double( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "level" ], "start_line": 709, "end_line": 713, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_existing_char1", "long_name": "check_existing_char1( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "level" ], "start_line": 320, "end_line": 321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_char_fail", "long_name": "check_char_fail( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 223, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_int", "long_name": "check_int( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 33, "parameters": [ "self", "level" ], "start_line": 17, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_double", "long_name": "check_double( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 35, "parameters": [ "self", "level" ], "start_line": 34, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_noargs", "long_name": "check_noargs( self )", "filename": "test_scxx_object.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self" ], "start_line": 481, "end_line": 486, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_args", "long_name": "check_args( self )", "filename": "test_scxx_object.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 487, "end_line": 498, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_equal", "long_name": "check_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 353, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_set_complex", "long_name": "check_set_complex( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 783, "end_line": 789, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_not_equal", "long_name": "check_not_equal( self )", "filename": "test_scxx_object.py", "nloc": 4, "complexity": 1, "token_count": 34, "parameters": [ "self" ], "start_line": 382, "end_line": 385, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_existing_double", "long_name": "check_existing_double( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "level" ], "start_line": 312, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_list_refcount", "long_name": "check_list_refcount( self )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 697, "end_line": 703, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 35, "parameters": [ "self", "level" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_existing_double", "long_name": "check_existing_double( self )", "filename": "test_scxx_object.py", "nloc": 2, "complexity": 1, "token_count": 15, "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": "check_noargs_with_args", "long_name": "check_noargs_with_args( self )", "filename": "test_scxx_object.py", "nloc": 18, "complexity": 3, "token_count": 72, "parameters": [ "self" ], "start_line": 513, "end_line": 534, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "check_float", "long_name": "check_float( self )", "filename": "test_scxx_object.py", "nloc": 8, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_complex_cast", "long_name": "check_complex_cast( self )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 124, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_failure", "long_name": "check_failure( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 10, "complexity": 2, "token_count": 25, "parameters": [ "self", "level" ], "start_line": 92, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_set_from_member", "long_name": "check_set_from_member( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 6, "complexity": 1, "token_count": 46, "parameters": [ "self", "level" ], "start_line": 814, "end_line": 819, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_hash", "long_name": "check_hash( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 7, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 631, "end_line": 638, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_set_class", "long_name": "check_set_class( self , level = 5 )", "filename": "test_scxx_object.py", "nloc": 14, "complexity": 1, "token_count": 99, "parameters": [ "self", "level" ], "start_line": 796, "end_line": 813, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 } ], "nloc": 753, "complexity": 133, "token_count": 4311, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import inline_tools", " def check_int(self,level=5):", " def check_float(self,level=5):", " def check_double(self,level=5):", " def check_complex(self,level=5):", " def check_string(self,level=5):", " def check_std_string(self,level=5):", " def check_stdout(self,level=5):", " def check_stringio(self,level=5):", " def check_failure(self,level=5):", " def check_int_cast(self,level=5):", " def check_double_cast(self,level=5):", " def check_float_cast(self,level=5):", " def check_complex_cast(self,level=5):", " def check_string_cast(self,level=5):", " def check_string(self,level=5):", " def check_std_string(self,level=5):", " def check_string_fail(self,level=5):", " def check_inline(self,level=5):", " def check_func(self,level=5):", " def check_char(self,level=5):", " def check_char_fail(self,level=5):", " def check_string(self,level=5):", " def check_string_fail(self,level=5):", " def check_obj(self,level=5):", " def check_obj_fail(self,level=5):", " def check_attr_call(self,level=5):", " def check_existing_char(self,level=5):", " def check_new_char(self,level=5):", " def check_existing_string(self,level=5):", " def check_new_string(self,level=5):", " def check_existing_object(self,level=5):", " def check_new_object(self,level=5):", " def check_new_fail(self,level=5):", " def check_existing_int(self,level=5):", " def check_existing_double(self,level=5):", " def check_existing_complex(self,level=5):", " def check_existing_char1(self,level=5):", " def check_existing_string1(self,level=5):", " def check_char(self,level=5):", " def check_string(self,level=5):", " def check_object(self,level=5):", " def check_equal(self,level=5):", " def check_equal_objects(self,level=5):", " def check_lt(self,level=5):", " def check_gt(self,level=5):", " def check_gte(self,level=5):", " def check_lte(self,level=5):", " def check_not_equal(self,level=5):", " def check_int(self,level=5):", " def check_int2(self,level=5):", " def check_unsigned_long(self,level=5):", " def check_double(self,level=5):", " def check_char(self,level=5):", " def check_std_string(self,level=5):", " def check_repr(self,level=5):", " def check_str(self,level=5):", " def check_unicode(self,level=5):", " def check_true(self,level=5):", " def check_false(self,level=5):", " def check_noargs(self,level=5):", " def check_args(self,level=5):", " def check_args_kw(self,level=5):", " def check_noargs_with_args(self,level=5):", " def check_noargs(self,level=5):", " def check_args(self,level=5):", " def check_args_kw(self,level=5):", " def check_std_noargs(self,level=5):", " def check_std_args(self,level=5):", " def check_std_args_kw(self,level=5):", " def check_noargs_with_args(self,level=5):", " def check_hash(self,level=5):", " def check_true(self,level=5):", " def check_false(self,level=5):", " def check_false(self,level=5):", " def check_true(self,level=5):", " def check_type(self,level=5):", " def check_size(self,level=5):", " def check_len(self,level=5):", " def check_length(self,level=5):", " def check_list_refcount(self,level=5):", " def check_set_int(self,level=5):", " def check_set_double(self,level=5):", " def check_set_char(self,level=5):", " def check_set_string(self,level=5):", " def check_set_string(self,level=5):", " def check_key_refcount(self,level=5):", " def check_set_double_exists(self,level=5):", " def check_set_double_new(self,level=5):", " def check_set_complex(self,level=5):", " def check_set_char(self,level=5):", " def check_set_class(self,level=5):", " def check_set_from_member(self,level=5):", " ScipyTest('weave.scxx').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "add_grandparent_to_path(__name__)", "import inline_tools", " def check_int(self):", " def check_float(self):", " def check_double(self):", " def check_complex(self):", " def check_string(self):", " def check_std_string(self):", " def check_stdout(self):", " def check_stringio(self):", " def check_failure(self):", " def check_int_cast(self):", " def check_double_cast(self):", " def check_float_cast(self):", " def check_complex_cast(self):", " def check_string_cast(self):", " def check_string(self):", " def check_std_string(self):", " def check_string_fail(self):", " def check_inline(self):", " def check_func(self):", " def check_char(self):", " def check_char_fail(self):", " def check_string(self):", " def check_string_fail(self):", " def check_obj(self):", " def check_obj_fail(self):", " def check_attr_call(self):", " def check_existing_char(self):", " def check_new_char(self):", " def check_existing_string(self):", " def check_new_string(self):", " def check_existing_object(self):", " def check_new_object(self):", " def check_new_fail(self):", " def check_existing_int(self):", " def check_existing_double(self):", " def check_existing_complex(self):", " def check_existing_char1(self):", " def check_existing_string1(self):", " def check_char(self):", " def check_string(self):", " def check_object(self):", " def check_equal(self):", " def check_equal_objects(self):", " def check_lt(self):", " def check_gt(self):", " def check_gte(self):", " def check_lte(self):", " def check_not_equal(self):", " def check_int(self):", " def check_int2(self):", " def check_unsigned_long(self):", " def check_double(self):", " def check_char(self):", " def check_std_string(self):", " def check_repr(self):", " def check_str(self):", " def check_unicode(self):", " def check_true(self):", " def check_false(self):", " def check_noargs(self):", " def check_args(self):", " def check_args_kw(self):", " def check_noargs_with_args(self):", " def check_noargs(self):", " def check_args(self):", " def check_args_kw(self):", " def check_std_noargs(self):", " def check_std_args(self):", " def check_std_args_kw(self):", " def check_noargs_with_args(self):", " def check_hash(self):", " def check_true(self):", " def check_false(self):", " def check_false(self):", " def check_true(self):", " def check_type(self):", " def check_size(self):", " def check_len(self):", " def check_length(self):", " def check_list_refcount(self):", " def check_set_int(self):", " def check_set_double(self):", " def check_set_char(self):", " def check_set_string(self):", " def check_set_string(self):", " def check_key_refcount(self):", " def check_set_double_exists(self):", " def check_set_double_new(self):", " def check_set_complex(self):", " def check_set_char(self):", " def check_set_class(self):", " def check_set_from_member(self):", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " suites.append( makeSuite(test_object_construct,'check_'))", " suites.append( makeSuite(test_object_print,'check_'))", " suites.append( makeSuite(test_object_cast,'check_'))", " suites.append( makeSuite(test_object_hasattr,'check_'))", " suites.append( makeSuite(test_object_attr,'check_'))", " suites.append( makeSuite(test_object_set_attr,'check_'))", " suites.append( makeSuite(test_object_del,'check_'))", " suites.append( makeSuite(test_object_cmp,'check_'))", " suites.append( makeSuite(test_object_repr,'check_'))", " suites.append( makeSuite(test_object_str,'check_'))", " suites.append( makeSuite(test_object_unicode,'check_'))", " suites.append( makeSuite(test_object_is_callable,'check_'))", " suites.append( makeSuite(test_object_call,'check_'))", " suites.append( makeSuite(test_object_mcall,'check_'))", " suites.append( makeSuite(test_object_hash,'check_'))", " suites.append( makeSuite(test_object_is_true,'check_'))", " suites.append( makeSuite(test_object_type,'check_'))", " suites.append( makeSuite(test_object_size,'check_'))", " suites.append( makeSuite(test_object_set_item_op_index,'check_'))", " suites.append( makeSuite(test_object_set_item_op_key,'check_'))", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbose=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbose)", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/tests/test_scxx_sequence.py", "new_path": "weave/tests/test_scxx_sequence.py", "filename": "test_scxx_sequence.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,10 +3,10 @@\n import unittest\n import time\n import os,sys\n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n \n-add_grandparent_to_path(__name__)\n-import inline_tools\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import inline_tools\n restore_path()\n \n # Test:\n@@ -20,10 +20,10 @@\n \n from UserList import UserList\n \n-class test_sequence_base(unittest.TestCase):\n+class _test_sequence_base(unittest.TestCase):\n seq_type = None\n \n- def check_conversion(self):\n+ def check_conversion(self,level=5):\n a = self.seq_type([])\n before = sys.getrefcount(a)\n import weave\n@@ -36,7 +36,7 @@ def check_conversion(self):\n #print '2nd,3rd:', before, after\n assert(after == before)\n \n- def check_in(self):\n+ def check_in(self,level=5):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n@@ -88,7 +88,7 @@ def check_in(self):\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n- def check_count(self):\n+ def check_count(self,level=5):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n@@ -122,7 +122,7 @@ def check_count(self):\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n- def check_access_speed(self):\n+ def check_access_speed(self,level=5):\n N = 1000000\n print '%s access -- val = a[i] for N =', (self.seq_type, N)\n a = self.seq_type([0]) * N\n@@ -151,7 +151,7 @@ def check_access_speed(self):\n t2 = time.time()\n print 'weave:', t2 - t1\n \n- def check_access_set_speed(self):\n+ def check_access_set_speed(self,level=5):\n N = 1000000\n print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)\n a = self.seq_type([0]) * N\n@@ -178,10 +178,10 @@ def check_access_set_speed(self):\n print 'weave:', t2 - t1\n assert list(b) == list(a) \n \n-class test_tuple(test_sequence_base):\n+class test_tuple(_test_sequence_base):\n seq_type = tuple\n \n- def check_set_item_operator_equal_fail(self):\n+ def check_set_item_operator_equal_fail(self,level=5):\n # Tuples should only allow setting of variables \n # immediately after creation.\n a = (1,2,3) \n@@ -189,7 +189,7 @@ def check_set_item_operator_equal_fail(self):\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n except TypeError:\n pass \n- def check_set_item_operator_equal(self): \n+ def check_set_item_operator_equal(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[0] = 1;\n@@ -202,7 +202,7 @@ def check_set_item_operator_equal(self):\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n \n- def check_set_item_index_error(self): \n+ def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[4] = 1;\n@@ -213,7 +213,7 @@ def check_set_item_index_error(self):\n assert 0\n except IndexError:\n pass \n- def check_get_item_operator_index_error(self):\n+ def check_get_item_operator_index_error(self,level=5):\n code = \"\"\"\n py::tuple a(3);\n py::object b = a[4]; // should fail.\n@@ -224,9 +224,9 @@ def check_get_item_operator_index_error(self):\n except IndexError:\n pass\n \n-class test_list(test_sequence_base):\n+class test_list(_test_sequence_base):\n seq_type = list\n- def check_append_passed_item(self):\n+ def check_append_passed_item(self,level=5):\n a = []\n item = 1\n \n@@ -243,7 +243,7 @@ def check_append_passed_item(self):\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2 \n- def check_append(self):\n+ def check_append(self,level=5):\n a = []\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n@@ -277,7 +277,7 @@ def check_append(self):\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n- def check_insert(self):\n+ def check_insert(self,level=5):\n a = [1,2,3]\n \n a.insert(1,234)\n@@ -316,7 +316,7 @@ def check_insert(self):\n after1 = sys.getrefcount(a)\n assert after1 == before1\n \n- def check_set_item_operator_equal(self):\n+ def check_set_item_operator_equal(self,level=5):\n a = self.seq_type([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n@@ -348,7 +348,7 @@ def check_set_item_operator_equal(self):\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n- def check_set_item_operator_equal_created(self): \n+ def check_set_item_operator_equal_created(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[0] = 1;\n@@ -360,7 +360,7 @@ def check_set_item_operator_equal_created(self):\n assert a == [1,2,3]\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n- def check_set_item_index_error(self): \n+ def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[4] = 1;\n@@ -370,7 +370,7 @@ def check_set_item_index_error(self):\n assert 0\n except IndexError:\n pass\n- def check_get_item_index_error(self): \n+ def check_get_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n py::object o = a[4];\n@@ -381,7 +381,7 @@ def check_get_item_index_error(self):\n except IndexError:\n pass\n \n- def check_string_add_speed(self):\n+ def check_string_add_speed(self,level=5):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n@@ -407,7 +407,7 @@ def check_string_add_speed(self):\n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n- def check_int_add_speed(self):\n+ def check_int_add_speed(self,level=5):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n@@ -433,20 +433,6 @@ def check_int_add_speed(self):\n print 'weave:', t2 - t1\n assert b == desired \n \n-def test_suite(level=1):\n- from unittest import makeSuite\n- suites = [] \n- if level >= 5:\n- #suites.append( makeSuite(test_list,'check_'))\n- suites.append( makeSuite(test_tuple,'check_'))\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10,verbose=2):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner(verbosity=verbose)\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.scxx').run()\n+\n", "added_lines": 26, "deleted_lines": 40, "source_code": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nfrom UserList import UserList\n\nclass _test_sequence_base(unittest.TestCase):\n seq_type = None\n\n def check_conversion(self,level=5):\n a = self.seq_type([])\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n #print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n #print '2nd,3rd:', before, after\n assert(after == before)\n\n def check_in(self,level=5):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.in(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = a.in(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(0);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = a.in(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(3.1417);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = a.in(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = a.in(\"beta\");'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = \"\"\"\n std::string val = std::string(\"alpha\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"\"\"\n std::string val = std::string(\"beta\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self,level=5):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.count(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = a.count(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = a.count(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = a.count(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = \"\"\"\n std::string alpha = std::string(\"alpha\");\n return_val = a.count(alpha);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n def check_access_speed(self,level=5):\n N = 1000000\n print '%s access -- val = a[i] for N =', (self.seq_type, N)\n a = self.seq_type([0]) * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self,level=5):\n N = 1000000\n print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)\n a = self.seq_type([0]) * N\n # b is always a list so we can assign to it.\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = self.seq_type([0]) * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert list(b) == list(a) \n\nclass test_tuple(_test_sequence_base):\n seq_type = tuple\n\n def check_set_item_operator_equal_fail(self,level=5):\n # Tuples should only allow setting of variables \n # immediately after creation.\n a = (1,2,3) \n try:\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n except TypeError:\n pass \n def check_set_item_operator_equal(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == (1,2,3)\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n\n def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::tuple a(3);\n a[4] = 1;\n return_val = a;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass \n def check_get_item_operator_index_error(self,level=5):\n code = \"\"\"\n py::tuple a(3);\n py::object b = a[4]; // should fail.\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n \nclass test_list(_test_sequence_base):\n seq_type = list\n def check_append_passed_item(self,level=5):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2 \n def check_append(self,level=5):\n a = []\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_insert(self,level=5):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self,level=5):\n a = self.seq_type([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n code = \"\"\"\n std::string val = std::string(\"sissy\");\n a[1] = val;\n \"\"\"\n inline_tools.inline(code,['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_item_operator_equal_created(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == [1,2,3]\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n def check_set_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n a[4] = 1;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n def check_get_item_index_error(self,level=5): \n code = \"\"\"\n py::list a(3);\n py::object o = a[4];\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n\n def check_string_add_speed(self,level=5):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n def check_int_add_speed(self,level=5):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\nif __name__ == \"__main__\":\n ScipyTest('weave.scxx').run()\n\n", "source_code_before": "\"\"\" Test refcounting and behavior of SCXX.\n\"\"\"\nimport unittest\nimport time\nimport os,sys\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport inline_tools\nrestore_path()\n\n# Test:\n# append DONE\n# insert DONE\n# in DONE\n# count DONE\n# setItem DONE\n# operator[] (get)\n# operator[] (set) DONE\n\nfrom UserList import UserList\n\nclass test_sequence_base(unittest.TestCase):\n seq_type = None\n\n def check_conversion(self):\n a = self.seq_type([])\n before = sys.getrefcount(a)\n import weave\n weave.inline(\"\",['a'])\n #print 'first:',before\n # first call is goofing up refcount.\n before = sys.getrefcount(a) \n weave.inline(\"\",['a'])\n after = sys.getrefcount(a) \n #print '2nd,3rd:', before, after\n assert(after == before)\n\n def check_in(self):\n \"\"\" Test the \"in\" method for lists. We'll assume\n it works for sequences if it works here.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.in(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n item = 0\n res = inline_tools.inline(code,['a','item'])\n assert res == 0\n \n # check overloaded in(int val) method\n code = \"return_val = a.in(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(0);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(double val) method\n code = \"return_val = a.in(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"return_val = a.in(3.1417);\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(char* val) method \n code = 'return_val = a.in(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = 'return_val = a.in(\"beta\");'\n res = inline_tools.inline(code,['a'])\n assert res == 0\n \n # check overloaded in(std::string val) method\n code = \"\"\"\n std::string val = std::string(\"alpha\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n code = \"\"\"\n std::string val = std::string(\"beta\");\n return_val = a.in(val);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 0\n\n def check_count(self):\n \"\"\" Test the \"count\" method for lists. We'll assume\n it works for sequences if it works hre.\n \"\"\"\n a = self.seq_type([1,2,'alpha',3.1416])\n\n item = 1\n code = \"return_val = a.count(item);\"\n res = inline_tools.inline(code,['a','item'])\n assert res == 1\n \n # check overloaded count(int val) method\n code = \"return_val = a.count(1);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(double val) method\n code = \"return_val = a.count(3.1416);\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(char* val) method \n code = 'return_val = a.count(\"alpha\");'\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n # check overloaded count(std::string val) method\n code = \"\"\"\n std::string alpha = std::string(\"alpha\");\n return_val = a.count(alpha);\n \"\"\"\n res = inline_tools.inline(code,['a'])\n assert res == 1\n \n def check_access_speed(self):\n N = 1000000\n print '%s access -- val = a[i] for N =', (self.seq_type, N)\n a = self.seq_type([0]) * N\n val = 0\n t1 = time.time()\n for i in xrange(N):\n val = a[i]\n t2 = time.time()\n print 'python1:', t2 - t1\n t1 = time.time()\n for i in a:\n val = i\n t2 = time.time()\n print 'python2:', t2 - t1\n \n code = \"\"\"\n const int N = a.length();\n py::object val;\n for(int i=0; i < N; i++)\n val = a[i];\n \"\"\"\n # compile not included in timing \n inline_tools.inline(code,['a']) \n t1 = time.time()\n inline_tools.inline(code,['a']) \n t2 = time.time()\n print 'weave:', t2 - t1\n\n def check_access_set_speed(self):\n N = 1000000\n print '%s access/set -- b[i] = a[i] for N =', (self.seq_type,N)\n a = self.seq_type([0]) * N\n # b is always a list so we can assign to it.\n b = [1] * N\n t1 = time.time()\n for i in xrange(N):\n b[i] = a[i]\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = self.seq_type([0]) * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = a[i]; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert list(b) == list(a) \n\nclass test_tuple(test_sequence_base):\n seq_type = tuple\n\n def check_set_item_operator_equal_fail(self):\n # Tuples should only allow setting of variables \n # immediately after creation.\n a = (1,2,3) \n try:\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n except TypeError:\n pass \n def check_set_item_operator_equal(self): \n code = \"\"\"\n py::tuple a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == (1,2,3)\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n\n def check_set_item_index_error(self): \n code = \"\"\"\n py::tuple a(3);\n a[4] = 1;\n return_val = a;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass \n def check_get_item_operator_index_error(self):\n code = \"\"\"\n py::tuple a(3);\n py::object b = a[4]; // should fail.\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n \nclass test_list(test_sequence_base):\n seq_type = list\n def check_append_passed_item(self):\n a = []\n item = 1\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(item);\",['a','item'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n before2 = sys.getrefcount(item)\n inline_tools.inline(\"a.append(item);\",['a','item'])\n assert a[0] is item\n del a[0] \n after1 = sys.getrefcount(a)\n after2 = sys.getrefcount(item)\n assert after1 == before1\n assert after2 == before2 \n def check_append(self):\n a = []\n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.append(1);\",['a'])\n del a[0] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded append(int val) method\n inline_tools.inline(\"a.append(1234);\",['a']) \n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 1234\n del a[0] \n\n # check overloaded append(double val) method\n inline_tools.inline(\"a.append(123.0);\",['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 123.0\n del a[0] \n \n # check overloaded append(char* val) method \n inline_tools.inline('a.append(\"bubba\");',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'bubba'\n del a[0] \n \n # check overloaded append(std::string val) method\n inline_tools.inline('a.append(std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[0]) == 2 \n assert a[0] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_insert(self):\n a = [1,2,3]\n \n a.insert(1,234)\n del a[1]\n \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a.insert(1,1234);\",['a'])\n del a[1] \n \n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a.insert(1,1234);\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n del a[1] \n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a.insert(1,123.0);\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n del a[1] \n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a.insert(1,\"bubba\");',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n del a[1] \n \n # check overloaded insert(int ndx, std::string val) method\n inline_tools.inline('a.insert(1,std::string(\"sissy\"));',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n del a[0] \n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n\n def check_set_item_operator_equal(self):\n a = self.seq_type([1,2,3]) \n # temporary refcount fix until I understand why it incs by one.\n inline_tools.inline(\"a[1] = 1234;\",['a'])\n before1 = sys.getrefcount(a)\n \n # check overloaded insert(int ndx, int val) method\n inline_tools.inline(\"a[1] = 1234;\",['a']) \n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 1234\n\n # check overloaded insert(int ndx, double val) method\n inline_tools.inline(\"a[1] = 123.0;\",['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 123.0\n \n # check overloaded insert(int ndx, char* val) method \n inline_tools.inline('a[1] = \"bubba\";',['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'bubba'\n \n # check overloaded insert(int ndx, std::string val) method\n code = \"\"\"\n std::string val = std::string(\"sissy\");\n a[1] = val;\n \"\"\"\n inline_tools.inline(code,['a'])\n assert sys.getrefcount(a[1]) == 2 \n assert a[1] == 'sissy'\n \n after1 = sys.getrefcount(a)\n assert after1 == before1\n def check_set_item_operator_equal_created(self): \n code = \"\"\"\n py::list a(3);\n a[0] = 1;\n a[1] = 2;\n a[2] = 3;\n return_val = a;\n \"\"\"\n a = inline_tools.inline(code)\n assert a == [1,2,3]\n # returned value should only have a single refcount\n assert sys.getrefcount(a) == 2\n def check_set_item_index_error(self): \n code = \"\"\"\n py::list a(3);\n a[4] = 1;\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n def check_get_item_index_error(self): \n code = \"\"\"\n py::list a(3);\n py::object o = a[4];\n \"\"\"\n try:\n a = inline_tools.inline(code)\n assert 0\n except IndexError:\n pass\n\n def check_string_add_speed(self):\n N = 1000000\n print 'string add -- b[i] = a[i] + \"blah\" for N =', N \n a = [\"blah\"] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 'blah'\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [\"blah\"] * N\n b = [1] * N \n code = \"\"\"\n const int N = a.length();\n std::string blah = std::string(\"blah\");\n for(int i=0; i < N; i++)\n b[i] = (std::string)a[i] + blah; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n def check_int_add_speed(self):\n N = 1000000\n print 'int add -- b[i] = a[i] + 1 for N =', N \n a = [0] * N\n desired = [1] * N\n t1 = time.time()\n for i in xrange(N):\n desired[i] = a[i] + 1\n t2 = time.time()\n print 'python:', t2 - t1\n \n a = [0] * N\n b = [0] * N \n code = \"\"\"\n const int N = a.length();\n for(int i=0; i < N; i++)\n b[i] = (int)a[i] + 1; \n \"\"\"\n # compile not included in timing\n inline_tools.inline(code,['a','b']) \n t1 = time.time()\n inline_tools.inline(code,['a','b']) \n t2 = time.time()\n print 'weave:', t2 - t1\n assert b == desired \n\ndef test_suite(level=1):\n from unittest import makeSuite\n suites = [] \n if level >= 5:\n #suites.append( makeSuite(test_list,'check_'))\n suites.append( makeSuite(test_tuple,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbose=2):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner(verbosity=verbose)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_conversion", "long_name": "check_conversion( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 9, "complexity": 1, "token_count": 70, "parameters": [ "self", "level" ], "start_line": 26, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 39, "complexity": 1, "token_count": 225, "parameters": [ "self", "level" ], "start_line": 39, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 21, "complexity": 1, "token_count": 128, "parameters": [ "self", "level" ], "start_line": 91, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 26, "complexity": 3, "token_count": 142, "parameters": [ "self", "level" ], "start_line": 125, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 154, "parameters": [ "self", "level" ], "start_line": 154, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_fail", "long_name": "check_set_item_operator_equal_fail( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "level" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 192, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 205, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_get_item_operator_index_error", "long_name": "check_get_item_operator_index_error( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 216, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 14, "complexity": 1, "token_count": 97, "parameters": [ "self", "level" ], "start_line": 229, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 1, "token_count": 186, "parameters": [ "self", "level" ], "start_line": 246, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 25, "complexity": 1, "token_count": 204, "parameters": [ "self", "level" ], "start_line": 280, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 22, "complexity": 1, "token_count": 174, "parameters": [ "self", "level" ], "start_line": 319, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_created", "long_name": "check_set_item_operator_equal_created( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 351, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 363, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_get_item_index_error", "long_name": "check_get_item_index_error( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 24, "complexity": 2, "token_count": 134, "parameters": [ "self", "level" ], "start_line": 384, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 134, "parameters": [ "self", "level" ], "start_line": 410, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx_sequence.py", "nloc": 9, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 26, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx_sequence.py", "nloc": 39, "complexity": 1, "token_count": 221, "parameters": [ "self" ], "start_line": 39, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx_sequence.py", "nloc": 21, "complexity": 1, "token_count": 124, "parameters": [ "self" ], "start_line": 91, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 26, "complexity": 3, "token_count": 138, "parameters": [ "self" ], "start_line": 125, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 154, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_fail", "long_name": "check_set_item_operator_equal_fail( self )", "filename": "test_scxx_sequence.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 192, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 205, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_get_item_operator_index_error", "long_name": "check_get_item_operator_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 216, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx_sequence.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 229, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 246, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx_sequence.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 280, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx_sequence.py", "nloc": 22, "complexity": 1, "token_count": 170, "parameters": [ "self" ], "start_line": 319, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_created", "long_name": "check_set_item_operator_equal_created( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 351, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 363, "end_line": 372, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_get_item_index_error", "long_name": "check_get_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 384, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 410, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_sequence.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 436, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_sequence.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 445, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_insert", "long_name": "check_insert( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 25, "complexity": 1, "token_count": 204, "parameters": [ "self", "level" ], "start_line": 280, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_get_item_index_error", "long_name": "check_get_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 21, "complexity": 1, "token_count": 128, "parameters": [ "self", "level" ], "start_line": 91, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 150, "parameters": [ "self" ], "start_line": 154, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_conversion", "long_name": "check_conversion( self )", "filename": "test_scxx_sequence.py", "nloc": 9, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 26, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 205, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_scxx_sequence.py", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "level" ], "start_line": 436, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "check_append", "long_name": "check_append( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 1, "token_count": 182, "parameters": [ "self" ], "start_line": 246, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "check_get_item_index_error", "long_name": "check_get_item_index_error( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 373, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 24, "complexity": 2, "token_count": 134, "parameters": [ "self", "level" ], "start_line": 384, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 134, "parameters": [ "self", "level" ], "start_line": 410, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 26, "complexity": 3, "token_count": 138, "parameters": [ "self" ], "start_line": 125, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_set_item_index_error", "long_name": "check_set_item_index_error( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 205, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 14, "complexity": 1, "token_count": 97, "parameters": [ "self", "level" ], "start_line": 229, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_access_set_speed", "long_name": "check_access_set_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 154, "parameters": [ "self", "level" ], "start_line": 154, "end_line": 179, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_fail", "long_name": "check_set_item_operator_equal_fail( self )", "filename": "test_scxx_sequence.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self )", "filename": "test_scxx_sequence.py", "nloc": 39, "complexity": 1, "token_count": 221, "parameters": [ "self" ], "start_line": 39, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "check_get_item_operator_index_error", "long_name": "check_get_item_operator_index_error( self )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 216, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_append", "long_name": "check_append( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 1, "token_count": 186, "parameters": [ "self", "level" ], "start_line": 246, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 1 }, { "name": "check_insert", "long_name": "check_insert( self )", "filename": "test_scxx_sequence.py", "nloc": 25, "complexity": 1, "token_count": 200, "parameters": [ "self" ], "start_line": 280, "end_line": 317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 1 }, { "name": "check_access_speed", "long_name": "check_access_speed( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 26, "complexity": 3, "token_count": 142, "parameters": [ "self", "level" ], "start_line": 125, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "check_conversion", "long_name": "check_conversion( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 9, "complexity": 1, "token_count": 70, "parameters": [ "self", "level" ], "start_line": 26, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 192, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_in", "long_name": "check_in( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 39, "complexity": 1, "token_count": 225, "parameters": [ "self", "level" ], "start_line": 39, "end_line": 89, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_fail", "long_name": "check_set_item_operator_equal_fail( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "level" ], "start_line": 184, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "check_count", "long_name": "check_count( self )", "filename": "test_scxx_sequence.py", "nloc": 21, "complexity": 1, "token_count": 124, "parameters": [ "self" ], "start_line": 91, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 33, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_created", "long_name": "check_set_item_operator_equal_created( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 351, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_get_item_operator_index_error", "long_name": "check_get_item_operator_index_error( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 10, "complexity": 2, "token_count": 28, "parameters": [ "self", "level" ], "start_line": 216, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_set_item_operator_equal_created", "long_name": "check_set_item_operator_equal_created( self )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 35, "parameters": [ "self" ], "start_line": 351, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 , verbose = 2 )", "filename": "test_scxx_sequence.py", "nloc": 5, "complexity": 1, "token_count": 35, "parameters": [ "level", "verbose" ], "start_line": 445, "end_line": 449, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "check_set_item_operator_equal", "long_name": "check_set_item_operator_equal( self , level = 5 )", "filename": "test_scxx_sequence.py", "nloc": 11, "complexity": 1, "token_count": 39, "parameters": [ "self", "level" ], "start_line": 192, "end_line": 203, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "check_append_passed_item", "long_name": "check_append_passed_item( self )", "filename": "test_scxx_sequence.py", "nloc": 14, "complexity": 1, "token_count": 93, "parameters": [ "self" ], "start_line": 229, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_int_add_speed", "long_name": "check_int_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 23, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 410, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "check_string_add_speed", "long_name": "check_string_add_speed( self )", "filename": "test_scxx_sequence.py", "nloc": 24, "complexity": 2, "token_count": 130, "parameters": [ "self" ], "start_line": 384, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 } ], "nloc": 336, "complexity": 28, "token_count": 1961, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import inline_tools", "class _test_sequence_base(unittest.TestCase):", " def check_conversion(self,level=5):", " def check_in(self,level=5):", " def check_count(self,level=5):", " def check_access_speed(self,level=5):", " def check_access_set_speed(self,level=5):", "class test_tuple(_test_sequence_base):", " def check_set_item_operator_equal_fail(self,level=5):", " def check_set_item_operator_equal(self,level=5):", " def check_set_item_index_error(self,level=5):", " def check_get_item_operator_index_error(self,level=5):", "class test_list(_test_sequence_base):", " def check_append_passed_item(self,level=5):", " def check_append(self,level=5):", " def check_insert(self,level=5):", " def check_set_item_operator_equal(self,level=5):", " def check_set_item_operator_equal_created(self,level=5):", " def check_set_item_index_error(self,level=5):", " def check_get_item_index_error(self,level=5):", " def check_string_add_speed(self,level=5):", " def check_int_add_speed(self,level=5):", " ScipyTest('weave.scxx').run()", "" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "add_grandparent_to_path(__name__)", "import inline_tools", "class test_sequence_base(unittest.TestCase):", " def check_conversion(self):", " def check_in(self):", " def check_count(self):", " def check_access_speed(self):", " def check_access_set_speed(self):", "class test_tuple(test_sequence_base):", " def check_set_item_operator_equal_fail(self):", " def check_set_item_operator_equal(self):", " def check_set_item_index_error(self):", " def check_get_item_operator_index_error(self):", "class test_list(test_sequence_base):", " def check_append_passed_item(self):", " def check_append(self):", " def check_insert(self):", " def check_set_item_operator_equal(self):", " def check_set_item_operator_equal_created(self):", " def check_set_item_index_error(self):", " def check_get_item_index_error(self):", " def check_string_add_speed(self):", " def check_int_add_speed(self):", "def test_suite(level=1):", " from unittest import makeSuite", " suites = []", " if level >= 5:", " #suites.append( makeSuite(test_list,'check_'))", " suites.append( makeSuite(test_tuple,'check_'))", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbose=2):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner(verbosity=verbose)", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/tests/test_size_check.py", "new_path": "weave/tests/test_size_check.py", "filename": "test_size_check.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -6,11 +6,10 @@\n except:\n pass # scipy_base.fastumath not available \n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-\n-add_grandparent_to_path(__name__)\n-import size_check\n-from ast_tools import *\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import size_check\n+from weave.ast_tools import *\n restore_path()\n \n empty = array(())\n@@ -443,23 +442,6 @@ def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_make_same_length,'check_') )\n- suites.append( unittest.makeSuite(test_binary_op_size,'check_') )\n- suites.append( unittest.makeSuite(test_dummy_array,'check_') )\n- suites.append( unittest.makeSuite(test_dummy_array_indexing,'check_') )\n- suites.append( unittest.makeSuite(test_reduction,'check_') )\n- suites.append( unittest.makeSuite(test_expressions,'check_') )\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n \n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.size_check').run()\n", "added_lines": 5, "deleted_lines": 23, "source_code": "import unittest, os\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import size_check\nfrom weave.ast_tools import *\nrestore_path()\n\nempty = array(())\n \ndef array_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired)))\n except AssertionError:\n try:\n # kluge for bug in Numeric\n assert (len(actual[0]) == len(actual[1]) == \n len(desired[0]) == len(desired[1]) == 0)\n except: \n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_make_same_length(unittest.TestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(unittest.TestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(unittest.TestCase):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.array_assert_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to Numeric.array\n # on wrapping of indices.\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self): \n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n\n def check_2d_0(self):\n self.generic_2d('a[:]')\n def check_2d_1(self):\n self.generic_2d('a[:2]')\n def check_2d_2(self):\n self.generic_2d('a[:,:]')\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n beg2 = whrandom.choice(choices)\n end2 = whrandom.choice(choices)\n step2 = whrandom.choice(choices) \n expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)\n self.generic_2d(expr) \n except IndexError:\n pass\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n idx = []\n for i in range(9):\n idx.append(whrandom.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(unittest.TestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(unittest.TestCase): \n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.array_assert_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n\nif __name__ == \"__main__\":\n ScipyTest('weave.size_check').run()\n", "source_code_before": "import unittest, os\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport size_check\nfrom ast_tools import *\nrestore_path()\n\nempty = array(())\n \ndef array_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired)))\n except AssertionError:\n try:\n # kluge for bug in Numeric\n assert (len(actual[0]) == len(actual[1]) == \n len(desired[0]) == len(desired[1]) == 0)\n except: \n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_make_same_length(unittest.TestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(unittest.TestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(unittest.TestCase):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.array_assert_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to Numeric.array\n # on wrapping of indices.\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self): \n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n\n def check_2d_0(self):\n self.generic_2d('a[:]')\n def check_2d_1(self):\n self.generic_2d('a[:2]')\n def check_2d_2(self):\n self.generic_2d('a[:,:]')\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n beg2 = whrandom.choice(choices)\n end2 = whrandom.choice(choices)\n step2 = whrandom.choice(choices) \n expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)\n self.generic_2d(expr) \n except IndexError:\n pass\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n idx = []\n for i in range(9):\n idx.append(whrandom.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(unittest.TestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(unittest.TestCase): \n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.array_assert_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_make_same_length,'check_') )\n suites.append( unittest.makeSuite(test_binary_op_size,'check_') )\n suites.append( unittest.makeSuite(test_dummy_array,'check_') )\n suites.append( unittest.makeSuite(test_dummy_array_indexing,'check_') )\n suites.append( unittest.makeSuite(test_reduction,'check_') )\n suites.append( unittest.makeSuite(test_expressions,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "array_assert_equal", "long_name": "array_assert_equal( test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 17, "complexity": 3, "token_count": 120, "parameters": [ "test_string", "actual", "desired" ], "start_line": 17, "end_line": 36, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 40, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 45, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_scalar", "long_name": "check_x_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 49, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_scalar", "long_name": "check_y_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 53, "end_line": 56, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_short", "long_name": "check_x_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 57, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_short", "long_name": "check_y_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 61, "end_line": 64, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 67, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 71, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 78, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 80, "end_line": 83, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x1", "long_name": "check_x1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 84, "end_line": 87, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y1", "long_name": "check_y1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 88, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y", "long_name": "check_x_y( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 92, "end_line": 95, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y2", "long_name": "check_x_y2( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 96, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y3", "long_name": "check_x_y3( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 100, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y4", "long_name": "check_x_y4( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 104, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y5", "long_name": "check_x_y5( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 108, "end_line": 111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y6", "long_name": "check_x_y6( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 112, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y7", "long_name": "check_x_y7( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 116, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 121, "end_line": 123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_error2", "long_name": "check_error2( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 124, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 76, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 129, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 106, "parameters": [ "self", "x", "y", "desired" ], "start_line": 144, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 156, "end_line": 161, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val" ], "start_line": 162, "end_line": 163, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 166, "end_line": 180, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , ary , expr , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self", "ary", "expr", "desired" ], "start_line": 181, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , a , expr )", "filename": "test_size_check.py", "nloc": 9, "complexity": 3, "token_count": 59, "parameters": [ "self", "a", "expr" ], "start_line": 186, "end_line": 195, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "generic_1d", "long_name": "generic_1d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self", "expr" ], "start_line": 196, "end_line": 198, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 199, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 202, "end_line": 204, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_1d_index", "long_name": "generic_1d_index( self , expr )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self", "expr" ], "start_line": 206, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1d_index_0", "long_name": "check_1d_index_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 211, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_1", "long_name": "check_1d_index_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 213, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_2", "long_name": "check_1d_index_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_3", "long_name": "check_1d_index_3( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 217, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_1d_index_calculated", "long_name": "check_1d_index_calculated( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 220, "end_line": 221, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 222, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_1", "long_name": "check_1d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 224, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_2", "long_name": "check_1d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 226, "end_line": 227, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_3", "long_name": "check_1d_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 228, "end_line": 231, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_4", "long_name": "check_1d_4( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "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": "check_1d_5", "long_name": "check_1d_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "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": "check_1d_6", "long_name": "check_1d_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 236, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_7", "long_name": "check_1d_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 238, "end_line": 239, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_8", "long_name": "check_1d_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 240, "end_line": 241, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_9", "long_name": "check_1d_9( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 242, "end_line": 245, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_10", "long_name": "check_1d_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 246, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_0", "long_name": "check_1d_stride_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 249, "end_line": 250, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_1", "long_name": "check_1d_stride_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 251, "end_line": 252, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_2", "long_name": "check_1d_stride_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 253, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_3", "long_name": "check_1d_stride_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "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": "check_1d_stride_4", "long_name": "check_1d_stride_4( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 257, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_stride_5", "long_name": "check_1d_stride_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 261, "end_line": 262, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_6", "long_name": "check_1d_stride_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_7", "long_name": "check_1d_stride_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 265, "end_line": 266, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_8", "long_name": "check_1d_stride_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_9", "long_name": "check_1d_stride_9( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 269, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_10", "long_name": "check_1d_stride_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 271, "end_line": 272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_11", "long_name": "check_1d_stride_11( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 273, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_12", "long_name": "check_1d_stride_12( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 275, "end_line": 276, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_random", "long_name": "check_1d_random( self )", "filename": "test_size_check.py", "nloc": 11, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 277, "end_line": 289, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 291, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 293, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_2", "long_name": "check_2d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 295, "end_line": 296, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_random", "long_name": "check_2d_random( self )", "filename": "test_size_check.py", "nloc": 15, "complexity": 3, "token_count": 120, "parameters": [ "self" ], "start_line": 297, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_3d_random", "long_name": "check_3d_random( self )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 314, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 330, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 335, "end_line": 339, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 340, "end_line": 344, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3d_0", "long_name": "check_3d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 345, "end_line": 349, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_error0", "long_name": "check_error0( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 350, "end_line": 355, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 356, "end_line": 361, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 364, "end_line": 378, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , desired , ** kw )", "filename": "test_size_check.py", "nloc": 20, "complexity": 6, "token_count": 117, "parameters": [ "self", "expr", "desired", "kw" ], "start_line": 379, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , expr , ** kw )", "filename": "test_size_check.py", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self", "expr", "kw" ], "start_line": 399, "end_line": 408, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_generic_1d", "long_name": "check_generic_1d( self )", "filename": "test_size_check.py", "nloc": 14, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 409, "end_line": 422, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_single_index", "long_name": "check_single_index( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 423, "end_line": 426, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_calculated_index", "long_name": "check_calculated_index( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 428, "end_line": 432, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_calculated_index2", "long_name": "check_calculated_index2( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 433, "end_line": 437, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 438, "end_line": 440, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 441, "end_line": 443, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "methods_before": [ { "name": "array_assert_equal", "long_name": "array_assert_equal( test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 17, "complexity": 3, "token_count": 120, "parameters": [ "test_string", "actual", "desired" ], "start_line": 18, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 41, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 29, "parameters": [ "self" ], "start_line": 46, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_scalar", "long_name": "check_x_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 50, "end_line": 53, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_scalar", "long_name": "check_y_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 46, "parameters": [ "self" ], "start_line": 54, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_short", "long_name": "check_x_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 58, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y_short", "long_name": "check_y_short( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 55, "parameters": [ "self" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 32, "parameters": [ "self", "x", "y", "desired" ], "start_line": 68, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 72, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 12, "parameters": [ "self", "val" ], "start_line": 79, "end_line": 80, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_scalar", "long_name": "check_scalar( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 33, "parameters": [ "self" ], "start_line": 81, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x1", "long_name": "check_x1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 85, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_y1", "long_name": "check_y1( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self" ], "start_line": 89, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y", "long_name": "check_x_y( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 93, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y2", "long_name": "check_x_y2( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 97, "end_line": 100, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y3", "long_name": "check_x_y3( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 101, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y4", "long_name": "check_x_y4( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 105, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y5", "long_name": "check_x_y5( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 109, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y6", "long_name": "check_x_y6( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 42, "parameters": [ "self" ], "start_line": 113, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_x_y7", "long_name": "check_x_y7( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 56, "parameters": [ "self" ], "start_line": 117, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 122, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_error2", "long_name": "check_error2( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 28, "parameters": [ "self" ], "start_line": 125, "end_line": 127, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 76, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 130, "end_line": 144, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , x , y , desired )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 106, "parameters": [ "self", "x", "y", "desired" ], "start_line": 145, "end_line": 156, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "generic_error_test", "long_name": "generic_error_test( self , x , y )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 29, "parameters": [ "self", "x", "y" ], "start_line": 157, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "desired_type", "long_name": "desired_type( self , val )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 19, "parameters": [ "self", "val" ], "start_line": 163, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 167, "end_line": 181, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , ary , expr , desired )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 37, "parameters": [ "self", "ary", "expr", "desired" ], "start_line": 182, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , a , expr )", "filename": "test_size_check.py", "nloc": 9, "complexity": 3, "token_count": 59, "parameters": [ "self", "a", "expr" ], "start_line": 187, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "generic_1d", "long_name": "generic_1d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 21, "parameters": [ "self", "expr" ], "start_line": 197, "end_line": 199, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 200, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 203, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_1d_index", "long_name": "generic_1d_index( self , expr )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 30, "parameters": [ "self", "expr" ], "start_line": 207, "end_line": 211, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_1d_index_0", "long_name": "check_1d_index_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 212, "end_line": 213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_1", "long_name": "check_1d_index_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 214, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_2", "long_name": "check_1d_index_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 216, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_index_3", "long_name": "check_1d_index_3( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 218, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_1d_index_calculated", "long_name": "check_1d_index_calculated( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 221, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 223, "end_line": 224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_1", "long_name": "check_1d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 225, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_2", "long_name": "check_1d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "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": "check_1d_3", "long_name": "check_1d_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 229, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_4", "long_name": "check_1d_4( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 233, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_5", "long_name": "check_1d_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 235, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_6", "long_name": "check_1d_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 237, "end_line": 238, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_7", "long_name": "check_1d_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 239, "end_line": 240, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_8", "long_name": "check_1d_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 241, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_9", "long_name": "check_1d_9( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 243, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_10", "long_name": "check_1d_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 247, "end_line": 248, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_0", "long_name": "check_1d_stride_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "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": "check_1d_stride_1", "long_name": "check_1d_stride_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 252, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_2", "long_name": "check_1d_stride_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 254, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_3", "long_name": "check_1d_stride_3( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 256, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_4", "long_name": "check_1d_stride_4( self )", "filename": "test_size_check.py", "nloc": 3, "complexity": 2, "token_count": 17, "parameters": [ "self" ], "start_line": 258, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_1d_stride_5", "long_name": "check_1d_stride_5( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 262, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_6", "long_name": "check_1d_stride_6( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 264, "end_line": 265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_7", "long_name": "check_1d_stride_7( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 266, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_8", "long_name": "check_1d_stride_8( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 268, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_9", "long_name": "check_1d_stride_9( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 270, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_10", "long_name": "check_1d_stride_10( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 272, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_11", "long_name": "check_1d_stride_11( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 274, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_stride_12", "long_name": "check_1d_stride_12( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 276, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_1d_random", "long_name": "check_1d_random( self )", "filename": "test_size_check.py", "nloc": 11, "complexity": 3, "token_count": 87, "parameters": [ "self" ], "start_line": 278, "end_line": 290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 292, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 294, "end_line": 295, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_2", "long_name": "check_2d_2( self )", "filename": "test_size_check.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 296, "end_line": 297, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "check_2d_random", "long_name": "check_2d_random( self )", "filename": "test_size_check.py", "nloc": 15, "complexity": 3, "token_count": 120, "parameters": [ "self" ], "start_line": 298, "end_line": 314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "check_3d_random", "long_name": "check_3d_random( self )", "filename": "test_size_check.py", "nloc": 12, "complexity": 4, "token_count": 86, "parameters": [ "self" ], "start_line": 315, "end_line": 328, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_1d_0", "long_name": "check_1d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 47, "parameters": [ "self" ], "start_line": 331, "end_line": 335, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_0", "long_name": "check_2d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 336, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_2d_1", "long_name": "check_2d_1( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 50, "parameters": [ "self" ], "start_line": 341, "end_line": 345, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_3d_0", "long_name": "check_3d_0( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 53, "parameters": [ "self" ], "start_line": 346, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_error0", "long_name": "check_error0( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 351, "end_line": 356, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_error1", "long_name": "check_error1( self )", "filename": "test_size_check.py", "nloc": 6, "complexity": 2, "token_count": 30, "parameters": [ "self" ], "start_line": 357, "end_line": 362, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "array_assert_equal", "long_name": "array_assert_equal( self , test_string , actual , desired )", "filename": "test_size_check.py", "nloc": 13, "complexity": 2, "token_count": 82, "parameters": [ "self", "test_string", "actual", "desired" ], "start_line": 365, "end_line": 379, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , expr , desired , ** kw )", "filename": "test_size_check.py", "nloc": 20, "complexity": 6, "token_count": 117, "parameters": [ "self", "expr", "desired", "kw" ], "start_line": 380, "end_line": 399, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "generic_wrap", "long_name": "generic_wrap( self , expr , ** kw )", "filename": "test_size_check.py", "nloc": 10, "complexity": 3, "token_count": 55, "parameters": [ "self", "expr", "kw" ], "start_line": 400, "end_line": 409, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "check_generic_1d", "long_name": "check_generic_1d( self )", "filename": "test_size_check.py", "nloc": 14, "complexity": 1, "token_count": 100, "parameters": [ "self" ], "start_line": 410, "end_line": 423, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 1 }, { "name": "check_single_index", "long_name": "check_single_index( self )", "filename": "test_size_check.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 424, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_calculated_index", "long_name": "check_calculated_index( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 429, "end_line": 433, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_calculated_index2", "long_name": "check_calculated_index2( self )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "self" ], "start_line": 434, "end_line": 438, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_2d", "long_name": "generic_2d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "expr" ], "start_line": 439, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "generic_3d", "long_name": "generic_3d( self , expr )", "filename": "test_size_check.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "expr" ], "start_line": 442, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_size_check.py", "nloc": 11, "complexity": 2, "token_count": 104, "parameters": [ "level" ], "start_line": 446, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 458, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_size_check.py", "nloc": 11, "complexity": 2, "token_count": 104, "parameters": [ "level" ], "start_line": 446, "end_line": 456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_size_check.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 458, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 405, "complexity": 114, "token_count": 3031, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import size_check", "from weave.ast_tools import *", " ScipyTest('weave.size_check').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import size_check", "from ast_tools import *", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_make_same_length,'check_') )", " suites.append( unittest.makeSuite(test_binary_op_size,'check_') )", " suites.append( unittest.makeSuite(test_dummy_array,'check_') )", " suites.append( unittest.makeSuite(test_dummy_array_indexing,'check_') )", " suites.append( unittest.makeSuite(test_reduction,'check_') )", " suites.append( unittest.makeSuite(test_expressions,'check_') )", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", " test()" ] } }, { "old_path": "weave/tests/test_slice_handler.py", "new_path": "weave/tests/test_slice_handler.py", "filename": "test_slice_handler.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,12 +1,11 @@\n import unittest\n # Was getting a weird \"no module named slice_handler error with this.\n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-\n-add_grandparent_to_path(__name__)\n-import slice_handler\n-from slice_handler import indexed_array_pattern\n-from ast_tools import *\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import slice_handler\n+from weave.slice_handler import indexed_array_pattern\n+from weave.ast_tools import *\n restore_path()\n \n def print_assert_equal(test_string,actual,desired):\n@@ -166,20 +165,5 @@ def check_simple_expr(self):\n self.generic_test(test,desired)\n \n \n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_slice,'check_') )\n- suites.append( unittest.makeSuite(test_transform_slices,'check_') )\n- suites.append( unittest.makeSuite(test_build_slice_atom,'check_') )\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n\\ No newline at end of file\n+ ScipyTest('weave.slice_handler').run()\n", "added_lines": 6, "deleted_lines": 22, "source_code": "import unittest\n# Was getting a weird \"no module named slice_handler error with this.\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import slice_handler\nfrom weave.slice_handler import indexed_array_pattern\nfrom weave.ast_tools import *\nrestore_path()\n\ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_build_slice_atom(unittest.TestCase):\n def generic_test(self,slice_vars,desired):\n pos = slice_vars['pos']\n ast_list = slice_handler.build_slice_atom(slice_vars,pos)\n actual = ast_to_string(ast_list)\n print_assert_equal('',actual,desired)\n def check_exclusive_end(self):\n slice_vars = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index','pos':0}\n desired = 'slice(1,2-1)'\n self.generic_test(slice_vars,desired)\n \nclass test_slice(unittest.TestCase):\n\n def generic_test(self,suite_string,desired):\n import parser\n ast_tuple = parser.suite(suite_string).totuple()\n found, data = find_first_pattern(ast_tuple,indexed_array_pattern)\n subscript = data['subscript_list'][1] #[0] is symbol, [1] is the supscript\n actual = slice_handler.slice_ast_to_dict(subscript)\n print_assert_equal(suite_string,actual,desired)\n\n def check_empty_2_slice(self):\n \"\"\"match slice from a[:]\"\"\"\n test =\"a[:]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_2_slice(self):\n \"\"\"match slice from a[1:]\"\"\"\n test =\"a[1:]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_2_slice(self):\n \"\"\"match slice from a[:2]\"\"\"\n test =\"a[:2]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_2_slice(self):\n \"\"\"match slice from a[1:2]\"\"\"\n test =\"a[1:2]\"\n desired = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_empty_3_slice(self):\n \"\"\"match slice from a[::]\"\"\"\n test =\"a[::]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_3_slice(self):\n \"\"\"match slice from a[1::]\"\"\"\n test =\"a[1::]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_3_slice(self):\n \"\"\"match slice from a[:2:]\"\"\"\n test =\"a[:2:]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_stp3_slice(self):\n \"\"\"match slice from a[::3]\"\"\"\n test =\"a[::3]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_3_slice(self):\n \"\"\"match slice from a[1:2:]\"\"\"\n test =\"a[1:2:]\"\n desired = {'begin':'1', 'end':'2','step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_step_3_slice(self):\n \"\"\"match slice from a[1::3]\"\"\"\n test =\"a[1::3]\"\n desired = {'begin':'1', 'end':'_end','step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_step_3_slice(self):\n \"\"\"match slice from a[:2:3]\"\"\"\n test =\"a[:2:3]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_stp3_slice(self):\n \"\"\"match slice from a[1:2:3]\"\"\"\n test =\"a[1:2:3]\"\n desired = {'begin':'1', 'end':'2', 'step':'3','single_index':'_index'}\n self.generic_test(test,desired)\n def check_expr_3_slice(self):\n \"\"\"match slice from a[:1+i+2:]\"\"\"\n test =\"a[:1+i+2:]\"\n desired = {'begin':'_beg', 'end':\"1+i+2\",'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_single_index(self):\n \"\"\"match slice from a[0]\"\"\"\n test =\"a[0]\"\n desired = {'begin':'_beg', 'end':\"_end\",'step':'_stp',\n 'single_index':'0'}\n self.generic_test(test,desired)\n\ndef replace_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \nclass test_transform_slices(unittest.TestCase):\n def generic_test(self,suite_string,desired):\n import parser\n ast_list = parser.suite(suite_string).tolist()\n slice_handler.transform_slices(ast_list)\n actual = ast_to_string(ast_list)\n # Remove white space from expressions so that equivelant \n # but differently formatted string will compare equally\n import string\n actual = replace_whitespace(actual)\n desired = replace_whitespace(desired)\n print_assert_equal(suite_string,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"transform a[:] to slice notation\"\"\"\n test =\"a[:]\"\n desired = 'a[slice(_beg,_end,_stp)]'\n self.generic_test(test,desired)\n def check_simple_expr(self):\n \"\"\"transform a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\"\"\n test =\"a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\n desired = \" a[slice(_beg,_end),slice(_beg,_end)] = \"\\\n \" b[slice(_beg,_end), slice(1,1+2-1,3)] *\"\\\n \" (c[slice(1-2+i,_end), slice(_beg,_end)] -\"\\\n \" c[slice(_beg,_end), slice(_beg,_end)])\"\n self.generic_test(test,desired)\n\n\nif __name__ == \"__main__\":\n ScipyTest('weave.slice_handler').run()\n", "source_code_before": "import unittest\n# Was getting a weird \"no module named slice_handler error with this.\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport slice_handler\nfrom slice_handler import indexed_array_pattern\nfrom ast_tools import *\nrestore_path()\n\ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_build_slice_atom(unittest.TestCase):\n def generic_test(self,slice_vars,desired):\n pos = slice_vars['pos']\n ast_list = slice_handler.build_slice_atom(slice_vars,pos)\n actual = ast_to_string(ast_list)\n print_assert_equal('',actual,desired)\n def check_exclusive_end(self):\n slice_vars = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index','pos':0}\n desired = 'slice(1,2-1)'\n self.generic_test(slice_vars,desired)\n \nclass test_slice(unittest.TestCase):\n\n def generic_test(self,suite_string,desired):\n import parser\n ast_tuple = parser.suite(suite_string).totuple()\n found, data = find_first_pattern(ast_tuple,indexed_array_pattern)\n subscript = data['subscript_list'][1] #[0] is symbol, [1] is the supscript\n actual = slice_handler.slice_ast_to_dict(subscript)\n print_assert_equal(suite_string,actual,desired)\n\n def check_empty_2_slice(self):\n \"\"\"match slice from a[:]\"\"\"\n test =\"a[:]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_2_slice(self):\n \"\"\"match slice from a[1:]\"\"\"\n test =\"a[1:]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_2_slice(self):\n \"\"\"match slice from a[:2]\"\"\"\n test =\"a[:2]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_2_slice(self):\n \"\"\"match slice from a[1:2]\"\"\"\n test =\"a[1:2]\"\n desired = {'begin':'1', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_empty_3_slice(self):\n \"\"\"match slice from a[::]\"\"\"\n test =\"a[::]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_3_slice(self):\n \"\"\"match slice from a[1::]\"\"\"\n test =\"a[1::]\"\n desired = {'begin':'1', 'end':'_end', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_3_slice(self):\n \"\"\"match slice from a[:2:]\"\"\"\n test =\"a[:2:]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_stp3_slice(self):\n \"\"\"match slice from a[::3]\"\"\"\n test =\"a[::3]\"\n desired = {'begin':'_beg', 'end':'_end', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_3_slice(self):\n \"\"\"match slice from a[1:2:]\"\"\"\n test =\"a[1:2:]\"\n desired = {'begin':'1', 'end':'2','step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_step_3_slice(self):\n \"\"\"match slice from a[1::3]\"\"\"\n test =\"a[1::3]\"\n desired = {'begin':'1', 'end':'_end','step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_end_step_3_slice(self):\n \"\"\"match slice from a[:2:3]\"\"\"\n test =\"a[:2:3]\"\n desired = {'begin':'_beg', 'end':'2', 'step':'3',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_begin_end_stp3_slice(self):\n \"\"\"match slice from a[1:2:3]\"\"\"\n test =\"a[1:2:3]\"\n desired = {'begin':'1', 'end':'2', 'step':'3','single_index':'_index'}\n self.generic_test(test,desired)\n def check_expr_3_slice(self):\n \"\"\"match slice from a[:1+i+2:]\"\"\"\n test =\"a[:1+i+2:]\"\n desired = {'begin':'_beg', 'end':\"1+i+2\",'step':'_stp',\n 'single_index':'_index'}\n self.generic_test(test,desired)\n def check_single_index(self):\n \"\"\"match slice from a[0]\"\"\"\n test =\"a[0]\"\n desired = {'begin':'_beg', 'end':\"_end\",'step':'_stp',\n 'single_index':'0'}\n self.generic_test(test,desired)\n\ndef replace_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \nclass test_transform_slices(unittest.TestCase):\n def generic_test(self,suite_string,desired):\n import parser\n ast_list = parser.suite(suite_string).tolist()\n slice_handler.transform_slices(ast_list)\n actual = ast_to_string(ast_list)\n # Remove white space from expressions so that equivelant \n # but differently formatted string will compare equally\n import string\n actual = replace_whitespace(actual)\n desired = replace_whitespace(desired)\n print_assert_equal(suite_string,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"transform a[:] to slice notation\"\"\"\n test =\"a[:]\"\n desired = 'a[slice(_beg,_end,_stp)]'\n self.generic_test(test,desired)\n def check_simple_expr(self):\n \"\"\"transform a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\"\"\n test =\"a[:,:] = b[:,1:1+2:3] *(c[1-2+i:,:] - c[:,:])\"\n desired = \" a[slice(_beg,_end),slice(_beg,_end)] = \"\\\n \" b[slice(_beg,_end), slice(1,1+2-1,3)] *\"\\\n \" (c[slice(1-2+i,_end), slice(_beg,_end)] -\"\\\n \" c[slice(_beg,_end), slice(_beg,_end)])\"\n self.generic_test(test,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_slice,'check_') )\n suites.append( unittest.makeSuite(test_transform_slices,'check_') )\n suites.append( unittest.makeSuite(test_build_slice_atom,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()", "methods": [ { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_slice_handler.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 11, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , slice_vars , desired )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "slice_vars", "desired" ], "start_line": 28, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_exclusive_end", "long_name": "check_exclusive_end( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 33, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , suite_string , desired )", "filename": "test_slice_handler.py", "nloc": 7, "complexity": 1, "token_count": 58, "parameters": [ "self", "suite_string", "desired" ], "start_line": 41, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_empty_2_slice", "long_name": "check_empty_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_2_slice", "long_name": "check_begin_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 55, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_end_2_slice", "long_name": "check_end_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 61, "end_line": 66, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_end_2_slice", "long_name": "check_begin_end_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 67, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_empty_3_slice", "long_name": "check_empty_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 73, "end_line": 78, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_3_slice", "long_name": "check_begin_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 79, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_end_3_slice", "long_name": "check_end_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 85, "end_line": 90, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_stp3_slice", "long_name": "check_stp3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 91, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_end_3_slice", "long_name": "check_begin_end_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 97, "end_line": 102, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_step_3_slice", "long_name": "check_begin_step_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 103, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_end_step_3_slice", "long_name": "check_end_step_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 109, "end_line": 114, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_end_stp3_slice", "long_name": "check_begin_end_stp3_slice( self )", "filename": "test_slice_handler.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 115, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_expr_3_slice", "long_name": "check_expr_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 120, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_single_index", "long_name": "check_single_index( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 126, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "replace_whitespace", "long_name": "replace_whitespace( in_str )", "filename": "test_slice_handler.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 133, "end_line": 138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , suite_string , desired )", "filename": "test_slice_handler.py", "nloc": 9, "complexity": 1, "token_count": 57, "parameters": [ "self", "suite_string", "desired" ], "start_line": 141, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_slice_handler.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 153, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_slice_handler.py", "nloc": 7, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 158, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "methods_before": [ { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_slice_handler.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 12, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , slice_vars , desired )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self", "slice_vars", "desired" ], "start_line": 29, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_exclusive_end", "long_name": "check_exclusive_end( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 39, "parameters": [ "self" ], "start_line": 34, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generic_test", "long_name": "generic_test( self , suite_string , desired )", "filename": "test_slice_handler.py", "nloc": 7, "complexity": 1, "token_count": 58, "parameters": [ "self", "suite_string", "desired" ], "start_line": 42, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "check_empty_2_slice", "long_name": "check_empty_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 50, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_2_slice", "long_name": "check_begin_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 56, "end_line": 61, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_end_2_slice", "long_name": "check_end_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 62, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_end_2_slice", "long_name": "check_begin_end_2_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 68, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_empty_3_slice", "long_name": "check_empty_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 74, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_3_slice", "long_name": "check_begin_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 80, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_end_3_slice", "long_name": "check_end_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_stp3_slice", "long_name": "check_stp3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 92, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_end_3_slice", "long_name": "check_begin_end_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 98, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_step_3_slice", "long_name": "check_begin_step_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 104, "end_line": 109, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_end_step_3_slice", "long_name": "check_end_step_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 110, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_begin_end_stp3_slice", "long_name": "check_begin_end_stp3_slice( self )", "filename": "test_slice_handler.py", "nloc": 4, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 116, "end_line": 120, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_expr_3_slice", "long_name": "check_expr_3_slice( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 121, "end_line": 126, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "check_single_index", "long_name": "check_single_index( self )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 36, "parameters": [ "self" ], "start_line": 127, "end_line": 132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "replace_whitespace", "long_name": "replace_whitespace( in_str )", "filename": "test_slice_handler.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 134, "end_line": 139, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "generic_test", "long_name": "generic_test( self , suite_string , desired )", "filename": "test_slice_handler.py", "nloc": 9, "complexity": 1, "token_count": 57, "parameters": [ "self", "suite_string", "desired" ], "start_line": 142, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_slice_handler.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "self" ], "start_line": 154, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "check_simple_expr", "long_name": "check_simple_expr( self )", "filename": "test_slice_handler.py", "nloc": 7, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 159, "end_line": 166, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_slice_handler.py", "nloc": 8, "complexity": 2, "token_count": 65, "parameters": [ "level" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 178, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_slice_handler.py", "nloc": 8, "complexity": 2, "token_count": 65, "parameters": [ "level" ], "start_line": 169, "end_line": 176, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_slice_handler.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 178, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 137, "complexity": 23, "token_count": 951, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import slice_handler", "from weave.slice_handler import indexed_array_pattern", "from weave.ast_tools import *", " ScipyTest('weave.slice_handler').run()" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import slice_handler", "from slice_handler import indexed_array_pattern", "from ast_tools import *", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_slice,'check_') )", " suites.append( unittest.makeSuite(test_transform_slices,'check_') )", " suites.append( unittest.makeSuite(test_build_slice_atom,'check_') )", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/tests/test_standard_array_spec.py", "new_path": "weave/tests/test_standard_array_spec.py", "filename": "test_standard_array_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -8,10 +8,9 @@\n import RandomArray\n import time\n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-\n-add_grandparent_to_path(__name__)\n-import standard_array_spec\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import standard_array_spec\n restore_path()\n \n def remove_whitespace(in_str):\n@@ -48,19 +47,6 @@ def check_type_match_array(self):\n s = standard_array_spec.array_converter() \n assert(s.type_match(arange(4)))\n \n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_array_converter,'check_'))\n-\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.standard_array_spec').run()\n+\n", "added_lines": 5, "deleted_lines": 19, "source_code": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import standard_array_spec\nrestore_path()\n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_array_converter(unittest.TestCase): \n def check_type_match_string(self):\n s = standard_array_spec.array_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = standard_array_spec.array_converter() \n assert(not s.type_match(5))\n def check_type_match_array(self):\n s = standard_array_spec.array_converter() \n assert(s.type_match(arange(4)))\n\nif __name__ == \"__main__\":\n ScipyTest('weave.standard_array_spec').run()\n\n", "source_code_before": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # scipy_base.fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport standard_array_spec\nrestore_path()\n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test.testing\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_array_converter(unittest.TestCase): \n def check_type_match_string(self):\n s = standard_array_spec.array_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = standard_array_spec.array_converter() \n assert(not s.type_match(5))\n def check_type_match_array(self):\n s = standard_array_spec.array_converter() \n assert(s.type_match(arange(4)))\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_array_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_standard_array_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 16, "end_line": 21, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_standard_array_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 23, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 40, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 43, "end_line": 45, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_array", "long_name": "check_type_match_array( self )", "filename": "test_standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 46, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "methods_before": [ { "name": "remove_whitespace", "long_name": "remove_whitespace( in_str )", "filename": "test_standard_array_spec.py", "nloc": 6, "complexity": 1, "token_count": 45, "parameters": [ "in_str" ], "start_line": 17, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "print_assert_equal", "long_name": "print_assert_equal( test_string , actual , desired )", "filename": "test_standard_array_spec.py", "nloc": 13, "complexity": 2, "token_count": 74, "parameters": [ "test_string", "actual", "desired" ], "start_line": 24, "end_line": 38, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 0 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "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": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 44, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_array", "long_name": "check_type_match_array( self )", "filename": "test_standard_array_spec.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "self" ], "start_line": 47, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_standard_array_spec.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 51, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_standard_array_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 59, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_standard_array_spec.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 51, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_standard_array_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 59, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 43, "complexity": 6, "token_count": 250, "diff_parsed": { "added": [ "from scipy_test.testing import *", "set_package_path()", "from weave import standard_array_spec", " ScipyTest('weave.standard_array_spec').run()", "" ], "deleted": [ "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import standard_array_spec", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_array_converter,'check_'))", "", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/tests/test_wx_spec.py", "new_path": "weave/tests/test_wx_spec.py", "filename": "test_wx_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,42 +5,40 @@\n and returned correctly in the local_dict dictionary\n argument\n check_return -- test whether a variable is passed in, modified, and\n- then returned as a function return value correctly \n+ then returned as a function return value correctly\n \"\"\"\n import unittest\n \n-from scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n-\n-add_grandparent_to_path(__name__)\n-import ext_tools\n-import wx_spec\n+from scipy_test.testing import *\n+set_package_path()\n+from weave import ext_tools, wx_spec\n restore_path()\n \n import wxPython\n import wxPython.wx\n \n class test_wx_converter(unittest.TestCase): \n- def check_type_match_string(self):\n+ def check_type_match_string(self,level=5):\n s = wx_spec.wx_converter()\n assert(not s.type_match('string') )\n- def check_type_match_int(self):\n+ def check_type_match_int(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5))\n- def check_type_match_float(self):\n+ def check_type_match_float(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.))\n- def check_type_match_complex(self):\n+ def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n- def check_type_match_complex(self):\n+ def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n- def check_type_match_wxframe(self):\n+ def check_type_match_wxframe(self,level=5):\n s = wx_spec.wx_converter()\n f=wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n assert(s.type_match(f))\n \n- def check_var_in(self):\n+ def check_var_in(self,level=5):\n mod = ext_tools.ext_module('wx_var_in',compiler='msvc')\n a = wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n code = \"\"\"\n@@ -64,7 +62,7 @@ def check_var_in(self):\n except TypeError:\n pass\n \n- def no_check_var_local(self):\n+ def no_check_var_local(self,level=5):\n mod = ext_tools.ext_module('wx_var_local')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n@@ -77,7 +75,7 @@ def no_check_var_local(self):\n q={}\n wx_var_local.test(b,q)\n assert(q['a'] == 'hello')\n- def no_check_return(self):\n+ def no_check_return(self,level=5):\n mod = ext_tools.ext_module('wx_return')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n@@ -93,18 +91,5 @@ def no_check_return(self):\n c = wx_return.test(b)\n assert( c == 'hello')\n \n-def test_suite(level=1):\n- suites = []\n- if level >= 5:\n- suites.append( unittest.makeSuite(test_wx_converter,'check_'))\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10):\n- all_tests = test_suite(level)\n- runner = unittest.TextTestRunner()\n- runner.run(all_tests)\n- return runner\n-\n if __name__ == \"__main__\":\n- test()\n+ ScipyTest('weave.wx_spec').run()\n", "added_lines": 14, "deleted_lines": 29, "source_code": "\"\"\"\ncheck_var_in -- tests whether a variable is passed in correctly\n and also if the passed in variable can be reassigned\ncheck_var_local -- tests wheter a variable is passed in , modified,\n and returned correctly in the local_dict dictionary\n argument\ncheck_return -- test whether a variable is passed in, modified, and\n then returned as a function return value correctly\n\"\"\"\nimport unittest\n\nfrom scipy_test.testing import *\nset_package_path()\nfrom weave import ext_tools, wx_spec\nrestore_path()\n\nimport wxPython\nimport wxPython.wx\n\nclass test_wx_converter(unittest.TestCase): \n def check_type_match_string(self,level=5):\n s = wx_spec.wx_converter()\n assert(not s.type_match('string') )\n def check_type_match_int(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_complex(self,level=5):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_wxframe(self,level=5):\n s = wx_spec.wx_converter()\n f=wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n assert(s.type_match(f))\n \n def check_var_in(self,level=5):\n mod = ext_tools.ext_module('wx_var_in',compiler='msvc')\n a = wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n code = \"\"\"\n a->SetTitle(wxString(\"jim\"));\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'],locals(),globals())\n mod.add_function(test)\n mod.compile()\n import wx_var_in\n b=a\n wx_var_in.test(b)\n assert(b.GetTitle() == \"jim\")\n try:\n b = 1.\n wx_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 1\n wx_var_in.test(b)\n except TypeError:\n pass\n \n def no_check_var_local(self,level=5):\n mod = ext_tools.ext_module('wx_var_local')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = 'a=Py::String(\"hello\");'\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_var_local\n b='bub'\n q={}\n wx_var_local.test(b,q)\n assert(q['a'] == 'hello')\n def no_check_return(self,level=5):\n mod = ext_tools.ext_module('wx_return')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n a= Py::wx(\"hello\");\n return_val = Py::new_reference_to(a);\n \"\"\"\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_return\n b='bub'\n c = wx_return.test(b)\n assert( c == 'hello')\n\nif __name__ == \"__main__\":\n ScipyTest('weave.wx_spec').run()\n", "source_code_before": "\"\"\"\ncheck_var_in -- tests whether a variable is passed in correctly\n and also if the passed in variable can be reassigned\ncheck_var_local -- tests wheter a variable is passed in , modified,\n and returned correctly in the local_dict dictionary\n argument\ncheck_return -- test whether a variable is passed in, modified, and\n then returned as a function return value correctly \n\"\"\"\nimport unittest\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport ext_tools\nimport wx_spec\nrestore_path()\n\nimport wxPython\nimport wxPython.wx\n\nclass test_wx_converter(unittest.TestCase): \n def check_type_match_string(self):\n s = wx_spec.wx_converter()\n assert(not s.type_match('string') )\n def check_type_match_int(self):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5))\n def check_type_match_float(self):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.))\n def check_type_match_complex(self):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_complex(self):\n s = wx_spec.wx_converter() \n assert(not s.type_match(5.+1j))\n def check_type_match_wxframe(self):\n s = wx_spec.wx_converter()\n f=wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n assert(s.type_match(f))\n \n def check_var_in(self):\n mod = ext_tools.ext_module('wx_var_in',compiler='msvc')\n a = wxPython.wx.wxFrame(wxPython.wx.NULL,-1,'bob') \n code = \"\"\"\n a->SetTitle(wxString(\"jim\"));\n \"\"\"\n test = ext_tools.ext_function('test',code,['a'],locals(),globals())\n mod.add_function(test)\n mod.compile()\n import wx_var_in\n b=a\n wx_var_in.test(b)\n assert(b.GetTitle() == \"jim\")\n try:\n b = 1.\n wx_var_in.test(b)\n except TypeError:\n pass\n try:\n b = 1\n wx_var_in.test(b)\n except TypeError:\n pass\n \n def no_check_var_local(self):\n mod = ext_tools.ext_module('wx_var_local')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = 'a=Py::String(\"hello\");'\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_var_local\n b='bub'\n q={}\n wx_var_local.test(b,q)\n assert(q['a'] == 'hello')\n def no_check_return(self):\n mod = ext_tools.ext_module('wx_return')\n a = 'string'\n var_specs = ext_tools.assign_variable_types(['a'],locals())\n code = \"\"\"\n a= Py::wx(\"hello\");\n return_val = Py::new_reference_to(a);\n \"\"\"\n test = ext_tools.ext_function('test',var_specs,code)\n mod.add_function(test)\n mod.compile()\n import wx_return\n b='bub'\n c = wx_return.test(b)\n assert( c == 'hello')\n\ndef test_suite(level=1):\n suites = []\n if level >= 5:\n suites.append( unittest.makeSuite(test_wx_converter,'check_'))\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [ { "name": "check_type_match_string", "long_name": "check_type_match_string( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 24, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "level" ], "start_line": 27, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self", "level" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self", "level" ], "start_line": 33, "end_line": 35, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_wxframe", "long_name": "check_type_match_wxframe( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 4, "complexity": 1, "token_count": 44, "parameters": [ "self", "level" ], "start_line": 36, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 23, "complexity": 3, "token_count": 128, "parameters": [ "self", "level" ], "start_line": 41, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "no_check_var_local", "long_name": "no_check_var_local( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 13, "complexity": 1, "token_count": 86, "parameters": [ "self", "level" ], "start_line": 65, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "no_check_return", "long_name": "no_check_return( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 15, "complexity": 1, "token_count": 79, "parameters": [ "self", "level" ], "start_line": 78, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 } ], "methods_before": [ { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 23, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 29, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 32, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 35, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_wxframe", "long_name": "check_type_match_wxframe( self )", "filename": "test_wx_spec.py", "nloc": 4, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_wx_spec.py", "nloc": 23, "complexity": 3, "token_count": 124, "parameters": [ "self" ], "start_line": 43, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "no_check_var_local", "long_name": "no_check_var_local( self )", "filename": "test_wx_spec.py", "nloc": 13, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 67, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "no_check_return", "long_name": "no_check_return( self )", "filename": "test_wx_spec.py", "nloc": 15, "complexity": 1, "token_count": 75, "parameters": [ "self" ], "start_line": 80, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_wx_spec.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 96, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 103, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_type_match_string", "long_name": "check_type_match_string( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 23, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "self" ], "start_line": 26, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 23, "complexity": 3, "token_count": 128, "parameters": [ "self", "level" ], "start_line": 41, "end_line": 63, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "no_check_var_local", "long_name": "no_check_var_local( self )", "filename": "test_wx_spec.py", "nloc": 13, "complexity": 1, "token_count": 82, "parameters": [ "self" ], "start_line": 67, "end_line": 79, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_var_in", "long_name": "check_var_in( self )", "filename": "test_wx_spec.py", "nloc": 23, "complexity": 3, "token_count": 124, "parameters": [ "self" ], "start_line": 43, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 1 }, { "name": "no_check_return", "long_name": "no_check_return( self )", "filename": "test_wx_spec.py", "nloc": 15, "complexity": 1, "token_count": 75, "parameters": [ "self" ], "start_line": 80, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_wx_spec.py", "nloc": 6, "complexity": 2, "token_count": 39, "parameters": [ "level" ], "start_line": 96, "end_line": 101, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "check_type_match_int", "long_name": "check_type_match_int( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 24, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "test_wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [ "level" ], "start_line": 103, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "no_check_return", "long_name": "no_check_return( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 15, "complexity": 1, "token_count": 79, "parameters": [ "self", "level" ], "start_line": 78, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 29, "parameters": [ "self", "level" ], "start_line": 30, "end_line": 32, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_wxframe", "long_name": "check_type_match_wxframe( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 4, "complexity": 1, "token_count": 44, "parameters": [ "self", "level" ], "start_line": 36, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_type_match_wxframe", "long_name": "check_type_match_wxframe( self )", "filename": "test_wx_spec.py", "nloc": 4, "complexity": 1, "token_count": 40, "parameters": [ "self" ], "start_line": 38, "end_line": 41, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "no_check_var_local", "long_name": "no_check_var_local( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 13, "complexity": 1, "token_count": 86, "parameters": [ "self", "level" ], "start_line": 65, "end_line": 77, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 27, "parameters": [ "self", "level" ], "start_line": 27, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_string", "long_name": "check_type_match_string( self , level = 5 )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 26, "parameters": [ "self", "level" ], "start_line": 21, "end_line": 23, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_complex", "long_name": "check_type_match_complex( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self" ], "start_line": 32, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "check_type_match_float", "long_name": "check_type_match_float( self )", "filename": "test_wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "self" ], "start_line": 29, "end_line": 31, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 } ], "nloc": 89, "complexity": 11, "token_count": 531, "diff_parsed": { "added": [ " then returned as a function return value correctly", "from scipy_test.testing import *", "set_package_path()", "from weave import ext_tools, wx_spec", " def check_type_match_string(self,level=5):", " def check_type_match_int(self,level=5):", " def check_type_match_float(self,level=5):", " def check_type_match_complex(self,level=5):", " def check_type_match_complex(self,level=5):", " def check_type_match_wxframe(self,level=5):", " def check_var_in(self,level=5):", " def no_check_var_local(self,level=5):", " def no_check_return(self,level=5):", " ScipyTest('weave.wx_spec').run()" ], "deleted": [ " then returned as a function return value correctly", "from scipy_distutils.misc_util import add_grandparent_to_path, restore_path", "", "add_grandparent_to_path(__name__)", "import ext_tools", "import wx_spec", " def check_type_match_string(self):", " def check_type_match_int(self):", " def check_type_match_float(self):", " def check_type_match_complex(self):", " def check_type_match_complex(self):", " def check_type_match_wxframe(self):", " def check_var_in(self):", " def no_check_var_local(self):", " def no_check_return(self):", "def test_suite(level=1):", " suites = []", " if level >= 5:", " suites.append( unittest.makeSuite(test_wx_converter,'check_'))", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10):", " all_tests = test_suite(level)", " runner = unittest.TextTestRunner()", " runner.run(all_tests)", " return runner", "", " test()" ] } }, { "old_path": "weave/vtk_spec.py", "new_path": "weave/vtk_spec.py", "filename": "vtk_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -129,15 +129,3 @@ def __cmp__(self,other):\n except:\n pass\n return res\n-\n-\"\"\"\n-# this should only be enabled on machines with access to a display device\n-# It'll cause problems otherwise.\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\"\"\"\n", "added_lines": 0, "deleted_lines": 12, "source_code": "\"\"\"\nVTK type converter.\n\nThis module handles conversion between VTK C++ and VTK Python objects\nso that one can write inline C++ code to manipulate VTK Python\nobjects. It requires that you have VTK and the VTK-Python wrappers\ninstalled. It has been tested with VTK 4.0 and above. The code is\nbased on wx_spec.py. You will need to call inline with include_dirs,\nlibrary_dirs and often even libraries appropriately set for this to\nwork without errors. Sometimes you might need to include additional\nheaders.\n\nDistributed under the SciPy License.\n\nAuthors:\n Prabhu Ramachandran \n Eric Jones \n\"\"\"\n\nimport common_info\nfrom c_spec import common_base_converter\n\n\nvtk_py_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic:\n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n\n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nvtk_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(vtkObjectBase* obj)\n{\n return vtkPythonGetObjectFromPointer(obj);\n}\n\"\"\"\n \n\nclass vtk_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.c_type \n self.to_c_return = None # not used\n self.check_func = None # not used\n hdr = self.class_name + \".h\"\n # Remember that you need both the quotes!\n self.headers.extend(['\"vtkPythonUtil.h\"', '\"vtkObject.h\"',\n '\"%s\"'%hdr])\n #self.include_dirs.extend(vtk_inc)\n #self.define_macros.append(('SOME_VARIABLE', '1'))\n #self.library_dirs.extend(vtk_lib)\n self.libraries.extend(['vtkCommonPython', 'vtkCommon'])\n #self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n if value.IsA('vtkObject'):\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return vtk_py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return vtk_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.__class__.__name__\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n", "source_code_before": "\"\"\"\nVTK type converter.\n\nThis module handles conversion between VTK C++ and VTK Python objects\nso that one can write inline C++ code to manipulate VTK Python\nobjects. It requires that you have VTK and the VTK-Python wrappers\ninstalled. It has been tested with VTK 4.0 and above. The code is\nbased on wx_spec.py. You will need to call inline with include_dirs,\nlibrary_dirs and often even libraries appropriately set for this to\nwork without errors. Sometimes you might need to include additional\nheaders.\n\nDistributed under the SciPy License.\n\nAuthors:\n Prabhu Ramachandran \n Eric Jones \n\"\"\"\n\nimport common_info\nfrom c_spec import common_base_converter\n\n\nvtk_py_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic:\n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n\n %(c_type)s py_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s vtk_ptr = (%(c_type)s) vtkPythonGetPointerFromObject(py_obj, \"%(type_name)s\");\n if (!vtk_ptr)\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return vtk_ptr;\n }\n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nvtk_c_to_py_template = \\\n\"\"\"\nPyObject* %(type_name)s_to_py(vtkObjectBase* obj)\n{\n return vtkPythonGetObjectFromPointer(obj);\n}\n\"\"\"\n \n\nclass vtk_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.c_type \n self.to_c_return = None # not used\n self.check_func = None # not used\n hdr = self.class_name + \".h\"\n # Remember that you need both the quotes!\n self.headers.extend(['\"vtkPythonUtil.h\"', '\"vtkObject.h\"',\n '\"%s\"'%hdr])\n #self.include_dirs.extend(vtk_inc)\n #self.define_macros.append(('SOME_VARIABLE', '1'))\n #self.library_dirs.extend(vtk_lib)\n self.libraries.extend(['vtkCommonPython', 'vtkCommon'])\n #self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n if value.IsA('vtkObject'):\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return vtk_py_to_c_template % self.template_vars()\n\n def c_to_py_code(self):\n return vtk_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.__class__.__name__\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\"\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "vtk_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "vtk_spec.py", "nloc": 11, "complexity": 1, "token_count": 79, "parameters": [ "self" ], "start_line": 70, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "vtk_spec.py", "nloc": 8, "complexity": 3, "token_count": 29, "parameters": [ "self", "value" ], "start_line": 89, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "vtk_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 98, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "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": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "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": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "vtk_spec.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self", "name", "value" ], "start_line": 114, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "vtk_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 121, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "vtk_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 66, "end_line": 68, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "vtk_spec.py", "nloc": 11, "complexity": 1, "token_count": 79, "parameters": [ "self" ], "start_line": 70, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "vtk_spec.py", "nloc": 8, "complexity": 3, "token_count": 29, "parameters": [ "self", "value" ], "start_line": 89, "end_line": 96, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "vtk_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 98, "end_line": 106, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "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": "c_to_py_code", "long_name": "c_to_py_code( self )", "filename": "vtk_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "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": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "vtk_spec.py", "nloc": 5, "complexity": 1, "token_count": 31, "parameters": [ "self", "name", "value" ], "start_line": 114, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "vtk_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 121, "end_line": 131, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "changed_methods": [], "nloc": 107, "complexity": 15, "token_count": 313, "diff_parsed": { "added": [], "deleted": [ "", "\"\"\"", "# this should only be enabled on machines with access to a display device", "# It'll cause problems otherwise.", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "\"\"\"" ] } }, { "old_path": "weave/wx_spec.py", "new_path": "weave/wx_spec.py", "filename": "wx_spec.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -168,14 +168,3 @@ def __cmp__(self,other):\n except:\n pass\n return res\n-\"\"\"\n-# this should only be enabled on machines with access to a display device\n-# It'll cause problems otherwise.\n-def test(level=10):\n- from scipy_test.testing import module_test\n- module_test(__name__,__file__,level=level)\n-\n-def test_suite(level=1):\n- from scipy_test.testing import module_test_suite\n- return module_test_suite(__name__,__file__,level=level)\n-\"\"\" \n\\ No newline at end of file\n", "added_lines": 0, "deleted_lines": 11, "source_code": "import common_info\nfrom c_spec import common_base_converter\nimport sys,os\n\n# these may need user configuration.\nif sys.platform == \"win32\":\n wx_base = r'c:\\third\\wxpython-2.4.0.7'\nelse:\n # probably should do some more discovery here.\n wx_base = '/usr/lib/wxPython'\n\ndef get_wxconfig(flag):\n wxconfig = os.path.join(wx_base,'bin','wx-config')\n import commands\n res,settings = commands.getstatusoutput(wxconfig + ' --' + flag)\n if res:\n msg = wxconfig + ' failed. Impossible to learn wxPython settings'\n raise RuntimeError, msg\n return settings.split()\n\nwx_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj,const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n } \n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nclass wx_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n self.headers.append('\"wx/wx.h\"')\n if sys.platform == \"win32\": \n # These will be used in many cases\n self.headers.append('') \n \n # These are needed for linking.\n self.libraries.extend(['kernel32','user32','gdi32','comdlg32',\n 'winspool', 'winmm', 'shell32', \n 'oldnames', 'comctl32', 'ctl3d32',\n 'odbc32', 'ole32', 'oleaut32', \n 'uuid', 'rpcrt4', 'advapi32', 'wsock32'])\n \n # not sure which of these macros are needed.\n self.define_macros.append(('WIN32', '1'))\n self.define_macros.append(('__WIN32__', '1'))\n self.define_macros.append(('_WINDOWS', '1'))\n self.define_macros.append(('STRICT', '1'))\n # I think this will only work on NT/2000/XP set\n # set to 0x0400 for earlier versions.\n # Hmmm. setting this breaks stuff\n #self.define_macros.append(('WINVER', '0x0350'))\n\n self.library_dirs.append(os.path.join(wx_base,'lib'))\n #self.include_dirs.append(os.path.join(wx_base,'include')) \n self.include_dirs.append(wx_base) \n self.include_dirs.append(os.path.join(wx_base,'include')) \n self.include_dirs.append(os.path.join(wx_base,'include','msw')) \n # how do I discover unicode or not unicode?? \n # non-unicode \n self.libraries.append('wxmsw24h')\n self.include_dirs.append(os.path.join(wx_base,'lib'))\n \n # unicode\n #self.libraries.append('wxmswuh')\n #self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))\n #self.define_macros.append(('UNICODE', '1'))\n else:\n # make sure the gtk files are available \n # ?? Do I need to link to them?\n self.headers.append('\"gdk/gdk.h\"')\n # !! This shouldn't be hard coded.\n self.include_dirs.append(\"/usr/include/gtk-1.2\")\n self.include_dirs.append(\"/usr/include/glib-1.2\")\n self.include_dirs.append(\"/usr/lib/glib/include\")\n cxxflags = get_wxconfig('cxxflags')\n libflags = get_wxconfig('libs') + get_wxconfig('gl-libs')\n \n #older versions of wx do not support the ldflags.\n try:\n ldflags = get_wxconfig('ldflags')\n except RuntimeError:\n ldflags = []\n \n self.extra_compile_args.extend(cxxflags)\n self.extra_link_args.extend(libflags)\n self.extra_link_args.extend(ldflags) \n self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n wx_class = value.this.split('_')[-2]\n if wx_class[:2] == 'wx':\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return wx_to_c_template % self.template_vars()\n\n #def c_to_py_code(self):\n # return simple_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.this.split('_')[-2]\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n", "source_code_before": "import common_info\nfrom c_spec import common_base_converter\nimport sys,os\n\n# these may need user configuration.\nif sys.platform == \"win32\":\n wx_base = r'c:\\third\\wxpython-2.4.0.7'\nelse:\n # probably should do some more discovery here.\n wx_base = '/usr/lib/wxPython'\n\ndef get_wxconfig(flag):\n wxconfig = os.path.join(wx_base,'bin','wx-config')\n import commands\n res,settings = commands.getstatusoutput(wxconfig + ' --' + flag)\n if res:\n msg = wxconfig + ' failed. Impossible to learn wxPython settings'\n raise RuntimeError, msg\n return settings.split()\n\nwx_to_c_template = \\\n\"\"\"\nclass %(type_name)s_handler\n{\npublic: \n %(c_type)s convert_to_%(type_name)s(PyObject* py_obj, const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_conversion_error(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n }\n \n %(c_type)s py_to_%(type_name)s(PyObject* py_obj,const char* name)\n {\n %(c_type)s wx_ptr; \n // work on this error reporting...\n if (SWIG_GetPtrObj(py_obj,(void **) &wx_ptr,\"_%(type_name)s_p\"))\n handle_bad_type(py_obj,\"%(type_name)s\", name);\n %(inc_ref_count)s\n return wx_ptr;\n } \n};\n\n%(type_name)s_handler x__%(type_name)s_handler = %(type_name)s_handler();\n#define convert_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.convert_to_%(type_name)s(py_obj,name)\n#define py_to_%(type_name)s(py_obj,name) \\\\\n x__%(type_name)s_handler.py_to_%(type_name)s(py_obj,name)\n\n\"\"\"\n\nclass wx_converter(common_base_converter):\n def __init__(self,class_name=\"undefined\"):\n self.class_name = class_name\n common_base_converter.__init__(self)\n\n def init_info(self):\n common_base_converter.init_info(self)\n # These are generated on the fly instead of defined at \n # the class level.\n self.type_name = self.class_name\n self.c_type = self.class_name + \"*\"\n self.return_type = self.class_name + \"*\"\n self.to_c_return = None # not used\n self.check_func = None # not used\n self.headers.append('\"wx/wx.h\"')\n if sys.platform == \"win32\": \n # These will be used in many cases\n self.headers.append('') \n \n # These are needed for linking.\n self.libraries.extend(['kernel32','user32','gdi32','comdlg32',\n 'winspool', 'winmm', 'shell32', \n 'oldnames', 'comctl32', 'ctl3d32',\n 'odbc32', 'ole32', 'oleaut32', \n 'uuid', 'rpcrt4', 'advapi32', 'wsock32'])\n \n # not sure which of these macros are needed.\n self.define_macros.append(('WIN32', '1'))\n self.define_macros.append(('__WIN32__', '1'))\n self.define_macros.append(('_WINDOWS', '1'))\n self.define_macros.append(('STRICT', '1'))\n # I think this will only work on NT/2000/XP set\n # set to 0x0400 for earlier versions.\n # Hmmm. setting this breaks stuff\n #self.define_macros.append(('WINVER', '0x0350'))\n\n self.library_dirs.append(os.path.join(wx_base,'lib'))\n #self.include_dirs.append(os.path.join(wx_base,'include')) \n self.include_dirs.append(wx_base) \n self.include_dirs.append(os.path.join(wx_base,'include')) \n self.include_dirs.append(os.path.join(wx_base,'include','msw')) \n # how do I discover unicode or not unicode?? \n # non-unicode \n self.libraries.append('wxmsw24h')\n self.include_dirs.append(os.path.join(wx_base,'lib'))\n \n # unicode\n #self.libraries.append('wxmswuh')\n #self.include_dirs.append(os.path.join(wx_base,'lib','mswdlluh'))\n #self.define_macros.append(('UNICODE', '1'))\n else:\n # make sure the gtk files are available \n # ?? Do I need to link to them?\n self.headers.append('\"gdk/gdk.h\"')\n # !! This shouldn't be hard coded.\n self.include_dirs.append(\"/usr/include/gtk-1.2\")\n self.include_dirs.append(\"/usr/include/glib-1.2\")\n self.include_dirs.append(\"/usr/lib/glib/include\")\n cxxflags = get_wxconfig('cxxflags')\n libflags = get_wxconfig('libs') + get_wxconfig('gl-libs')\n \n #older versions of wx do not support the ldflags.\n try:\n ldflags = get_wxconfig('ldflags')\n except RuntimeError:\n ldflags = []\n \n self.extra_compile_args.extend(cxxflags)\n self.extra_link_args.extend(libflags)\n self.extra_link_args.extend(ldflags) \n self.support_code.append(common_info.swig_support_code)\n \n def type_match(self,value):\n is_match = 0\n try:\n wx_class = value.this.split('_')[-2]\n if wx_class[:2] == 'wx':\n is_match = 1\n except AttributeError:\n pass\n return is_match\n\n def generate_build_info(self):\n if self.class_name != \"undefined\":\n res = common_base_converter.generate_build_info(self)\n else:\n # if there isn't a class_name, we don't want the\n # we don't want the support_code to be included\n import base_info\n res = base_info.base_info()\n return res\n \n def py_to_c_code(self):\n return wx_to_c_template % self.template_vars()\n\n #def c_to_py_code(self):\n # return simple_c_to_py_template % self.template_vars()\n \n def type_spec(self,name,value):\n # factory\n class_name = value.this.split('_')[-2]\n new_spec = self.__class__(class_name)\n new_spec.name = name \n return new_spec\n\n def __cmp__(self,other):\n #only works for equal\n res = -1\n try:\n res = cmp(self.name,other.name) or \\\n cmp(self.__class__, other.__class__) or \\\n cmp(self.class_name, other.class_name) or \\\n cmp(self.type_name,other.type_name)\n except:\n pass\n return res\n\"\"\"\n# this should only be enabled on machines with access to a display device\n# It'll cause problems otherwise.\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\"\"\" ", "methods": [ { "name": "get_wxconfig", "long_name": "get_wxconfig( flag )", "filename": "wx_spec.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "flag" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 56, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 40, "complexity": 3, "token_count": 345, "parameters": [ "self" ], "start_line": 60, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "wx_spec.py", "nloc": 9, "complexity": 3, "token_count": 44, "parameters": [ "self", "value" ], "start_line": 127, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "wx_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 137, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "wx_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 147, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 153, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "wx_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 160, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_wxconfig", "long_name": "get_wxconfig( flag )", "filename": "wx_spec.py", "nloc": 8, "complexity": 2, "token_count": 53, "parameters": [ "flag" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , class_name = \"undefined\" )", "filename": "wx_spec.py", "nloc": 3, "complexity": 1, "token_count": 20, "parameters": [ "self", "class_name" ], "start_line": 56, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "init_info", "long_name": "init_info( self )", "filename": "wx_spec.py", "nloc": 40, "complexity": 3, "token_count": 345, "parameters": [ "self" ], "start_line": 60, "end_line": 125, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 66, "top_nesting_level": 1 }, { "name": "type_match", "long_name": "type_match( self , value )", "filename": "wx_spec.py", "nloc": 9, "complexity": 3, "token_count": 44, "parameters": [ "self", "value" ], "start_line": 127, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "generate_build_info", "long_name": "generate_build_info( self )", "filename": "wx_spec.py", "nloc": 7, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 137, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "py_to_c_code", "long_name": "py_to_c_code( self )", "filename": "wx_spec.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 147, "end_line": 148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "type_spec", "long_name": "type_spec( self , name , value )", "filename": "wx_spec.py", "nloc": 5, "complexity": 1, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 153, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__cmp__", "long_name": "__cmp__( self , other )", "filename": "wx_spec.py", "nloc": 10, "complexity": 5, "token_count": 66, "parameters": [ "self", "other" ], "start_line": 160, "end_line": 170, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "changed_methods": [], "nloc": 125, "complexity": 18, "token_count": 656, "diff_parsed": { "added": [], "deleted": [ "\"\"\"", "# this should only be enabled on machines with access to a display device", "# It'll cause problems otherwise.", "def test(level=10):", " from scipy_test.testing import module_test", " module_test(__name__,__file__,level=level)", "", "def test_suite(level=1):", " from scipy_test.testing import module_test_suite", " return module_test_suite(__name__,__file__,level=level)", "\"\"\"" ] } } ] }, { "hash": "772b74eec5bf8fca3c76959c4afc96a97632d7c4", "msg": "Introduced SourceFilter. Clean ups and minor bug fixes", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-27T12:03:38+00:00", "author_timezone": 0, "committer_date": "2003-10-27T12:03:38+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "4d1b593225e392072f5f684f9fcac8c9efb21916" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 16, "insertions": 57, "lines": 73, "files": 6, "dmm_unit_size": 0.9615384615384616, "dmm_unit_complexity": 0.19230769230769232, "dmm_unit_interfacing": 0.8076923076923077, "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": "@@ -6,12 +6,12 @@\n from scipy_distutils.misc_util import get_path,default_config_dict,dot_join\n import shutil\n \n-def configuration(parent_package=''):\n+def 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__)\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", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/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", "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=''):\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__)\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": 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 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 4, "token_count": 219, "parameters": [ "parent_package" ], "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": 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 }, { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 28, "complexity": 4, "token_count": 219, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 46, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 } ], "nloc": 47, "complexity": 4, "token_count": 315, "diff_parsed": { "added": [ "def configuration(parent_package='',parent_path=None):", " local_path = get_path(__name__,parent_path)" ], "deleted": [ "def configuration(parent_package=''):", " local_path = get_path(__name__)" ] } }, { "old_path": "scipy_distutils/extension.py", "new_path": "scipy_distutils/extension.py", "filename": "extension.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -11,7 +11,7 @@\n __revision__ = \"$Id$\"\n \n from distutils.extension import Extension as old_Extension\n-from scipy_distutils.misc_util import SourceGenerator\n+from scipy_distutils.misc_util import SourceGenerator, SourceFilter\n \n import re\n cxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\n@@ -49,26 +49,44 @@ def __init__ (self, name, sources,\n \n def has_cxx_sources(self):\n for source in self.sources:\n+ if isinstance(source,SourceGenerator) \\\n+ or isinstance(source,SourceFilter):\n+ for s in source.sources:\n+ if cxx_ext_re(s):\n+ return 1\n if cxx_ext_re(str(source)):\n return 1\n return 0\n \n def has_f2py_sources(self):\n for source in self.sources:\n- if fortran_pyf_ext_re(str(source)):\n+ if isinstance(source,SourceGenerator) \\\n+ or isinstance(source,SourceFilter):\n+ for s in source.sources:\n+ if fortran_pyf_ext_re(s):\n+ return 1\n+ elif fortran_pyf_ext_re(source):\n return 1\n return 0\n \n def generate_sources(self):\n- for i in range(len(self.sources)):\n- if isinstance(self.sources[i],SourceGenerator):\n- self.sources[i] = self.sources[i].generate()\n-\n+ new_sources = []\n+ for source in self.sources:\n+ if isinstance(source, SourceGenerator):\n+ new_sources.append(source.generate())\n+ elif isinstance(source, SourceFilter):\n+ new_sources.extend(source.filter())\n+ else:\n+ new_sources.append(source)\n+ self.sources = new_sources\n+ \n def get_sources(self):\n sources = []\n for source in self.sources:\n if isinstance(source,SourceGenerator):\n sources.extend(source.sources)\n+ elif isinstance(source,SourceFilter):\n+ sources.extend(source.sources)\n else:\n sources.append(source)\n return sources\n", "added_lines": 24, "deleted_lines": 6, "source_code": "\"\"\"distutils.extension\n\nProvides the Extension class, used to describe C/C++ extension\nmodules in setup scripts.\n\nOverridden to support f2py and SourceGenerator.\n\"\"\"\n\n# created 2000/05/30, Greg Ward\n\n__revision__ = \"$Id$\"\n\nfrom distutils.extension import Extension as old_Extension\nfrom scipy_distutils.misc_util import SourceGenerator, SourceFilter\n\nimport re\ncxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_pyf_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\\Z',re.I).match\n\nclass Extension(old_Extension):\n def __init__ (self, name, sources,\n include_dirs=None,\n define_macros=None,\n undef_macros=None,\n library_dirs=None,\n libraries=None,\n runtime_library_dirs=None,\n extra_objects=None,\n extra_compile_args=None,\n extra_link_args=None,\n export_symbols=None,\n f2py_options=None\n ):\n old_Extension.__init__(self,name, [],\n include_dirs,\n define_macros,\n undef_macros,\n library_dirs,\n libraries,\n runtime_library_dirs,\n extra_objects,\n extra_compile_args,\n extra_link_args,\n export_symbols)\n # Avoid assert statements checking that sources contains strings:\n self.sources = sources\n \n self.f2py_options = f2py_options or []\n\n def has_cxx_sources(self):\n for source in self.sources:\n if isinstance(source,SourceGenerator) \\\n or isinstance(source,SourceFilter):\n for s in source.sources:\n if cxx_ext_re(s):\n return 1\n if cxx_ext_re(str(source)):\n return 1\n return 0\n\n def has_f2py_sources(self):\n for source in self.sources:\n if isinstance(source,SourceGenerator) \\\n or isinstance(source,SourceFilter):\n for s in source.sources:\n if fortran_pyf_ext_re(s):\n return 1\n elif fortran_pyf_ext_re(source):\n return 1\n return 0\n\n def generate_sources(self):\n new_sources = []\n for source in self.sources:\n if isinstance(source, SourceGenerator):\n new_sources.append(source.generate())\n elif isinstance(source, SourceFilter):\n new_sources.extend(source.filter())\n else:\n new_sources.append(source)\n self.sources = new_sources\n \n def get_sources(self):\n sources = []\n for source in self.sources:\n if isinstance(source,SourceGenerator):\n sources.extend(source.sources)\n elif isinstance(source,SourceFilter):\n sources.extend(source.sources)\n else:\n sources.append(source)\n return sources\n\n# class Extension\n", "source_code_before": "\"\"\"distutils.extension\n\nProvides the Extension class, used to describe C/C++ extension\nmodules in setup scripts.\n\nOverridden to support f2py and SourceGenerator.\n\"\"\"\n\n# created 2000/05/30, Greg Ward\n\n__revision__ = \"$Id$\"\n\nfrom distutils.extension import Extension as old_Extension\nfrom scipy_distutils.misc_util import SourceGenerator\n\nimport re\ncxx_ext_re = re.compile(r'.*[.](cpp|cxx|cc)\\Z',re.I).match\nfortran_pyf_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f|pyf)\\Z',re.I).match\n\nclass Extension(old_Extension):\n def __init__ (self, name, sources,\n include_dirs=None,\n define_macros=None,\n undef_macros=None,\n library_dirs=None,\n libraries=None,\n runtime_library_dirs=None,\n extra_objects=None,\n extra_compile_args=None,\n extra_link_args=None,\n export_symbols=None,\n f2py_options=None\n ):\n old_Extension.__init__(self,name, [],\n include_dirs,\n define_macros,\n undef_macros,\n library_dirs,\n libraries,\n runtime_library_dirs,\n extra_objects,\n extra_compile_args,\n extra_link_args,\n export_symbols)\n # Avoid assert statements checking that sources contains strings:\n self.sources = sources\n \n self.f2py_options = f2py_options or []\n\n def has_cxx_sources(self):\n for source in self.sources:\n if cxx_ext_re(str(source)):\n return 1\n return 0\n\n def has_f2py_sources(self):\n for source in self.sources:\n if fortran_pyf_ext_re(str(source)):\n return 1\n return 0\n\n def generate_sources(self):\n for i in range(len(self.sources)):\n if isinstance(self.sources[i],SourceGenerator):\n self.sources[i] = self.sources[i].generate()\n\n def get_sources(self):\n sources = []\n for source in self.sources:\n if isinstance(source,SourceGenerator):\n sources.extend(source.sources)\n else:\n sources.append(source)\n return sources\n\n# class Extension\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , name , sources , include_dirs = None , define_macros = None , undef_macros = None , library_dirs = None , libraries = None , runtime_library_dirs = None , extra_objects = None , extra_compile_args = None , extra_link_args = None , export_symbols = None , f2py_options = None )", "filename": "extension.py", "nloc": 26, "complexity": 2, "token_count": 97, "parameters": [ "self", "name", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options" ], "start_line": 21, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 7, "token_count": 56, "parameters": [ "self" ], "start_line": 50, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 7, "token_count": 53, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 4, "token_count": 65, "parameters": [ "self" ], "start_line": 72, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_sources", "long_name": "get_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 83, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , name , sources , include_dirs = None , define_macros = None , undef_macros = None , library_dirs = None , libraries = None , runtime_library_dirs = None , extra_objects = None , extra_compile_args = None , extra_link_args = None , export_symbols = None , f2py_options = None )", "filename": "extension.py", "nloc": 26, "complexity": 2, "token_count": 97, "parameters": [ "self", "name", "sources", "include_dirs", "define_macros", "undef_macros", "library_dirs", "libraries", "runtime_library_dirs", "extra_objects", "extra_compile_args", "extra_link_args", "export_symbols", "f2py_options" ], "start_line": 21, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( self )", "filename": "extension.py", "nloc": 5, "complexity": 3, "token_count": 25, "parameters": [ "self" ], "start_line": 50, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "extension.py", "nloc": 5, "complexity": 3, "token_count": 25, "parameters": [ "self" ], "start_line": 56, "end_line": 60, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self )", "filename": "extension.py", "nloc": 4, "complexity": 3, "token_count": 48, "parameters": [ "self" ], "start_line": 62, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_sources", "long_name": "get_sources( self )", "filename": "extension.py", "nloc": 8, "complexity": 3, "token_count": 42, "parameters": [ "self" ], "start_line": 67, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "has_f2py_sources", "long_name": "has_f2py_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 7, "token_count": 53, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "has_cxx_sources", "long_name": "has_cxx_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 7, "token_count": 56, "parameters": [ "self" ], "start_line": 50, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "generate_sources", "long_name": "generate_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 4, "token_count": 65, "parameters": [ "self" ], "start_line": 72, "end_line": 81, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_sources", "long_name": "get_sources( self )", "filename": "extension.py", "nloc": 10, "complexity": 4, "token_count": 58, "parameters": [ "self" ], "start_line": 83, "end_line": 92, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "nloc": 80, "complexity": 24, "token_count": 392, "diff_parsed": { "added": [ "from scipy_distutils.misc_util import SourceGenerator, SourceFilter", " if isinstance(source,SourceGenerator) \\", " or isinstance(source,SourceFilter):", " for s in source.sources:", " if cxx_ext_re(s):", " return 1", " if isinstance(source,SourceGenerator) \\", " or isinstance(source,SourceFilter):", " for s in source.sources:", " if fortran_pyf_ext_re(s):", " return 1", " elif fortran_pyf_ext_re(source):", " new_sources = []", " for source in self.sources:", " if isinstance(source, SourceGenerator):", " new_sources.append(source.generate())", " elif isinstance(source, SourceFilter):", " new_sources.extend(source.filter())", " else:", " new_sources.append(source)", " self.sources = new_sources", "", " elif isinstance(source,SourceFilter):", " sources.extend(source.sources)" ], "deleted": [ "from scipy_distutils.misc_util import SourceGenerator", " if fortran_pyf_ext_re(str(source)):", " for i in range(len(self.sources)):", " if isinstance(self.sources[i],SourceGenerator):", " self.sources[i] = self.sources[i].generate()", "" ] } }, { "old_path": "scipy_distutils/misc_util.py", "new_path": "scipy_distutils/misc_util.py", "filename": "misc_util.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -221,9 +221,18 @@ def get_build_temp():\n return os.path.join('build','temp'+plat_specifier)\n \n class 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):\n- caller_dir = os.path.dirname(sys._getframe(1).f_globals['__file__'])\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@@ -245,3 +254,16 @@ def generate(self):\n self.func(self.target,self.sources,*self.args)\n assert os.path.exists(self.target),`self.target`\n return self.target\n+\n+class 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", "added_lines": 24, "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 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", "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 def __init__(self,func,target,sources=[],*args):\n if not os.path.isabs(target):\n caller_dir = os.path.dirname(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", "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": 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 } ], "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": 10, "complexity": 2, "token_count": 114, "parameters": [ "self", "func", "target", "sources", "args" ], "start_line": 224, "end_line": 233, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 234, "end_line": 235, "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": 236, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 } ], "changed_methods": [ { "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 }, { "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": "__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 } ], "nloc": 202, "complexity": 66, "token_count": 1543, "diff_parsed": { "added": [ " \"\"\" SourceGenerator", " func - creates target, arguments are (target,sources)+args", " sources - target source files", " args - extra arguments to func", "", " If func is None then target must exist and it is touched whenever", " sources are newer.", " \"\"\"", " if not os.path.isabs(target) and func is not None:", " caller_dir = os.path.abspath(os.path.dirname(\\", " sys._getframe(1).f_globals['__file__']))", "", "class SourceFilter:", " \"\"\" SourceFilter", " func - implements criteria to filter sources", " sources - source files", " args - extra arguments to func", " \"\"\"", " def __init__(self,func,sources,*args):", " self.func = func", " self.sources = sources", " self.args = args", " def filter(self):", " return self.func(self.sources,*self.args)" ], "deleted": [ " if not os.path.isabs(target):", " caller_dir = os.path.dirname(sys._getframe(1).f_globals['__file__'])" ] } }, { "old_path": "scipy_distutils/setup_scipy_distutils.py", "new_path": "scipy_distutils/setup_scipy_distutils.py", "filename": "setup_scipy_distutils.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,9 +3,9 @@\n import os\n from misc_util import get_path, default_config_dict, dot_join\n \n-def configuration(parent_package=''):\n+def configuration(parent_package='',parent_path=None):\n package = 'scipy_distutils'\n- local_path = get_path(__name__)\n+ local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n \n sub_package = dot_join(package,'command')\n", "added_lines": 2, "deleted_lines": 2, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package='',parent_path=None):\n package = 'scipy_distutils'\n local_path = get_path(__name__,parent_path)\n config = default_config_dict(package,parent_package)\n\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n\n config['data_files'].append((package,[os.path.join(local_path,'sample_site.cfg')]))\n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n for k,v in config.items():\n if not v:\n del config[k]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **config\n )\n", "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom misc_util import get_path, default_config_dict, dot_join\n\ndef configuration(parent_package=''):\n package = 'scipy_distutils'\n local_path = get_path(__name__)\n config = default_config_dict(package,parent_package)\n\n sub_package = dot_join(package,'command')\n config['packages'].append(dot_join(parent_package,sub_package))\n config['package_dir'][sub_package] = os.path.join(local_path,'command')\n\n config['data_files'].append((package,[os.path.join(local_path,'sample_site.cfg')]))\n return config\n\nif __name__ == '__main__':\n from scipy_distutils_version import scipy_distutils_version\n print 'scipy_distutils Version',scipy_distutils_version\n from distutils.core import setup\n config = configuration()\n for k,v in config.items():\n if not v:\n del config[k]\n setup(version = scipy_distutils_version,\n description = \"Changes to distutils needed for SciPy \"\\\n \"-- mostly Fortran support\",\n author = \"Travis Oliphant, Eric Jones, and Pearu Peterson\",\n author_email = \"scipy-dev@scipy.org\",\n license = \"SciPy License (BSD Style)\",\n url = 'http://www.scipy.org',\n **config\n )\n", "methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_distutils.py", "nloc": 9, "complexity": 1, "token_count": 96, "parameters": [ "parent_package", "parent_path" ], "start_line": 6, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 9, "complexity": 1, "token_count": 90, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_distutils.py", "nloc": 9, "complexity": 1, "token_count": 96, "parameters": [ "parent_package", "parent_path" ], "start_line": 6, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 }, { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_distutils.py", "nloc": 9, "complexity": 1, "token_count": 90, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 0 } ], "nloc": 28, "complexity": 1, "token_count": 182, "diff_parsed": { "added": [ "def configuration(parent_package='',parent_path=None):", " local_path = get_path(__name__,parent_path)" ], "deleted": [ "def configuration(parent_package=''):", " local_path = get_path(__name__)" ] } }, { "old_path": "scipy_test/setup_scipy_test.py", "new_path": "scipy_test/setup_scipy_test.py", "filename": "setup_scipy_test.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,7 +3,7 @@\n import os\n from scipy_distutils.misc_util import default_config_dict\n \n-def configuration(parent_package=''):\n+def configuration(parent_package='',parent_path=None):\n package = 'scipy_test'\n config = default_config_dict(package,parent_package)\n return config\n", "added_lines": 1, "deleted_lines": 1, "source_code": "#!/usr/bin/env python\n\nimport os\nfrom scipy_distutils.misc_util import default_config_dict\n\ndef configuration(parent_package='',parent_path=None):\n package = 'scipy_test'\n config = default_config_dict(package,parent_package)\n return config\n\nif __name__ == '__main__':\n from scipy_test_version import scipy_test_version\n print 'scipy_test Version',scipy_test_version\n from scipy_distutils.core import setup\n setup(version = scipy_test_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy test 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\nfrom scipy_distutils.misc_util import default_config_dict\n\ndef configuration(parent_package=''):\n package = 'scipy_test'\n config = default_config_dict(package,parent_package)\n return config\n\nif __name__ == '__main__':\n from scipy_test_version import scipy_test_version\n print 'scipy_test Version',scipy_test_version\n from scipy_distutils.core import setup\n setup(version = scipy_test_version,\n maintainer = \"SciPy Developers\",\n maintainer_email = \"scipy-dev@scipy.org\",\n description = \"SciPy test 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_test.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "parent_package", "parent_path" ], "start_line": 6, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_test.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' , parent_path = None )", "filename": "setup_scipy_test.py", "nloc": 4, "complexity": 1, "token_count": 24, "parameters": [ "parent_package", "parent_path" ], "start_line": 6, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 }, { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_test.py", "nloc": 4, "complexity": 1, "token_count": 20, "parameters": [ "parent_package" ], "start_line": 6, "end_line": 9, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "nloc": 18, "complexity": 1, "token_count": 83, "diff_parsed": { "added": [ "def configuration(parent_package='',parent_path=None):" ], "deleted": [ "def configuration(parent_package=''):" ] } }, { "old_path": "setup.py", "new_path": "setup.py", "filename": "setup.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -18,11 +18,11 @@\n \n bundle_packages = ['scipy_distutils','scipy_test','scipy_base']\n \n-def get_package_config(name):\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()\n+ config = mod.configuration(parent_path=parent_path)\n finally:\n del sys.path[0]\n return config\n@@ -42,7 +42,8 @@ def setup_package():\n sys.path.insert(0,path)\n \n try:\n- config = map(get_package_config,bundle_packages)\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", "added_lines": 4, "deleted_lines": 3, "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 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", "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):\n sys.path.insert(0,name)\n try:\n mod = __import__('setup_'+name)\n config = mod.configuration()\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(get_package_config,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": "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 } ], "methods_before": [ { "name": "get_package_config", "long_name": "get_package_config( name )", "filename": "setup.py", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "name" ], "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": 32, "complexity": 8, "token_count": 234, "parameters": [], "start_line": 38, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "get_package_config", "long_name": "get_package_config( name )", "filename": "setup.py", "nloc": 8, "complexity": 2, "token_count": 43, "parameters": [ "name" ], "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": 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 }, { "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 } ], "nloc": 65, "complexity": 12, "token_count": 369, "diff_parsed": { "added": [ "def get_package_config(name,parent_path=None):", " config = mod.configuration(parent_path=parent_path)", " config = map(lambda x:get_package_config(x,parent_path=path),", " bundle_packages)" ], "deleted": [ "def get_package_config(name):", " config = mod.configuration()", " config = map(get_package_config,bundle_packages)" ] } } ] }, { "hash": "a4a7063078b5e240f52ad325088b8b0a700c677c", "msg": "Fixed bug.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-27T16:53:33+00:00", "author_timezone": 0, "committer_date": "2003-10-27T16:53:33+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "772b74eec5bf8fca3c76959c4afc96a97632d7c4" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 1, "insertions": 3, "lines": 4, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "old_path": "scipy_distutils/command/run_f2py.py", "new_path": "scipy_distutils/command/run_f2py.py", "filename": "run_f2py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -67,6 +67,8 @@ def run (self):\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n+ if hasattr(ext,'generate_sources'):\n+ ext.generate_sources()\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n@@ -225,7 +227,7 @@ def fortran_sources_to_flib(self, ext):\n f_files = []\n \n for file in ext.sources:\n- if fortran_ext_re(str(file)):\n+ if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n", "added_lines": 3, "deleted_lines": 1, "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text,SourceGenerator\nfrom scipy_distutils import log\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n if hasattr(ext,'generate_sources'):\n ext.generate_sources()\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n log.info('using F2PY %s', f2py2e.f2py2e.f2py_version)\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n if isinstance(source,SourceGenerator):\n (base, source_ext) = os.path.splitext(str(source))\n (source_dir, base) = os.path.split(base)\n else:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n if isinstance(source,SourceGenerator):\n source = source.generate()\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n log.warn('%s provides %s but this extension is %s',\n source,`base`,`ext_name`)\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n if isinstance(source,SourceGenerator):\n source = source.generate()\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n log.debug(\"f2py %s\",\n string.join(fortran_sources + f2py_opts2,' '))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n log.warn('Only one .pyf file can be used per Extension'\\\n ' but got %s.', len(f2py_sources))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n log.debug(\"f2py %s\",\n string.join(f2py_options+[source],' '))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name+'_f2py'\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n\n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "source_code_before": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom distutils.cmd import Command\n#from scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\nfrom scipy_distutils.misc_util import red_text,yellow_text,SourceGenerator\nfrom scipy_distutils import log\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n log.info('using F2PY %s', f2py2e.f2py2e.f2py_version)\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n if isinstance(source,SourceGenerator):\n (base, source_ext) = os.path.splitext(str(source))\n (source_dir, base) = os.path.split(base)\n else:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n if isinstance(source,SourceGenerator):\n source = source.generate()\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n log.warn('%s provides %s but this extension is %s',\n source,`base`,`ext_name`)\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n if isinstance(source,SourceGenerator):\n source = source.generate()\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n log.debug(\"f2py %s\",\n string.join(fortran_sources + f2py_opts2,' '))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n log.warn('Only one .pyf file can be used per Extension'\\\n ' but got %s.', len(f2py_sources))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n log.debug(\"f2py %s\",\n string.join(f2py_options+[source],' '))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(str(file)):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name+'_f2py'\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n\n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "methods": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 48, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 4, "token_count": 56, "parameters": [ "self" ], "start_line": 62, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 109, "complexity": 31, "token_count": 772, "parameters": [ "self", "sources", "ext" ], "start_line": 76, "end_line": 217, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 142, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 198, "parameters": [ "self", "ext" ], "start_line": 221, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 39, "end_line": 44, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 48, "end_line": 58, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 62, "end_line": 71, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 109, "complexity": 31, "token_count": 772, "parameters": [ "self", "sources", "ext" ], "start_line": 74, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 142, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 201, "parameters": [ "self", "ext" ], "start_line": 219, "end_line": 255, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 7, "complexity": 4, "token_count": 56, "parameters": [ "self" ], "start_line": 62, "end_line": 73, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 198, "parameters": [ "self", "ext" ], "start_line": 221, "end_line": 257, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "nloc": 186, "complexity": 47, "token_count": 1269, "diff_parsed": { "added": [ " if hasattr(ext,'generate_sources'):", " ext.generate_sources()", " if fortran_ext_re(file):" ], "deleted": [ " if fortran_ext_re(str(file)):" ] } } ] }, { "hash": "b03d812ec59ce430e851bd4e89f4960f5452f0f8", "msg": "Fixed typo", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-28T06:44:37+00:00", "author_timezone": 0, "committer_date": "2003-10-28T06:44:37+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "a4a7063078b5e240f52ad325088b8b0a700c677c" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/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/system_info.py", "new_path": "scipy_distutils/system_info.py", "filename": "system_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -393,7 +393,7 @@ class sfftw_threads_info(fftw_info):\n \n class djbfft_info(system_info):\n section = 'djbfft'\n- dir_env_var = 'DJBFFTW'\n+ dir_env_var = 'DJBFFT'\n \n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n", "added_lines": 1, "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 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.verbose - 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 verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\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.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\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.verbose 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 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 = 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\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(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 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 = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(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(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 = 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 = (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] + 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] + 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 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):\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 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 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.verbose - 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 verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\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.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\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.verbose 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 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 = 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\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(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 = 'DJBFFTW'\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 = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(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(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 = 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 = (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] + 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] + 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 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):\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 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 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": 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 , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 207, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "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": 228, "end_line": 229, "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": 231, "end_line": 232, "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": 147, "parameters": [ "self" ], "start_line": 234, "end_line": 258, "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": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 260, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 270, "end_line": 271, "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": 273, "end_line": 274, "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": 276, "end_line": 277, "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": 279, "end_line": 284, "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": 286, "end_line": 295, "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": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 297, "end_line": 305, "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": 307, "end_line": 309, "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": 311, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 329, "end_line": 330, "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": 148, "parameters": [ "self" ], "start_line": 332, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 398, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 70, "parameters": [ "self", "section", "key" ], "start_line": 421, "end_line": 427, "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": 348, "parameters": [ "self" ], "start_line": 429, "end_line": 493, "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": 499, "end_line": 510, "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": 516, "end_line": 521, "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": 523, "end_line": 607, "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": 614, "end_line": 625, "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": 64, "parameters": [ "self", "section", "key" ], "start_line": 631, "end_line": 636, "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": 638, "end_line": 673, "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": 678, "end_line": 681, "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": 114, "parameters": [ "self" ], "start_line": 683, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 704, "end_line": 725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "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": 727, "end_line": 735, "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": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 737, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "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 , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 207, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "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": 228, "end_line": 229, "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": 231, "end_line": 232, "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": 147, "parameters": [ "self" ], "start_line": 234, "end_line": 258, "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": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 260, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 270, "end_line": 271, "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": 273, "end_line": 274, "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": 276, "end_line": 277, "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": 279, "end_line": 284, "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": 286, "end_line": 295, "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": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 297, "end_line": 305, "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": 307, "end_line": 309, "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": 311, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 329, "end_line": 330, "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": 148, "parameters": [ "self" ], "start_line": 332, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 398, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 70, "parameters": [ "self", "section", "key" ], "start_line": 421, "end_line": 427, "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": 348, "parameters": [ "self" ], "start_line": 429, "end_line": 493, "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": 499, "end_line": 510, "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": 516, "end_line": 521, "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": 523, "end_line": 607, "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": 614, "end_line": 625, "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": 64, "parameters": [ "self", "section", "key" ], "start_line": 631, "end_line": 636, "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": 638, "end_line": 673, "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": 678, "end_line": 681, "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": 114, "parameters": [ "self" ], "start_line": 683, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 704, "end_line": 725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "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": 727, "end_line": 735, "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": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 737, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 662, "complexity": 127, "token_count": 3278, "diff_parsed": { "added": [ " dir_env_var = 'DJBFFT'" ], "deleted": [ " dir_env_var = 'DJBFFTW'" ] } } ] }, { "hash": "11cffa55fceeda7a779a5a596b22fb98270f22b8", "msg": "Fixed detecting djbfft on freebsd. Changed system_info.verbose to verbosity and added verbosity=2 output.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-28T08:46:53+00:00", "author_timezone": 0, "committer_date": "2003-10-28T08:46:53+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "b03d812ec59ce430e851bd4e89f4960f5452f0f8" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 16, "insertions": 37, "lines": 53, "files": 1, "dmm_unit_size": 0.5789473684210527, "dmm_unit_complexity": 0.05263157894736842, "dmm_unit_interfacing": 0.5263157894736842, "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": "@@ -26,7 +26,7 @@\n Global parameters:\n system_info.search_static_first - search static libraries (.a)\n in precedence to shared ones (.so, .sl) if enabled.\n- system_info.verbose - output the results to stdout if enabled.\n+ system_info.verbosity - output the results to stdout if enabled.\n \n The file 'site.cfg' in the same directory as this module is read\n for configuration options. The format is that used by ConfigParser (i.e.,\n@@ -201,12 +201,13 @@ class system_info:\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- verbose = 1\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@@ -238,18 +239,18 @@ def get_info(self):\n flag = 0\n if not self.has_info():\n flag = 1\n- if self.verbose:\n+ if self.verbosity>0:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n- if self.verbose:\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.verbose and flag:\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@@ -265,6 +266,8 @@ def get_paths(self, section, key):\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@@ -298,7 +301,7 @@ def _lib_list(self, lib_dir, libs, ext):\n assert type(lib_dir) is type('')\n liblist = []\n for l in libs:\n- p = combine_paths(lib_dir, 'lib'+l+ext)\n+ p = self.combine_paths(lib_dir, 'lib'+l+ext)\n if p:\n assert len(p)==1\n liblist.append(p[0])\n@@ -319,6 +322,9 @@ def _check_libs(self,lib_dir,libs, opt_libs, ext):\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+\n class fftw_info(system_info):\n section = 'fftw'\n dir_env_var = 'FFTW'\n@@ -343,7 +349,7 @@ def calc_info(self):\n if info is not None:\n flag = 0\n for d in incl_dirs:\n- if len(combine_paths(d,self.includes))==2:\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@@ -395,19 +401,30 @@ class 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 = combine_paths (d,['djbfft.a'])\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(combine_paths(d,['fftc8.h','fftfreq.h']))==2:\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@@ -422,7 +439,7 @@ 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(combine_paths(d,['atlas*','ATLAS*',\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@@ -437,7 +454,7 @@ def calc_info(self):\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n- lib_dirs2 = combine_paths(d,['atlas*','ATLAS*'])+[d]\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@@ -449,7 +466,7 @@ def calc_info(self):\n if atlas is None:\n return\n include_dirs = self.get_include_dirs()\n- h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\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@@ -517,7 +534,7 @@ 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] + combine_paths(d,['LAPACK*/SRC','SRC']))\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@@ -632,7 +649,7 @@ 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] + combine_paths(d,['blas']))\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@@ -694,14 +711,14 @@ def calc_info(self):\n return\n inc_dir = None\n for d in include_dirs:\n- if combine_paths(d, 'X11/X.h'):\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 \n-def combine_paths(*args):\n+def combine_paths(*args,**kws):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n@@ -722,6 +739,9 @@ def combine_paths(*args):\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 \n def dict_append(d,**kws):\n@@ -741,6 +761,7 @@ def show_all():\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 \n if __name__ == \"__main__\":\n", "added_lines": 37, "deleted_lines": 16, "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 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", "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.verbose - 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 verbose = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\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.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\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.verbose 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 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 = 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\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(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 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 = combine_paths (d,['djbfft.a'])\n if p:\n info = {'extra_objects':p}\n break\n if info is None:\n return\n for d in incl_dirs:\n if len(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(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 = 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 = (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] + 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] + 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 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):\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 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 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": 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 } ], "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 , )", "filename": "system_info.py", "nloc": 20, "complexity": 2, "token_count": 182, "parameters": [ "self", "default_lib_dirs", "default_include_dirs" ], "start_line": 207, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "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": 228, "end_line": 229, "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": 231, "end_line": 232, "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": 147, "parameters": [ "self" ], "start_line": 234, "end_line": 258, "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": 9, "complexity": 5, "token_count": 116, "parameters": [ "self", "section", "key" ], "start_line": 260, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 270, "end_line": 271, "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": 273, "end_line": 274, "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": 276, "end_line": 277, "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": 279, "end_line": 284, "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": 286, "end_line": 295, "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": 63, "parameters": [ "self", "lib_dir", "libs", "ext" ], "start_line": 297, "end_line": 305, "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": 307, "end_line": 309, "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": 311, "end_line": 320, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "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": 329, "end_line": 330, "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": 148, "parameters": [ "self" ], "start_line": 332, "end_line": 357, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "calc_info", "long_name": "calc_info( self )", "filename": "system_info.py", "nloc": 17, "complexity": 6, "token_count": 104, "parameters": [ "self" ], "start_line": 398, "end_line": 414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "get_paths", "long_name": "get_paths( self , section , key )", "filename": "system_info.py", "nloc": 7, "complexity": 4, "token_count": 70, "parameters": [ "self", "section", "key" ], "start_line": 421, "end_line": 427, "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": 348, "parameters": [ "self" ], "start_line": 429, "end_line": 493, "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": 499, "end_line": 510, "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": 516, "end_line": 521, "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": 523, "end_line": 607, "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": 614, "end_line": 625, "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": 64, "parameters": [ "self", "section", "key" ], "start_line": 631, "end_line": 636, "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": 638, "end_line": 673, "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": 678, "end_line": 681, "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": 114, "parameters": [ "self" ], "start_line": 683, "end_line": 702, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 704, "end_line": 725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "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": 727, "end_line": 735, "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": 8, "complexity": 3, "token_count": 59, "parameters": [], "start_line": 737, "end_line": 744, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [ { "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 }, { "name": "combine_paths", "long_name": "combine_paths( * args )", "filename": "system_info.py", "nloc": 19, "complexity": 9, "token_count": 162, "parameters": [ "args" ], "start_line": 704, "end_line": 725, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "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": "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": "__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": "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": 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": "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": "_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 } ], "nloc": 681, "complexity": 136, "token_count": 3490, "diff_parsed": { "added": [ " system_info.verbosity - output the results to stdout if enabled.", " verbosity = 1", " verbosity = 1,", " if self.verbosity>0:", " if self.verbosity>0:", " if self.verbosity>0 and flag:", " if self.verbosity>1:", " print '(',key,'=',':'.join(ret),')'", " p = self.combine_paths(lib_dir, 'lib'+l+ext)", " def combine_paths(self,*args):", " return combine_paths(*args,**{'verbosity':self.verbosity})", "", " if len(self.combine_paths(d,self.includes))==2:", " def get_paths(self, section, key):", " pre_dirs = system_info.get_paths(self, section, key)", " dirs = []", " for d in pre_dirs:", " dirs.extend(self.combine_paths(d,['djbfft'])+[d])", " return [ d for d in dirs if os.path.isdir(d) ]", "", " p = self.combine_paths (d,['djbfft.a'])", " p = self.combine_paths (d,['libdjbfft.a'])", " if p:", " info = {'libraries':['djbfft'],'library_dirs':[d]}", " break", " if len(self.combine_paths(d,['fftc8.h','fftfreq.h']))==2:", " dirs.extend(self.combine_paths(d,['atlas*','ATLAS*',", " lib_dirs2 = self.combine_paths(d,['atlas*','ATLAS*'])+[d]", " h = (self.combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]", " dirs.extend([d] + self.combine_paths(d,['LAPACK*/SRC','SRC']))", " dirs.extend([d] + self.combine_paths(d,['blas']))", " if self.combine_paths(d, 'X11/X.h'):", "def combine_paths(*args,**kws):", " verbosity = kws.get('verbosity',1)", " if verbosity>1 and result:", " print '(','paths:',','.join(result),')'", " c.verbosity = 2" ], "deleted": [ " system_info.verbose - output the results to stdout if enabled.", " verbose = 1", " if self.verbose:", " if self.verbose:", " if self.verbose and flag:", " p = combine_paths(lib_dir, 'lib'+l+ext)", " if len(combine_paths(d,self.includes))==2:", " p = combine_paths (d,['djbfft.a'])", " if len(combine_paths(d,['fftc8.h','fftfreq.h']))==2:", " dirs.extend(combine_paths(d,['atlas*','ATLAS*',", " lib_dirs2 = combine_paths(d,['atlas*','ATLAS*'])+[d]", " h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]", " dirs.extend([d] + combine_paths(d,['LAPACK*/SRC','SRC']))", " dirs.extend([d] + combine_paths(d,['blas']))", " if combine_paths(d, 'X11/X.h'):", "def combine_paths(*args):" ] } } ] }, { "hash": "24b22dbdaa220b90961fedfb86f98044a720bad4", "msg": "Fixed the case when path to lib.exe contains spaces (thanks to Berthold Hollmann)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-28T15:42:11+00:00", "author_timezone": 0, "committer_date": "2003-10-28T15:42:11+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "11cffa55fceeda7a779a5a596b22fb98270f22b8" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 2, "insertions": 2, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1287,7 +1287,7 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n \n if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n- self.lib_ar = MSVCCompiler().lib + ' /OUT:'\n+ self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n \n def get_opt(self):\n import cpuinfo\n@@ -1532,7 +1532,7 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n \n if self.is_available():\n from distutils.msvccompiler import MSVCCompiler\n- self.lib_ar = MSVCCompiler().lib + ' /OUT:'\n+ self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n \n switches = ' /nologo /nodebug /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n", "added_lines": 2, "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 cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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 /nodebug /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 cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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 = MSVCCompiler().lib + ' /OUT:'\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 = MSVCCompiler().lib + ' /OUT:'\n\n switches = ' /nologo /nodebug /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": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1060, "end_line": 1122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1124, "end_line": 1140, "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": 1142, "end_line": 1148, "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": 1150, "end_line": 1158, "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": 1160, "end_line": 1161, "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": 1163, "end_line": 1164, "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": 1175, "end_line": 1204, "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": 1206, "end_line": 1220, "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": 1222, "end_line": 1223, "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": 1225, "end_line": 1234, "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": 1243, "end_line": 1246, "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": 1262, "end_line": 1290, "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": 1292, "end_line": 1306, "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": 1309, "end_line": 1318, "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": 1328, "end_line": 1331, "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": 1338, "end_line": 1359, "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": 1361, "end_line": 1363, "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": 1365, "end_line": 1366, "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": 1380, "end_line": 1408, "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": 1414, "end_line": 1415, "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": 1428, "end_line": 1459, "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": 1461, "end_line": 1462, "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": 1470, "end_line": 1494, "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": 1496, "end_line": 1499, "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": 1501, "end_line": 1505, "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": 1521, "end_line": 1549, "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": 1551, "end_line": 1553, "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": 1563, "end_line": 1588, "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": 1590, "end_line": 1592, "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": 1594, "end_line": 1595, "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": 1603, "end_line": 1628, "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": 1630, "end_line": 1631, "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": 1633, "end_line": 1636, "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": 1638, "end_line": 1644, "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": 1649, "end_line": 1657, "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": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1060, "end_line": 1122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1124, "end_line": 1140, "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": 1142, "end_line": 1148, "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": 1150, "end_line": 1158, "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": 1160, "end_line": 1161, "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": 1163, "end_line": 1164, "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": 1175, "end_line": 1204, "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": 1206, "end_line": 1220, "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": 1222, "end_line": 1223, "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": 1225, "end_line": 1234, "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": 1243, "end_line": 1246, "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": 144, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1262, "end_line": 1290, "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": 1292, "end_line": 1306, "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": 1309, "end_line": 1318, "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": 1328, "end_line": 1331, "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": 1338, "end_line": 1359, "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": 1361, "end_line": 1363, "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": 1365, "end_line": 1366, "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": 1380, "end_line": 1408, "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": 1414, "end_line": 1415, "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": 1428, "end_line": 1459, "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": 1461, "end_line": 1462, "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": 1470, "end_line": 1494, "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": 1496, "end_line": 1499, "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": 1501, "end_line": 1505, "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": 135, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1521, "end_line": 1549, "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": 1551, "end_line": 1553, "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": 1563, "end_line": 1588, "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": 1590, "end_line": 1592, "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": 1594, "end_line": 1595, "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": 1603, "end_line": 1628, "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": 1630, "end_line": 1631, "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": 1633, "end_line": 1636, "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": 1638, "end_line": 1644, "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": 1649, "end_line": 1657, "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": 20, "complexity": 4, "token_count": 146, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1262, "end_line": 1290, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 } ], "nloc": 1238, "complexity": 325, "token_count": 7221, "diff_parsed": { "added": [ " self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)", " self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)" ], "deleted": [ " self.lib_ar = MSVCCompiler().lib + ' /OUT:'", " self.lib_ar = MSVCCompiler().lib + ' /OUT:'" ] } } ] }, { "hash": "201ceec9b8a847e2aee5dcb137e2908331002f69", "msg": "-arch is not available gcc-3.4 option under darwin", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-29T08:17:57+00:00", "author_timezone": 0, "committer_date": "2003-10-29T08:17:57+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "24b22dbdaa220b90961fedfb86f98044a720bad4" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 4, "insertions": 5, "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_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1065,10 +1065,11 @@ def get_opt(self):\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n- if cpu.is_ppc():\n- opt = opt + ' -arch ppc '\n- elif cpu.is_i386():\n- opt = opt + ' -arch i386 '\n+ if self.version < '3.4':\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", "added_lines": 5, "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 self.version < '3.4':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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 /nodebug /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 cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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 /nodebug /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": 62, "complexity": 30, "token_count": 360, "parameters": [ "self" ], "start_line": 1060, "end_line": 1123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "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": 1125, "end_line": 1141, "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": 1143, "end_line": 1149, "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": 1151, "end_line": 1159, "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": 1161, "end_line": 1162, "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": 1164, "end_line": 1165, "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": 1176, "end_line": 1205, "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": 1207, "end_line": 1221, "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": 1223, "end_line": 1224, "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": 1226, "end_line": 1235, "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": 1244, "end_line": 1247, "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": 1263, "end_line": 1291, "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": 1293, "end_line": 1307, "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": 1310, "end_line": 1319, "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": 1329, "end_line": 1332, "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": 1339, "end_line": 1360, "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": 1362, "end_line": 1364, "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": 1366, "end_line": 1367, "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": 1381, "end_line": 1409, "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": 1415, "end_line": 1416, "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": 1429, "end_line": 1460, "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": 1462, "end_line": 1463, "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": 1471, "end_line": 1495, "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": 1497, "end_line": 1500, "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": 1502, "end_line": 1506, "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": 1522, "end_line": 1550, "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": 1552, "end_line": 1554, "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": 1564, "end_line": 1589, "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": 1591, "end_line": 1593, "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": 1595, "end_line": 1596, "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": 1604, "end_line": 1629, "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": 1631, "end_line": 1632, "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": 1634, "end_line": 1637, "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": 1639, "end_line": 1645, "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": 1650, "end_line": 1658, "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": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1060, "end_line": 1122, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 4, "token_count": 89, "parameters": [ "self" ], "start_line": 1124, "end_line": 1140, "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": 1142, "end_line": 1148, "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": 1150, "end_line": 1158, "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": 1160, "end_line": 1161, "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": 1163, "end_line": 1164, "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": 1175, "end_line": 1204, "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": 1206, "end_line": 1220, "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": 1222, "end_line": 1223, "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": 1225, "end_line": 1234, "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": 1243, "end_line": 1246, "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": 1262, "end_line": 1290, "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": 1292, "end_line": 1306, "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": 1309, "end_line": 1318, "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": 1328, "end_line": 1331, "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": 1338, "end_line": 1359, "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": 1361, "end_line": 1363, "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": 1365, "end_line": 1366, "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": 1380, "end_line": 1408, "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": 1414, "end_line": 1415, "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": 1428, "end_line": 1459, "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": 1461, "end_line": 1462, "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": 1470, "end_line": 1494, "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": 1496, "end_line": 1499, "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": 1501, "end_line": 1505, "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": 1521, "end_line": 1549, "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": 1551, "end_line": 1553, "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": 1563, "end_line": 1588, "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": 1590, "end_line": 1592, "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": 1594, "end_line": 1595, "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": 1603, "end_line": 1628, "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": 1630, "end_line": 1631, "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": 1633, "end_line": 1636, "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": 1638, "end_line": 1644, "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": 1649, "end_line": 1657, "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": 62, "complexity": 30, "token_count": 360, "parameters": [ "self" ], "start_line": 1060, "end_line": 1123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 } ], "nloc": 1239, "complexity": 326, "token_count": 7228, "diff_parsed": { "added": [ " if self.version < '3.4':", " if cpu.is_ppc():", " opt = opt + ' -arch ppc '", " elif cpu.is_i386():", " opt = opt + ' -arch i386 '" ], "deleted": [ " if cpu.is_ppc():", " opt = opt + ' -arch ppc '", " elif cpu.is_i386():", " opt = opt + ' -arch i386 '" ] } } ] }, { "hash": "99e8db0472d7b5d8b775184382212e32bf7a9e61", "msg": "It turns out that -arch is available only under Apple", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-10-29T19:57:25+00:00", "author_timezone": 0, "committer_date": "2003-10-29T19:57:25+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "201ceec9b8a847e2aee5dcb137e2908331002f69" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 1, "insertions": 2, "lines": 3, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1065,7 +1065,8 @@ def get_opt(self):\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n- if self.version < '3.4':\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", "added_lines": 2, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft [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 cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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 /nodebug /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 self.version < '3.4':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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 /nodebug /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": 62, "complexity": 30, "token_count": 360, "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 } ], "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": 360, "parameters": [ "self" ], "start_line": 1060, "end_line": 1123, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "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": 1125, "end_line": 1141, "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": 1143, "end_line": 1149, "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": 1151, "end_line": 1159, "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": 1161, "end_line": 1162, "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": 1164, "end_line": 1165, "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": 1176, "end_line": 1205, "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": 1207, "end_line": 1221, "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": 1223, "end_line": 1224, "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": 1226, "end_line": 1235, "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": 1244, "end_line": 1247, "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": 1263, "end_line": 1291, "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": 1293, "end_line": 1307, "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": 1310, "end_line": 1319, "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": 1329, "end_line": 1332, "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": 1339, "end_line": 1360, "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": 1362, "end_line": 1364, "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": 1366, "end_line": 1367, "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": 1381, "end_line": 1409, "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": 1415, "end_line": 1416, "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": 1429, "end_line": 1460, "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": 1462, "end_line": 1463, "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": 1471, "end_line": 1495, "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": 1497, "end_line": 1500, "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": 1502, "end_line": 1506, "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": 1522, "end_line": 1550, "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": 1552, "end_line": 1554, "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": 1564, "end_line": 1589, "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": 1591, "end_line": 1593, "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": 1595, "end_line": 1596, "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": 1604, "end_line": 1629, "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": 1631, "end_line": 1632, "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": 1634, "end_line": 1637, "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": 1639, "end_line": 1645, "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": 1650, "end_line": 1658, "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": 62, "complexity": 30, "token_count": 360, "parameters": [ "self" ], "start_line": 1060, "end_line": 1124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 65, "top_nesting_level": 1 } ], "nloc": 1239, "complexity": 326, "token_count": 7228, "diff_parsed": { "added": [ " if os.name != 'posix':", " # this should presumably correspond to Apple" ], "deleted": [ " if self.version < '3.4':" ] } } ] }, { "hash": "6957b1997a4bf1c1019dfb8543e350e405a6b9b4", "msg": "Added freeze method to distributions which returns a frozen class that has fixed shape, location, and scale parameters. No checking done yet, so errors on construction are not detected until first call of frozen methods.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-10-30T22:40:17+00:00", "author_timezone": 0, "committer_date": "2003-10-30T22:40:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "99e8db0472d7b5d8b775184382212e32bf7a9e61" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 4, "insertions": 4, "lines": 8, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "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": "@@ -242,9 +242,9 @@ def unwrap(p,discont=pi,axis=-1):\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n- putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n+ Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n- putmask(ph_correct,abs(dd) 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", "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\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 putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)\n ph_correct = ddmod - dd;\n 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 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 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": 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 } ], "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": 146, "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": 40, "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": 40, "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": "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": "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": "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 } ], "nloc": 287, "complexity": 81, "token_count": 2096, "diff_parsed": { "added": [ " Numeric.putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)", " Numeric.putmask(ph_correct,abs(dd) 0),pi)", " putmask(ph_correct,abs(dd)\nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\nimport traceback\n\nclass PPImportError(ImportError):\n pass\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n module = self.__dict__['_ppimport_attr_module']\n if isinstance(module, _ModuleLoader):\n # in case pp module was loaded by other means\n module = sys.modules[module.__name__]\n attr = getattr(module,\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n # module may be imported already\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n fullname = name\n location = 'sys.path'\n\n # Try once more if module is imported.\n # This covers the case when importing from python module\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n from scipy_test.testing import ScipyTest\n self.__dict__['test'] = ScipyTest(self).test\n\n # get additional attributes (doc strings, etc)\n # from pre_.py file. XXX: remove this code\n # when new style packaging is implemented.\n filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\n try:\n module = sys.modules[name]\n\texcept KeyError:\n raise ImportError,self.__dict__.get('_ppimport_exc_info')[1]\n if module is not self:\n exc_info = self.__dict__.get('_ppimport_exc_info')\n if exc_info is not None:\n raise PPImportError,\\\n ''.join(traceback.format_exception(*exc_info))\n else:\n assert module is self,`(module, self)`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n try:\n module = __import__(name,None,None,['*'])\n except: # ImportError:\n self.__dict__['_ppimport_exc_info'] = sys.exc_info()\n raise\n\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n\n # XXX: Should we check the existence of module.test? Warn?\n from scipy_test.testing import ScipyTest\n module.test = ScipyTest(module).test\n\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_info'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "source_code_before": "#!/usr/bin/env python\n\"\"\"\nPostpone module import to future.\n\nPython versions: 1.5.2 - 2.3.x\nAuthor: Pearu Peterson \nCreated: March 2003\n$Revision$\n$Date$\n\"\"\"\n__all__ = ['ppimport','ppimport_attr']\n\nimport os\nimport sys\nimport string\nimport types\nimport traceback\n\nclass PPImportError(ImportError):\n pass\n\ndef _get_so_ext(_cache={}):\n so_ext = _cache.get('so_ext')\n if so_ext is None:\n if sys.platform[:5]=='linux':\n so_ext = '.so'\n else:\n try:\n # if possible, avoid expensive get_config_vars call\n from distutils.sysconfig import get_config_vars\n so_ext = get_config_vars('SO')[0] or ''\n except ImportError:\n #XXX: implement hooks for .sl, .dll to fully support\n # Python 1.5.x \n so_ext = '.so'\n _cache['so_ext'] = so_ext\n return so_ext\n\ndef _get_frame(level=0):\n try:\n return sys._getframe(level+1)\n except AttributeError:\n # Python<=2.0 support\n frame = sys.exc_info()[2].tb_frame\n for i in range(level+1):\n frame = frame.f_back\n return frame\n\ndef ppimport_attr(module, name):\n \"\"\" ppimport(module, name) is 'postponed' getattr(module, name)\n \"\"\"\n if isinstance(module, _ModuleLoader):\n return _AttrLoader(module, name)\n return getattr(module, name)\n\nclass _AttrLoader:\n def __init__(self, module, name):\n self.__dict__['_ppimport_attr_module'] = module\n self.__dict__['_ppimport_attr_name'] = name\n\n def _ppimport_attr_getter(self):\n module = self.__dict__['_ppimport_attr_module']\n if isinstance(module, _ModuleLoader):\n # in case pp module was loaded by other means\n module = sys.modules[module.__name__]\n attr = getattr(module,\n self.__dict__['_ppimport_attr_name'])\n try:\n d = attr.__dict__\n if d is not None:\n self.__dict__ = d\n except AttributeError:\n pass\n self.__dict__['_ppimport_attr'] = attr\n return attr\n\n def __getattr__(self, name):\n try:\n attr = self.__dict__['_ppimport_attr']\n except KeyError:\n attr = self._ppimport_attr_getter()\n if name=='_ppimport_attr':\n return attr\n return getattr(attr, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_attr'):\n return repr(self._ppimport_attr)\n module = self.__dict__['_ppimport_attr_module']\n name = self.__dict__['_ppimport_attr_name']\n return \"\" % (`name`,`module`)\n\n __str__ = __repr__\n\n # For function and class attributes.\n def __call__(self, *args, **kwds):\n return self._ppimport_attr(*args,**kwds)\n\n\n\ndef _is_local_module(p_dir,name,suffices):\n base = os.path.join(p_dir,name)\n for suffix in suffices:\n if os.path.isfile(base+suffix):\n if p_dir:\n return base+suffix\n return name+suffix\n\ndef ppimport(name):\n \"\"\" ppimport(name) -> module or module wrapper\n\n If name has been imported before, return module. Otherwise\n return ModuleLoader instance that transparently postpones\n module import until the first attempt to access module name\n attributes.\n \"\"\"\n p_frame = _get_frame(1)\n p_name = p_frame.f_locals['__name__']\n if p_name=='__main__':\n p_dir = ''\n fullname = name\n elif p_frame.f_locals.has_key('__path__'):\n # python package\n p_path = p_frame.f_locals['__path__']\n p_dir = p_path[0]\n fullname = p_name + '.' + name\n else:\n # python module\n p_file = p_frame.f_locals['__file__']\n p_dir = os.path.dirname(p_file)\n fullname = p_name + '.' + name\n\n # module may be imported already\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n\n so_ext = _get_so_ext()\n py_exts = ('.py','.pyc','.pyo')\n so_exts = (so_ext,'module'+so_ext)\n \n for d,n,fn,e in [\\\n # name is local python module or local extension module\n (p_dir, name, fullname, py_exts+so_exts),\n # name is local package\n (os.path.join(p_dir, name), '__init__', fullname, py_exts),\n # name is package in parent directory (scipy specific)\n (os.path.join(os.path.dirname(p_dir), name), '__init__', name, py_exts),\n ]:\n location = _is_local_module(d, n, e)\n if location is not None:\n fullname = fn\n break\n\n if location is None:\n # name is to be looked in python sys.path.\n fullname = name\n location = 'sys.path'\n # Try once more if module is imported.\n # This covers the case when in python module\n module = sys.modules.get(fullname)\n if module is not None:\n return module\n # It is OK if name does not exists. The ImportError is\n # postponed until trying to use the module.\n\n return _ModuleLoader(fullname,location)\n\nclass _ModuleLoader:\n # Don't use it directly. Use ppimport instead.\n\n def __init__(self,name,location):\n\n # set attributes, avoid calling __setattr__\n self.__dict__['__name__'] = name\n self.__dict__['__file__'] = location\n\n if location != 'sys.path':\n from scipy_test.testing import ScipyTest\n self.__dict__['test'] = ScipyTest(self).test\n\n # get additional attributes (doc strings, etc)\n # from pre_.py file. XXX: remove this code\n # when new style packaging is implemented.\n filename = os.path.splitext(location)[0] + '.py'\n filename = location\n dirname,basename = os.path.split(filename)\n preinit = os.path.join(dirname,'pre_'+basename)\n if os.path.isfile(preinit):\n execfile(preinit, self.__dict__)\n\n # install loader\n sys.modules[name] = self\n\n def _ppimport_importer(self):\n name = self.__name__\n\n try:\n module = sys.modules[name]\n\texcept KeyError:\n raise ImportError,self.__dict__.get('_ppimport_exc_info')[1]\n if module is not self:\n exc_info = self.__dict__.get('_ppimport_exc_info')\n if exc_info is not None:\n raise PPImportError,\\\n ''.join(traceback.format_exception(*exc_info))\n else:\n assert module is self,`(module, self)`\n\n # uninstall loader\n del sys.modules[name]\n\n #print 'Executing postponed import for %s' %(name)\n try:\n module = __import__(name,None,None,['*'])\n except: # ImportError:\n self.__dict__['_ppimport_exc_info'] = sys.exc_info()\n raise\n\n assert isinstance(module,types.ModuleType),`module`\n\n self.__dict__ = module.__dict__\n self.__dict__['_ppimport_module'] = module\n\n # XXX: Should we check the existence of module.test? Warn?\n from scipy_test.testing import ScipyTest\n module.test = ScipyTest(module).test\n\n return module\n\n def __setattr__(self, name, value):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return setattr(module, name, value)\n\n def __getattr__(self, name):\n try:\n module = self.__dict__['_ppimport_module']\n except KeyError:\n module = self._ppimport_importer()\n return getattr(module, name)\n\n def __repr__(self):\n if self.__dict__.has_key('_ppimport_module'):\n status = 'imported'\n elif self.__dict__.has_key('_ppimport_exc_info'):\n status = 'import error'\n else:\n status = 'import postponed'\n return '' \\\n % (`self.__name__`,`self.__file__`, status)\n\n __str__ = __repr__\n\ntry:\n import pydoc as _pydoc\nexcept ImportError:\n _pydoc = None\nif _pydoc is not None:\n # Define new built-in 'help'.\n # This is a wrapper around pydoc.help (with a twist\n # (as in debian site.py) and ppimport support).\n class _Helper:\n def __repr__ (self):\n return \"Type help () for interactive help, \" \\\n \"or help (object) for help about object.\"\n def __call__ (self, *args, **kwds):\n new_args = []\n for a in args:\n if hasattr(a,'_ppimport_importer') or \\\n\t\t hasattr(a,'_ppimport_module'):\n a = a._ppimport_module\n if hasattr(a,'_ppimport_attr'):\n\t\t a = a._ppimport_attr\n new_args.append(a)\n return _pydoc.help(*new_args, **kwds)\n import __builtin__\n __builtin__.help = _Helper()\n\n import inspect as _inspect\n _old_inspect_getfile = _inspect.getfile\n def _inspect_getfile(object):\n\ttry:\n\t if hasattr(object,'_ppimport_importer') or \\\n\t hasattr(object,'_ppimport_module'):\n object = object._ppimport_module\n if hasattr(object,'_ppimport_attr'):\n\t\tobject = object._ppimport_attr\n\texcept ImportError:\n\t object = object.__class__\n\treturn _old_inspect_getfile(object)\n _inspect.getfile = _inspect_getfile\n", "methods": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 22, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 39, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 14, "complexity": 4, "token_count": 76, "parameters": [ "self" ], "start_line": 61, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 77, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 101, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 37, "complexity": 8, "token_count": 256, "parameters": [ "name" ], "start_line": 109, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 13, "complexity": 3, "token_count": 119, "parameters": [ "self", "name", "location" ], "start_line": 173, "end_line": 194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 25, "complexity": 5, "token_count": 173, "parameters": [ "self" ], "start_line": 196, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 232, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 239, "end_line": 244, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 246, "end_line": 254, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 267, "end_line": 269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 270, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 285, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "methods_before": [ { "name": "_get_so_ext", "long_name": "_get_so_ext( _cache = { } )", "filename": "ppimport.py", "nloc": 13, "complexity": 5, "token_count": 70, "parameters": [ "_cache" ], "start_line": 22, "end_line": 37, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 0 }, { "name": "_get_frame", "long_name": "_get_frame( level = 0 )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 50, "parameters": [ "level" ], "start_line": 39, "end_line": 47, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "ppimport_attr", "long_name": "ppimport_attr( module , name )", "filename": "ppimport.py", "nloc": 4, "complexity": 2, "token_count": 30, "parameters": [ "module", "name" ], "start_line": 49, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , module , name )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 25, "parameters": [ "self", "module", "name" ], "start_line": 57, "end_line": 59, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "_ppimport_attr_getter", "long_name": "_ppimport_attr_getter( self )", "filename": "ppimport.py", "nloc": 14, "complexity": 4, "token_count": 76, "parameters": [ "self" ], "start_line": 61, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 8, "complexity": 3, "token_count": 41, "parameters": [ "self", "name" ], "start_line": 77, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 50, "parameters": [ "self" ], "start_line": 86, "end_line": 91, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 2, "complexity": 1, "token_count": 22, "parameters": [ "self", "args", "kwds" ], "start_line": 96, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "_is_local_module", "long_name": "_is_local_module( p_dir , name , suffices )", "filename": "ppimport.py", "nloc": 7, "complexity": 4, "token_count": 49, "parameters": [ "p_dir", "name", "suffices" ], "start_line": 101, "end_line": 107, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 37, "complexity": 8, "token_count": 256, "parameters": [ "name" ], "start_line": 109, "end_line": 167, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 59, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , name , location )", "filename": "ppimport.py", "nloc": 13, "complexity": 3, "token_count": 119, "parameters": [ "self", "name", "location" ], "start_line": 172, "end_line": 193, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "_ppimport_importer", "long_name": "_ppimport_importer( self )", "filename": "ppimport.py", "nloc": 25, "complexity": 5, "token_count": 173, "parameters": [ "self" ], "start_line": 195, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , name , value )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 38, "parameters": [ "self", "name", "value" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , name )", "filename": "ppimport.py", "nloc": 6, "complexity": 2, "token_count": 34, "parameters": [ "self", "name" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 9, "complexity": 3, "token_count": 55, "parameters": [ "self" ], "start_line": 245, "end_line": 253, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "ppimport.py", "nloc": 3, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 266, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 2 }, { "name": "__call__", "long_name": "__call__( self , * args , ** kwds )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 71, "parameters": [ "self", "args", "kwds" ], "start_line": 269, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 2 }, { "name": "_inspect_getfile", "long_name": "_inspect_getfile( object )", "filename": "ppimport.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "object" ], "start_line": 284, "end_line": 293, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "ppimport", "long_name": "ppimport( name )", "filename": "ppimport.py", "nloc": 37, "complexity": 8, "token_count": 256, "parameters": [ "name" ], "start_line": 109, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 0 } ], "nloc": 216, "complexity": 59, "token_count": 1321, "diff_parsed": { "added": [ "", " # Try once more if module is imported.", " # This covers the case when importing from python module", " module = sys.modules.get(fullname)", " if module is not None:", " return module", " # It is OK if name does not exists. The ImportError is", " # postponed until trying to use the module." ], "deleted": [ " # Try once more if module is imported.", " # This covers the case when in python module", " module = sys.modules.get(fullname)", " if module is not None:", " return module", " # It is OK if name does not exists. The ImportError is", " # postponed until trying to use the module." ] } }, { "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": "@@ -1536,7 +1536,7 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n from distutils.msvccompiler import MSVCCompiler\n self.lib_ar = '\"%s\" /OUT:' % (MSVCCompiler().lib)\n \n- switches = ' /nologo /nodebug /MD /WX '\\\n+ switches = ' /nologo /MD /WX '\\\n ' /iface=(cref,nomixed_str_len_arg) /names:lowercase '\\\n ' /assume:underscore /threads '\n #switches += ' /libs:dll /threads '\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft [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 cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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", "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 cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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 /nodebug /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": 62, "complexity": 30, "token_count": 360, "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 } ], "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": 360, "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": "__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 } ], "nloc": 1239, "complexity": 326, "token_count": 7228, "diff_parsed": { "added": [ " switches = ' /nologo /MD /WX '\\" ], "deleted": [ " switches = ' /nologo /nodebug /MD /WX '\\" ] } } ] }, { "hash": "117a6697980cd9cc355de6b9783fe9668bd3c816", "msg": "Fixed missing function in function_base.py. Added entropy calculations to probability distributions. Fixed error in F distribution ppf function.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-11-19T11:52:04+00:00", "author_timezone": 0, "committer_date": "2003-11-19T11:52:04+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "197ff2202f843135f860001433dd3eb1c4ddc5f4" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/function_base.py", "new_path": "scipy_base/function_base.py", "filename": "function_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -3,7 +3,7 @@\n import Numeric\n from Numeric import ravel, asarray, nonzero, array, choose, ones, zeros, sometrue, alltrue\n from type_check import ScalarType\n-from shape_base import squeeze\n+from shape_base import squeeze, atleast_1d\n from fastumath import PINF as inf\n from fastumath import *\n import _compiled_base\n", "added_lines": 1, "deleted_lines": 1, "source_code": "\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", "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\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": 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 } ], "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": [], "nloc": 287, "complexity": 81, "token_count": 2098, "diff_parsed": { "added": [ "from shape_base import squeeze, atleast_1d" ], "deleted": [ "from shape_base import squeeze" ] } } ] }, { "hash": "e420835ca4558c414b6667cd609eb77452184cef", "msg": "Using sse only when available and not sse2", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-20T09:38:47+00:00", "author_timezone": 0, "committer_date": "2003-11-20T09:38:47+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "117a6697980cd9cc355de6b9783fe9668bd3c816" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 4, "insertions": 4, "lines": 8, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "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": "@@ -1102,10 +1102,10 @@ 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 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_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", "added_lines": 4, "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_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", "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 cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.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": 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 } ], "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": 360, "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_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 } ], "nloc": 1239, "complexity": 326, "token_count": 7227, "diff_parsed": { "added": [ " if cpu.has_mmx(): opt = opt + ' -mmmx '", " if self.version > '3.2.2' and cpu.has_sse2():", " opt = opt + ' -msse2 '", " elif cpu.has_sse(): opt = opt + ' -msse '" ], "deleted": [ " if cpu.has_mmx(): opt = opt + ' -mmmx '", " if cpu.has_sse(): opt = opt + ' -msse '", " if self.version > '3.2.2':", " if cpu.has_sse2(): opt = opt + ' -msse2 '" ] } } ] }, { "hash": "1aae76e5b0de886b9c7950441e2acdf103fff4ef", "msg": "DOS lineendings", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-11-24T09:49:35+00:00", "author_timezone": 0, "committer_date": "2003-11-24T09:49:35+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "e420835ca4558c414b6667cd609eb77452184cef" ], "project_name": "repo_copy", "project_path": "/tmp/tmp4k9wvcbz/repo_copy", "deletions": 0, "insertions": 0, "lines": 0, "files": 0, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null } ]