[ { "hash": "34777aa80d19f311ca78c34f83a77697ec528c0f", "msg": "Introduced MANIFEST.in that includes *.inc files to sdist", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-08-07T09:56:15+00:00", "author_timezone": 0, "committer_date": "2003-08-07T09:56:15+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "9ec9ed3fd61e10244e65d6c333686b29d0614061" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 0, "insertions": 1, "lines": 1, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": null, "new_path": "MANIFEST.in", "filename": "MANIFEST.in", "extension": "in", "change_type": "ADD", "diff": "@@ -0,0 +1 @@\n+include scipy_base/*.inc\n", "added_lines": 1, "deleted_lines": 0, "source_code": "include scipy_base/*.inc\n", "source_code_before": null, "methods": [], "methods_before": [], "changed_methods": [], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [ "include scipy_base/*.inc" ], "deleted": [] } } ] }, { "hash": "9da41c6d3fd97a256cbc24f833e9dde277a4cd86", "msg": "Applied John A. Turner patch for OSF1", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-08-08T20:10:56+00:00", "author_timezone": 0, "committer_date": "2003-08-08T20:10:56+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "34777aa80d19f311ca78c34f83a77697ec528c0f" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 1, "insertions": 3, "lines": 4, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -560,7 +560,9 @@ def build_library(self,library_name,source_list,module_dirs=None,\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n \n- if os.name == 'nt' or sys.platform[:4] == 'irix':\n+ 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", "added_lines": 3, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' \\\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 self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' or sys.platform[:4] == 'irix':\n # I (pearu) had the same problem on irix646 ...\n # I think we can make this \"bunk\" default as skip_ranlib\n # feature speeds things up.\n # XXX:Need to check if Digital compiler works here.\n\n # This is pure bunk...\n # Windows fails for long argument strings on the command line.\n # if objects is real long (> 2048 chars or so on my machine),\n # the command fails (cmd.exe /e:2048 on w2k).\n # for now we'll split linking into to steps which should work for\n objects = object_list[:]\n while objects:\n #obj,objects = objects[:20],objects[20:]\n i = 0\n obj = []\n while i<1900 and objects:\n i = i + len(objects[0]) + 1\n obj.append(objects[0])\n objects = objects[1:]\n self.create_static_lib(obj,library_name,build_dir,\n skip_ranlib = len(objects))\n else:\n self.create_static_lib(object_list,library_name,build_dir)\n\n def dummy_fortran_files(self):\n global remove_files\n import tempfile\n dummy_name = tempfile.mktemp()+'__dummy'\n dummy = open(dummy_name+'.f','w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n remove_files.extend([dummy_name+'.f',dummy_name+'.o'])\n return (dummy_name+'.f',dummy_name+'.o')\n \n def is_available(self):\n return self.get_version()\n \n def get_version(self):\n \"\"\"Return the compiler version. If compiler is not available,\n return empty string.\"\"\"\n # XXX: Are there compilers that have no version? If yes,\n # this test will fail even if the compiler is available.\n if self.version is not None:\n # Finding version is expensive, so return previously found\n # version string.\n return self.version\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 138, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 159, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 209, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 268, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 281, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 294, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 353, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 391, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 418, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 449, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 456, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 461, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 493, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 505, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 519, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 522, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 543, "end_line": 588, "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": 590, "end_line": 598, "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": 600, "end_line": 601, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 603, "end_line": 628, "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": 630, "end_line": 631, "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": 632, "end_line": 633, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 643, "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": 645, "end_line": 660, "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": 668, "end_line": 669, "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": 671, "end_line": 676, "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": 684, "end_line": 747, "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": 749, "end_line": 764, "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": 766, "end_line": 767, "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": 800, "end_line": 841, "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": 843, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 850, "end_line": 868, "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": 873, "end_line": 874, "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": 886, "end_line": 906, "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": 908, "end_line": 928, "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": 930, "end_line": 932, "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": 934, "end_line": 935, "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": 937, "end_line": 947, "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": 954, "end_line": 975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 977, "end_line": 995, "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": 1003, "end_line": 1049, "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": 1051, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1115, "end_line": 1132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1134, "end_line": 1140, "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": 1142, "end_line": 1150, "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": 1152, "end_line": 1153, "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": 1155, "end_line": 1156, "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": 1167, "end_line": 1196, "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": 1198, "end_line": 1212, "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": 1214, "end_line": 1215, "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": 1217, "end_line": 1226, "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": 1235, "end_line": 1238, "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": 1246, "end_line": 1267, "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": 1269, "end_line": 1271, "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": 1273, "end_line": 1274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1288, "end_line": 1316, "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": 1322, "end_line": 1323, "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": 1336, "end_line": 1367, "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": 1369, "end_line": 1370, "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": 1378, "end_line": 1402, "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": 1404, "end_line": 1407, "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": 1409, "end_line": 1413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1429, "end_line": 1456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1458, "end_line": 1460, "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": 1470, "end_line": 1495, "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": 1497, "end_line": 1499, "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": 1501, "end_line": 1502, "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": 1510, "end_line": 1535, "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": 1537, "end_line": 1538, "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": 1540, "end_line": 1543, "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": 1545, "end_line": 1551, "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": 1556, "end_line": 1564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 138, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 159, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 209, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 268, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 281, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 294, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 353, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 391, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 418, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 449, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 456, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 461, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 493, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 505, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 519, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 522, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 168, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 543, "end_line": 586, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 1 }, { "name": "dummy_fortran_files", "long_name": "dummy_fortran_files( self )", "filename": "build_flib.py", "nloc": 9, "complexity": 1, "token_count": 63, "parameters": [ "self" ], "start_line": 588, "end_line": 596, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "is_available", "long_name": "is_available( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 598, "end_line": 599, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 601, "end_line": 626, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_libraries", "long_name": "get_libraries( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 628, "end_line": 629, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 630, "end_line": 631, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 632, "end_line": 633, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 634, "end_line": 635, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 1, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 636, "end_line": 641, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 6, "token_count": 164, "parameters": [ "self" ], "start_line": 643, "end_line": 658, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 666, "end_line": 667, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 4, "token_count": 46, "parameters": [ "self", "temp_dir" ], "start_line": 669, "end_line": 674, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 49, "complexity": 9, "token_count": 283, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 682, "end_line": 745, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 747, "end_line": 762, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 16, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self" ], "start_line": 764, "end_line": 765, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 20, "complexity": 4, "token_count": 136, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 798, "end_line": 839, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 31, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 841, "end_line": 846, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 848, "end_line": 866, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 15, "parameters": [ "self" ], "start_line": 871, "end_line": 872, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 14, "complexity": 3, "token_count": 96, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 884, "end_line": 904, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self , mode = 'f90' )", "filename": "build_flib.py", "nloc": 21, "complexity": 11, "token_count": 143, "parameters": [ "self", "mode" ], "start_line": 906, "end_line": 926, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 14, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 928, "end_line": 930, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 932, "end_line": 933, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 935, "end_line": 945, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 100, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 952, "end_line": 973, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 975, "end_line": 993, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 39, "complexity": 16, "token_count": 250, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1001, "end_line": 1047, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 47, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 61, "complexity": 29, "token_count": 353, "parameters": [ "self" ], "start_line": 1049, "end_line": 1111, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1113, "end_line": 1130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1132, "end_line": 1138, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "get_extra_link_args", "long_name": "get_extra_link_args( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 3, "token_count": 39, "parameters": [ "self" ], "start_line": 1140, "end_line": 1148, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1150, "end_line": 1151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 17, "parameters": [ "self", "source_files", "module_files", "temp_dir" ], "start_line": 1153, "end_line": 1154, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 23, "complexity": 5, "token_count": 153, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1165, "end_line": 1194, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 85, "parameters": [ "self" ], "start_line": 1196, "end_line": 1210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1212, "end_line": 1213, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 10, "complexity": 5, "token_count": 54, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1215, "end_line": 1224, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 39, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1233, "end_line": 1236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 113, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1244, "end_line": 1265, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1267, "end_line": 1269, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1271, "end_line": 1272, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1286, "end_line": 1314, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self" ], "start_line": 1320, "end_line": 1321, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 5, "token_count": 162, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1334, "end_line": 1365, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1367, "end_line": 1368, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 123, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1376, "end_line": 1400, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 12, "parameters": [ "self" ], "start_line": 1402, "end_line": 1405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 36, "parameters": [ "self" ], "start_line": 1407, "end_line": 1411, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1427, "end_line": 1454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1456, "end_line": 1458, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 21, "complexity": 4, "token_count": 156, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1468, "end_line": 1493, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 1, "token_count": 10, "parameters": [ "self" ], "start_line": 1495, "end_line": 1497, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self" ], "start_line": 1499, "end_line": 1500, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 127, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1508, "end_line": 1533, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1535, "end_line": 1536, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 14, "parameters": [ "self" ], "start_line": 1538, "end_line": 1541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 7, "complexity": 3, "token_count": 36, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 1543, "end_line": 1549, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "find_fortran_compiler", "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 8, "complexity": 5, "token_count": 60, "parameters": [ "vendor", "fc", "f90c", "verbose" ], "start_line": 1554, "end_line": 1562, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "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": 543, "end_line": 588, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 46, "top_nesting_level": 1 } ], "nloc": 1166, "complexity": 305, "token_count": 6847, "diff_parsed": { "added": [ " if os.name == 'nt' \\", " or sys.platform[:4] == 'irix' \\", " or sys.platform[:3] == 'osf':" ], "deleted": [ " if os.name == 'nt' or sys.platform[:4] == 'irix':" ] } } ] }, { "hash": "9d8887db59bf96caf81d9187d4ff5a1af91e9f59", "msg": "Replaced execfile statements with simplified import statements in order to avoid problems with Windows installer tools.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-08-20T20:46:54+00:00", "author_timezone": 0, "committer_date": "2003-08-20T20:46:54+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "9da41c6d3fd97a256cbc24f833e9dde277a4cd86" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 3, "insertions": 1, "lines": 4, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/__init__.py", "new_path": "weave/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,9 +2,7 @@\n # weave - C/C++ integration\n #\n \n-import os as _os\n-execfile(_os.path.join(__path__[0],'pre___init__.py'),globals(),locals())\n-\n+from pre___init__ import __doc__\n from weave_version import weave_version as __version__\n \n try:\n", "added_lines": 1, "deleted_lines": 3, "source_code": "#\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", "source_code_before": "#\n# weave - C/C++ integration\n#\n\nimport os as _os\nexecfile(_os.path.join(__path__[0],'pre___init__.py'),globals(),locals())\n\nfrom weave_version import weave_version as __version__\n\ntry:\n from blitz_tools import blitz\nexcept ImportError:\n pass # Numeric wasn't available \n \nfrom inline_tools import inline\nimport ext_tools\nfrom ext_tools import ext_module, ext_function\ntry:\n from accelerate_tools import accelerate\nexcept:\n pass\n\n#---- testing ----#\n\ndef test(level=10):\n import unittest\n runner = unittest.TextTestRunner()\n runner.run(test_suite(level))\n return runner\n\ndef test_suite(level=1):\n import scipy_test.testing\n import weave\n return scipy_test.testing.harvest_test_suites(weave,level=level)\n", "methods": [ { "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 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 27, "parameters": [ "level" ], "start_line": 25, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "__init__.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 31, "end_line": 34, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 22, "complexity": 2, "token_count": 96, "diff_parsed": { "added": [ "from pre___init__ import __doc__" ], "deleted": [ "import os as _os", "execfile(_os.path.join(__path__[0],'pre___init__.py'),globals(),locals())", "" ] } } ] }, { "hash": "925821853de544eaa09869a6043129f50ee3dab6", "msg": "- add python2.3 support\n - set self.compiler_cxx to g++ in __init__. This should really be done through the set_exectuables method,\n but it would break pre 2.3 support because compiler_cxx is not an accepted option.\n - added target_lang argument to link() method.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-08-23T06:57:53+00:00", "author_timezone": 0, "committer_date": "2003-08-23T06:57:53+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "9d8887db59bf96caf81d9187d4ff5a1af91e9f59" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 15, "insertions": 28, "lines": 43, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.7142857142857143, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/mingw32_support.py", "new_path": "scipy_distutils/mingw32_support.py", "filename": "mingw32_support.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -91,6 +91,10 @@ def __init__ (self,\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@@ -108,11 +112,11 @@ def link(self,\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+ export_symbols = None,\n+ debug=0,\n+ extra_preargs=None,\n+ extra_postargs=None,\n+ build_temp=None):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n@@ -122,11 +126,12 @@ def link(self,\n libraries,\n library_dirs,\n runtime_library_dirs,\n- None, # export_symbols, we do this in our def-file\n+ None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n- build_temp)\n+ build_temp,\n+ target_lang)\n else:\n UnixCCompiler.link(self,\n target_desc,\n@@ -140,7 +145,8 @@ def link(self,\n debug,\n extra_preargs,\n extra_postargs,\n- build_temp)\n+ build_temp,\n+ target_lang)\n \n \n # On windows platforms, we want to default to mingw32 (gcc)\n", "added_lines": 14, "deleted_lines": 8, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None):\n 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 if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 160, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 170, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 206, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 221, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 224, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 228, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 231, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 99, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "mingw32_support.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 103, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 154, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 164, "end_line": 190, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 200, "end_line": 214, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 215, "end_line": 216, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 218, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 222, "end_line": 223, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 225, "end_line": 226, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "mingw32_support.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 103, "end_line": 143, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "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 )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 } ], "nloc": 150, "complexity": 20, "token_count": 762, "diff_parsed": { "added": [ " # added for python2.3 support", " # we can't pass it through set_executables because pre 2.2 would fail", " self.compiler_cxx = 'g++'", "", " export_symbols = None,", " debug=0,", " extra_preargs=None,", " extra_postargs=None,", " build_temp=None):", " None, #export_symbols, we do this in our def-file", " build_temp,", " target_lang)", " build_temp,", " target_lang)" ], "deleted": [ " None, # export_symbols, we do this in our def-file", " debug,", " extra_preargs,", " extra_postargs,", " build_temp):", " None, # export_symbols, we do this in our def-file", " build_temp)", " build_temp)" ] } }, { "old_path": "weave/build_tools.py", "new_path": "weave/build_tools.py", "filename": "build_tools.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -501,6 +501,10 @@ def __init__ (self,\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@@ -518,11 +522,12 @@ def link(self,\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+ 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@@ -536,7 +541,8 @@ def link(self,\n debug,\n extra_preargs,\n extra_postargs,\n- build_temp)\n+ build_temp,\n+ target_lang)\n else:\n UnixCCompiler.link(self,\n target_desc,\n@@ -550,7 +556,8 @@ def link(self,\n debug,\n extra_preargs,\n extra_postargs,\n- build_temp)\n+ build_temp,\n+ target_lang)\n \n \n # On windows platforms, we want to default to mingw32 (gcc)\n", "added_lines": 14, "deleted_lines": 7, "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 \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "source_code_before": "\"\"\" Tools for compiling C/C++ code to extension modules\n\n The main function, build_extension(), takes the C/C++ file\n along with some other options and builds a Python extension.\n It uses distutils for most of the heavy lifting.\n \n choose_compiler() is also useful (mainly on windows anyway)\n for trying to determine whether MSVC++ or gcc is available.\n MSVC doesn't handle templates as well, so some of the code emitted\n by the python->C conversions need this info to choose what kind\n of code to create.\n \n The other main thing here is an alternative version of the MingW32\n compiler class. The class makes it possible to build libraries with\n gcc even if the original version of python was built using MSVC. It\n does this by converting a pythonxx.lib file to a libpythonxx.a file.\n Note that you need write access to the pythonxx/lib directory to do this.\n\"\"\"\n\nimport sys,os,string,time\nimport tempfile\nimport exceptions\nimport commands\n\nimport platform_info\n\n# If linker is 'gcc', this will convert it to 'g++'\n# necessary to make sure stdc++ is linked in cross-platform way.\nimport distutils.sysconfig\nimport distutils.dir_util\nold_init_posix = distutils.sysconfig._init_posix\n\ndef _init_posix():\n old_init_posix()\n ld = distutils.sysconfig._config_vars['LDSHARED']\n #distutils.sysconfig._config_vars['LDSHARED'] = ld.replace('gcc','g++')\n # FreeBSD names gcc as cc, so the above find and replace doesn't work. \n # So, assume first entry in ld is the name of the linker -- gcc or cc or \n # whatever. This is a sane assumption, correct?\n # If the linker is gcc, set it to g++\n link_cmds = ld.split() \n if gcc_exists(link_cmds[0]):\n link_cmds[0] = 'g++'\n ld = ' '.join(link_cmds)\n \n\n if (sys.platform == 'darwin'):\n # The Jaguar distributed python 2.2 has -arch i386 in the link line\n # which doesn't seem right. It omits all kinds of warnings, so \n # remove it.\n ld = ld.replace('-arch i386','')\n \n # The following line is a HACK to fix a problem with building the\n # freetype shared library under Mac OS X:\n ld += ' -framework AppKit'\n \n # 2.3a1 on OS X emits a ton of warnings about long double. OPT\n # appears to not have all the needed flags set while CFLAGS does.\n cfg_vars = distutils.sysconfig._config_vars\n cfg_vars['OPT'] = cfg_vars['CFLAGS'] \n distutils.sysconfig._config_vars['LDSHARED'] = ld \n \ndistutils.sysconfig._init_posix = _init_posix \n# end force g++\n\n\nclass CompileError(exceptions.Exception):\n pass\n\n\ndef create_extension(module_path, **kw):\n \"\"\" Create an Extension that can be buil by setup.py\n \n See build_extension for information on keyword arguments.\n \"\"\"\n # some (most?) platforms will fail to link C++ correctly\n # unless scipy_distutils is used.\n try:\n from scipy_distutils.core import Extension\n except ImportError:\n from distutils.core import Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # the business end of the function\n sources = kw.get('sources',[])\n kw['sources'] = [module_path] + sources \n \n #--------------------------------------------------------------------\n # added access to environment variable that user can set to specify\n # where python (and other) include files are located. This is \n # very useful on systems where python is installed by the root, but\n # the user has also installed numerous packages in their own \n # location.\n #--------------------------------------------------------------------\n if os.environ.has_key('PYTHONINCLUDE'):\n path_string = os.environ['PYTHONINCLUDE'] \n if sys.platform == \"win32\":\n extra_include_dirs = path_string.split(';')\n else: \n extra_include_dirs = path_string.split(':')\n include_dirs = kw.get('include_dirs',[])\n kw['include_dirs'] = include_dirs + extra_include_dirs\n\n # SunOS specific\n # fix for issue with linking to libstdc++.a. see:\n # http://mail.python.org/pipermail/python-dev/2001-March/013510.html\n platform = sys.platform\n version = sys.version.lower()\n if platform[:5] == 'sunos' and version.find('gcc') != -1:\n extra_link_args = kw.get('extra_link_args',[])\n kw['extra_link_args'] = ['-mimpure-text'] + extra_link_args\n \n ext = Extension(module_name, **kw)\n return ext \n \ndef build_extension(module_path,compiler_name = '',build_dir = None,\n temp_dir = None, verbose = 0, **kw):\n \"\"\" Build the file given by module_path into a Python extension module.\n \n build_extensions uses distutils to build Python extension modules.\n kw arguments not used are passed on to the distutils extension\n module. Directory settings can handle absoulte settings, but don't\n currently expand '~' or environment variables.\n \n module_path -- the full path name to the c file to compile. \n Something like: /full/path/name/module_name.c \n The name of the c/c++ file should be the same as the\n name of the module (i.e. the initmodule() routine)\n compiler_name -- The name of the compiler to use. On Windows if it \n isn't given, MSVC is used if it exists (is found).\n gcc is used as a second choice. If neither are found, \n the default distutils compiler is used. Acceptable \n names are 'gcc', 'msvc' or any of the compiler names \n shown by distutils.ccompiler.show_compilers()\n build_dir -- The location where the resulting extension module \n should be placed. This location must be writable. If\n it isn't, several default locations are tried. If the \n build_dir is not in the current python path, a warning\n is emitted, and it is added to the end of the path.\n build_dir defaults to the current directory.\n temp_dir -- The location where temporary files (*.o or *.obj)\n from the build are placed. This location must be \n writable. If it isn't, several default locations are \n tried. It defaults to tempfile.gettempdir()\n verbose -- 0, 1, or 2. 0 is as quiet as possible. 1 prints\n minimal information. 2 is noisy. \n **kw -- keyword arguments. These are passed on to the \n distutils extension module. Most of the keywords\n are listed below.\n\n Distutils keywords. These are cut and pasted from Greg Ward's\n distutils.extension.Extension class for convenience:\n \n sources : [string]\n list of source filenames, relative to the distribution root\n (where the setup script lives), in Unix form (slash-separated)\n for portability. Source files may be C, C++, SWIG (.i),\n platform-specific resource files, or whatever else is recognized\n by the \"build_ext\" command as source for a Python extension.\n Note: The module_path file is always appended to the front of this\n list \n include_dirs : [string]\n list of directories to search for C/C++ header files (in Unix\n form for portability) \n define_macros : [(name : string, value : string|None)]\n list of macros to define; each macro is defined using a 2-tuple,\n where 'value' is either the string to define it to or None to\n define it without a particular value (equivalent of \"#define\n FOO\" in source or -DFOO on Unix C compiler command line) \n undef_macros : [string]\n list of macros to undefine explicitly\n library_dirs : [string]\n list of directories to search for C/C++ libraries at link time\n libraries : [string]\n list of library names (not filenames or paths) to link against\n runtime_library_dirs : [string]\n list of directories to search for C/C++ libraries at run time\n (for shared extensions, this is when the extension is loaded)\n extra_objects : [string]\n list of extra files to link with (eg. object files not implied\n by 'sources', static library that must be explicitly specified,\n binary resource files, etc.)\n extra_compile_args : [string]\n any extra platform- and compiler-specific information to use\n when compiling the source files in 'sources'. For platforms and\n compilers where \"command line\" makes sense, this is typically a\n list of command-line arguments, but for other platforms it could\n be anything.\n extra_link_args : [string]\n any extra platform- and compiler-specific information to use\n when linking object files together to create the extension (or\n to create a new static Python interpreter). Similar\n interpretation as for 'extra_compile_args'.\n export_symbols : [string]\n list of symbols to be exported from a shared extension. Not\n used on all platforms, and not generally necessary for Python\n extensions, which typically export exactly one symbol: \"init\" +\n extension_name.\n \"\"\"\n success = 0\n try:\n from scipy_distutils.core import setup, Extension\n except ImportError:\n from distutils.core import setup, Extension\n \n # this is a screwy trick to get rid of a ton of warnings on Unix\n import distutils.sysconfig\n distutils.sysconfig.get_config_vars()\n if distutils.sysconfig._config_vars.has_key('OPT'):\n flags = distutils.sysconfig._config_vars['OPT'] \n flags = flags.replace('-Wall','')\n distutils.sysconfig._config_vars['OPT'] = flags\n \n # get the name of the module and the extension directory it lives in. \n module_dir,cpp_name = os.path.split(os.path.abspath(module_path))\n module_name,ext = os.path.splitext(cpp_name) \n \n # configure temp and build directories\n temp_dir = configure_temp_dir(temp_dir) \n build_dir = configure_build_dir(module_dir)\n \n # dag. We keep having to add directories to the path to keep \n # object files separated from each other. gcc2.x and gcc3.x C++ \n # object files are not compatible, so we'll stick them in a sub\n # dir based on their version. This will add an md5 check sum\n # of the compiler binary to the directory name to keep objects\n # from different compilers in different locations.\n \n compiler_dir = platform_info.get_compiler_dir(compiler_name)\n temp_dir = os.path.join(temp_dir,compiler_dir)\n distutils.dir_util.mkpath(temp_dir)\n \n compiler_name = choose_compiler(compiler_name)\n \n configure_sys_argv(compiler_name,temp_dir,build_dir)\n \n # the business end of the function\n try:\n if verbose == 1:\n print 'Compiling code...'\n \n # set compiler verboseness 2 or more makes it output results\n if verbose > 1:\n verb = 1 \n else:\n verb = 0\n \n t1 = time.time() \n ext = create_extension(module_path,**kw)\n # the switcheroo on SystemExit here is meant to keep command line\n # sessions from exiting when compiles fail.\n builtin = sys.modules['__builtin__']\n old_SysExit = builtin.__dict__['SystemExit']\n builtin.__dict__['SystemExit'] = CompileError\n \n # distutils for MSVC messes with the environment, so we save the\n # current state and restore them afterward.\n import copy\n environ = copy.deepcopy(os.environ)\n try:\n setup(name = module_name, ext_modules = [ext],verbose=verb)\n finally:\n # restore state\n os.environ = environ \n # restore SystemExit\n builtin.__dict__['SystemExit'] = old_SysExit\n t2 = time.time()\n \n if verbose == 1:\n print 'finished compiling (sec): ', t2 - t1 \n success = 1\n configure_python_path(build_dir)\n except SyntaxError: #TypeError:\n success = 0 \n \n # restore argv after our trick... \n restore_sys_argv()\n\n return success\n\nold_argv = []\ndef configure_sys_argv(compiler_name,temp_dir,build_dir):\n # We're gonna play some tricks with argv here to pass info to distutils \n # which is really built for command line use. better way??\n global old_argv\n old_argv = sys.argv[:] \n sys.argv = ['','build_ext','--build-lib', build_dir,\n '--build-temp',temp_dir] \n if compiler_name == 'gcc':\n sys.argv.insert(2,'--compiler='+compiler_name)\n elif compiler_name:\n sys.argv.insert(2,'--compiler='+compiler_name)\n\ndef restore_sys_argv():\n sys.argv = old_argv\n \ndef configure_python_path(build_dir): \n #make sure the module lives in a directory on the python path.\n python_paths = [os.path.abspath(x) for x in sys.path]\n if os.path.abspath(build_dir) not in python_paths:\n #print \"warning: build directory was not part of python path.\"\\\n # \" It has been appended to the path.\"\n sys.path.append(os.path.abspath(build_dir))\n\ndef choose_compiler(compiler_name=''):\n \"\"\" Try and figure out which compiler is gonna be used on windows.\n On other platforms, it just returns whatever value it is given.\n \n converts 'gcc' to 'mingw32' on win32\n \"\"\"\n if sys.platform == 'win32': \n if not compiler_name:\n # On Windows, default to MSVC and use gcc if it wasn't found\n # wasn't found. If neither are found, go with whatever\n # the default is for distutils -- and probably fail...\n if msvc_exists():\n compiler_name = 'msvc'\n elif gcc_exists():\n compiler_name = 'mingw32'\n elif compiler_name == 'gcc':\n compiler_name = 'mingw32'\n else:\n # don't know how to force gcc -- look into this.\n if compiler_name == 'gcc':\n compiler_name = 'unix' \n return compiler_name\n \ndef gcc_exists(name = 'gcc'):\n \"\"\" Test to make sure gcc is found \n \n Does this return correct value on win98???\n \"\"\"\n result = 0\n cmd = '%s -v' % name\n try:\n w,r=os.popen4(cmd)\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Reading specs') != -1:\n result = 1\n except:\n # This was needed because the msvc compiler messes with\n # the path variable. and will occasionlly mess things up\n # so much that gcc is lost in the path. (Occurs in test\n # scripts)\n result = not os.system(cmd)\n return result\n\ndef msvc_exists():\n \"\"\" Determine whether MSVC is available on the machine.\n \"\"\"\n result = 0\n try:\n w,r=os.popen4('cl')\n w.close()\n str_result = r.read()\n #print str_result\n if string.find(str_result,'Microsoft') != -1:\n result = 1\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n version = distutils.msvccompiler.get_devstudio_version()\n if version:\n result = 1\n return result\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\n \ndef configure_temp_dir(temp_dir=None):\n if temp_dir is None: \n temp_dir = tempfile.gettempdir()\n elif not os.path.exists(temp_dir) or not os.access(temp_dir,os.W_OK):\n print \"warning: specified temp_dir '%s' does not exist \" \\\n \"or is not writable. Using the default temp directory\" % \\\n temp_dir\n temp_dir = tempfile.gettempdir()\n\n # final check that that directories are writable. \n if not os.access(temp_dir,os.W_OK):\n msg = \"Either the temp or build directory wasn't writable. Check\" \\\n \" these locations: '%s'\" % temp_dir \n raise ValueError, msg\n return temp_dir\n\ndef configure_build_dir(build_dir=None):\n # make sure build_dir exists and is writable\n if build_dir and (not os.path.exists(build_dir) or \n not os.access(build_dir,os.W_OK)):\n print \"warning: specified build_dir '%s' does not exist \" \\\n \"or is not writable. Trying default locations\" % build_dir\n build_dir = None\n \n if build_dir is None:\n #default to building in the home directory of the given module. \n build_dir = os.curdir\n # if it doesn't work use the current directory. This should always\n # be writable. \n if not os.access(build_dir,os.W_OK):\n print \"warning:, neither the module's directory nor the \"\\\n \"current directory are writable. Using the temporary\"\\\n \"directory.\"\n build_dir = tempfile.gettempdir()\n\n # final check that that directories are writable.\n if not os.access(build_dir,os.W_OK):\n msg = \"The build directory wasn't writable. Check\" \\\n \" this location: '%s'\" % build_dir\n raise ValueError, msg\n \n return os.path.abspath(build_dir) \n \nif sys.platform == 'win32':\n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp)\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n \ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\n\n\n", "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 }, { "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 } ], "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": 36, "complexity": 8, "token_count": 205, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 450, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 60, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "build_tools.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 513, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "build_tools.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 564, "end_line": 572, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "build_tools.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 574, "end_line": 600, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 605, "end_line": 607, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "build_tools.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 609, "end_line": 611, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "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": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , None , debug , extra_preargs , extra_postargs , build_temp )", "filename": "build_tools.py", "nloc": 41, "complexity": 2, "token_count": 102, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "None", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 513, "end_line": 553, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 41, "top_nesting_level": 2 } ], "nloc": 340, "complexity": 69, "token_count": 2004, "diff_parsed": { "added": [ " # added for python2.3 support", " # we can't pass it through set_executables because pre 2.2 would fail", " self.compiler_cxx = ['g++']", "", " export_symbols=None, # export_symbols, we do this in our def-file", " debug=0,", " extra_preargs=None,", " extra_postargs=None,", " build_temp=None,", " target_lang=None):", " build_temp,", " target_lang)", " build_temp,", " target_lang)" ], "deleted": [ " None, # export_symbols, we do this in our def-file", " debug,", " extra_preargs,", " extra_postargs,", " build_temp):", " build_temp)", " build_temp)" ] } } ] }, { "hash": "dac7a85925abefc8cf090ad00e60140cdd58ba62", "msg": "overrode object_filnames method in mingw compiler. The standard one in python2.3 cygwincompiler doesn't handle the case when a source file is specified with an absolute path correctly on windows. The leading drive letter is now stripped off.\n\nThis may be also be a problem on unix. It will definitely be a problem again when we try to get msvccompiler working.", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-08-23T07:46:45+00:00", "author_timezone": 0, "committer_date": "2003-08-23T07:46:45+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "925821853de544eaa09869a6043129f50ee3dab6" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 0, "insertions": 38, "lines": 38, "files": 1, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.0, "dmm_unit_interfacing": 0.0, "modified_files": [ { "old_path": "scipy_distutils/mingw32_support.py", "new_path": "scipy_distutils/mingw32_support.py", "filename": "mingw32_support.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -148,6 +148,44 @@ def link(self,\n build_temp,\n target_lang)\n \n+ def object_filenames (self,\n+ source_filenames,\n+ strip_dir=0,\n+ output_dir=''):\n+ if output_dir is None: output_dir = ''\n+ print 'cygiwn_output_dir:', output_dir\n+ obj_names = []\n+ for src_name in source_filenames:\n+ # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n+ (base, ext) = os.path.splitext (os.path.normcase(src_name))\n+ \n+ # added these lines to strip off windows drive letters\n+ # without it, .o files are placed next to .c files\n+ # instead of the build directory\n+ drv,base = os.path.splitdrive(base)\n+ if drv:\n+ base = base[1:]\n+ \n+ if ext not in (self.src_extensions + ['.rc','.res']):\n+ raise UnknownFileError, \\\n+ \"unknown file type '%s' (from '%s')\" % \\\n+ (ext, src_name)\n+ if strip_dir:\n+ base = os.path.basename (base)\n+ if ext == '.res' or ext == '.rc':\n+ # these need to be compiled to object files\n+ obj_names.append (os.path.join (output_dir,\n+ base + ext + self.obj_extension))\n+ else:\n+ print 'here', os.path.join (output_dir,\n+ base + self.obj_extension)\n+ print '...:', output_dir, base + self.obj_extension \n+ obj_names.append (os.path.join (output_dir,\n+ base + self.obj_extension))\n+ return obj_names\n+\n+ # object_filenames ()\n+\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n", "added_lines": 38, "deleted_lines": 0, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n\n # object_filenames ()\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None):\n 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 if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 151, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 198, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 208, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 244, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 259, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 262, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 266, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 269, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 160, "end_line": 168, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 170, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 206, "end_line": 220, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 221, "end_line": 222, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 224, "end_line": 225, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 228, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 231, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 151, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 } ], "nloc": 178, "complexity": 28, "token_count": 963, "diff_parsed": { "added": [ " def object_filenames (self,", " source_filenames,", " strip_dir=0,", " output_dir=''):", " if output_dir is None: output_dir = ''", " print 'cygiwn_output_dir:', output_dir", " obj_names = []", " for src_name in source_filenames:", " # use normcase to make sure '.rc' is really '.rc' and not '.RC'", " (base, ext) = os.path.splitext (os.path.normcase(src_name))", "", " # added these lines to strip off windows drive letters", " # without it, .o files are placed next to .c files", " # instead of the build directory", " drv,base = os.path.splitdrive(base)", " if drv:", " base = base[1:]", "", " if ext not in (self.src_extensions + ['.rc','.res']):", " raise UnknownFileError, \\", " \"unknown file type '%s' (from '%s')\" % \\", " (ext, src_name)", " if strip_dir:", " base = os.path.basename (base)", " if ext == '.res' or ext == '.rc':", " # these need to be compiled to object files", " obj_names.append (os.path.join (output_dir,", " base + ext + self.obj_extension))", " else:", " print 'here', os.path.join (output_dir,", " base + self.obj_extension)", " print '...:', output_dir, base + self.obj_extension", " obj_names.append (os.path.join (output_dir,", " base + self.obj_extension))", " return obj_names", "", " # object_filenames ()", "" ], "deleted": [] } } ] }, { "hash": "21ad48a017a636e2ee945c7a3c480f32f221ce28", "msg": "fixed indentation error to move object_filenames into the mingwcompiler class", "author": { "name": "Eric Jones", "email": "eric@enthought.com" }, "committer": { "name": "Eric Jones", "email": "eric@enthought.com" }, "author_date": "2003-08-23T07:50:41+00:00", "author_timezone": 0, "committer_date": "2003-08-23T07:50:41+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "dac7a85925abefc8cf090ad00e60140cdd58ba62" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 37, "insertions": 37, "lines": 74, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/mingw32_support.py", "new_path": "scipy_distutils/mingw32_support.py", "filename": "mingw32_support.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -148,43 +148,43 @@ def link(self,\n build_temp,\n target_lang)\n \n- def object_filenames (self,\n- source_filenames,\n- strip_dir=0,\n- output_dir=''):\n- if output_dir is None: output_dir = ''\n- print 'cygiwn_output_dir:', output_dir\n- obj_names = []\n- for src_name in source_filenames:\n- # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n- (base, ext) = os.path.splitext (os.path.normcase(src_name))\n- \n- # added these lines to strip off windows drive letters\n- # without it, .o files are placed next to .c files\n- # instead of the build directory\n- drv,base = os.path.splitdrive(base)\n- if drv:\n- base = base[1:]\n- \n- if ext not in (self.src_extensions + ['.rc','.res']):\n- raise UnknownFileError, \\\n- \"unknown file type '%s' (from '%s')\" % \\\n- (ext, src_name)\n- if strip_dir:\n- base = os.path.basename (base)\n- if ext == '.res' or ext == '.rc':\n- # these need to be compiled to object files\n- obj_names.append (os.path.join (output_dir,\n- base + ext + self.obj_extension))\n- else:\n- print 'here', os.path.join (output_dir,\n- base + self.obj_extension)\n- print '...:', output_dir, base + self.obj_extension \n- obj_names.append (os.path.join (output_dir,\n- base + self.obj_extension))\n- return obj_names\n-\n- # object_filenames ()\n+ def object_filenames (self,\n+ source_filenames,\n+ strip_dir=0,\n+ output_dir=''):\n+ if output_dir is None: output_dir = ''\n+ print 'cygiwn_output_dir:', output_dir\n+ obj_names = []\n+ for src_name in source_filenames:\n+ # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n+ (base, ext) = os.path.splitext (os.path.normcase(src_name))\n+ \n+ # added these lines to strip off windows drive letters\n+ # without it, .o files are placed next to .c files\n+ # instead of the build directory\n+ drv,base = os.path.splitdrive(base)\n+ if drv:\n+ base = base[1:]\n+ \n+ if ext not in (self.src_extensions + ['.rc','.res']):\n+ raise UnknownFileError, \\\n+ \"unknown file type '%s' (from '%s')\" % \\\n+ (ext, src_name)\n+ if strip_dir:\n+ base = os.path.basename (base)\n+ if ext == '.res' or ext == '.rc':\n+ # these need to be compiled to object files\n+ obj_names.append (os.path.join (output_dir,\n+ base + ext + self.obj_extension))\n+ else:\n+ print 'here', os.path.join (output_dir,\n+ base + self.obj_extension)\n+ print '...:', output_dir, base + self.obj_extension \n+ obj_names.append (os.path.join (output_dir,\n+ base + self.obj_extension))\n+ return obj_names\n+ \n+ # object_filenames ()\n \n \n # On windows platforms, we want to default to mingw32 (gcc)\n", "added_lines": 37, "deleted_lines": 37, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n\n # object_filenames ()\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 151, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 198, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 208, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 244, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 259, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 262, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 266, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 269, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 151, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 198, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 208, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 244, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 259, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 262, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 266, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 269, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 151, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 2 } ], "nloc": 178, "complexity": 28, "token_count": 963, "diff_parsed": { "added": [ " def object_filenames (self,", " source_filenames,", " strip_dir=0,", " output_dir=''):", " if output_dir is None: output_dir = ''", " print 'cygiwn_output_dir:', output_dir", " obj_names = []", " for src_name in source_filenames:", " # use normcase to make sure '.rc' is really '.rc' and not '.RC'", " (base, ext) = os.path.splitext (os.path.normcase(src_name))", "", " # added these lines to strip off windows drive letters", " # without it, .o files are placed next to .c files", " # instead of the build directory", " drv,base = os.path.splitdrive(base)", " if drv:", " base = base[1:]", "", " if ext not in (self.src_extensions + ['.rc','.res']):", " raise UnknownFileError, \\", " \"unknown file type '%s' (from '%s')\" % \\", " (ext, src_name)", " if strip_dir:", " base = os.path.basename (base)", " if ext == '.res' or ext == '.rc':", " # these need to be compiled to object files", " obj_names.append (os.path.join (output_dir,", " base + ext + self.obj_extension))", " else:", " print 'here', os.path.join (output_dir,", " base + self.obj_extension)", " print '...:', output_dir, base + self.obj_extension", " obj_names.append (os.path.join (output_dir,", " base + self.obj_extension))", " return obj_names", "", " # object_filenames ()" ], "deleted": [ " def object_filenames (self,", " source_filenames,", " strip_dir=0,", " output_dir=''):", " if output_dir is None: output_dir = ''", " print 'cygiwn_output_dir:', output_dir", " obj_names = []", " for src_name in source_filenames:", " # use normcase to make sure '.rc' is really '.rc' and not '.RC'", " (base, ext) = os.path.splitext (os.path.normcase(src_name))", "", " # added these lines to strip off windows drive letters", " # without it, .o files are placed next to .c files", " # instead of the build directory", " drv,base = os.path.splitdrive(base)", " if drv:", " base = base[1:]", "", " if ext not in (self.src_extensions + ['.rc','.res']):", " raise UnknownFileError, \\", " \"unknown file type '%s' (from '%s')\" % \\", " (ext, src_name)", " if strip_dir:", " base = os.path.basename (base)", " if ext == '.res' or ext == '.rc':", " # these need to be compiled to object files", " obj_names.append (os.path.join (output_dir,", " base + ext + self.obj_extension))", " else:", " print 'here', os.path.join (output_dir,", " base + self.obj_extension)", " print '...:', output_dir, base + self.obj_extension", " obj_names.append (os.path.join (output_dir,", " base + self.obj_extension))", " return obj_names", "", " # object_filenames ()" ] } } ] }, { "hash": "2fc0d0ef97f6e3ae84e5c44afac88a4e388ed7b5", "msg": "Fixed up for Python 2.3 distutils", "author": { "name": "martin", "email": "martin@localhost" }, "committer": { "name": "martin", "email": "martin@localhost" }, "author_date": "2003-09-17T16:39:59+00:00", "author_timezone": 0, "committer_date": "2003-09-17T16:39:59+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "21ad48a017a636e2ee945c7a3c480f32f221ce28" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 3, "insertions": 15, "lines": 18, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.75, "modified_files": [ { "old_path": "scipy_distutils/mingw32_support.py", "new_path": "scipy_distutils/mingw32_support.py", "filename": "mingw32_support.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -116,7 +116,8 @@ def link(self,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n- build_temp=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", "added_lines": 2, "deleted_lines": 1, "source_code": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None,\n target_lang=None):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "source_code_before": "\"\"\"\nSupport code for building Python extensions on Windows.\n\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n\n\"\"\"\n\nimport os, sys\nimport distutils.ccompiler\n\n# I'd really like to pull this out of scipy and make it part of distutils...\nimport scipy_distutils.command.build_flib as build_flib\n\n\nif sys.platform == 'win32':\n # NT stuff\n # 1. Make sure libpython.a exists for gcc. If not, build it.\n # 2. Force windows to use gcc (we're struggling with MSVC and g77 support) \n # 3. Force windows to use g77\n \n # 1. Build libpython from .lib and .dll if they don't exist. \n import distutils.cygwinccompiler\n from distutils.version import StrictVersion\n from distutils.ccompiler import gen_preprocess_options, gen_lib_options\n from distutils.errors import DistutilsExecError, CompileError, UnknownFileError\n \n from distutils.unixccompiler import UnixCCompiler \n \n # the same as cygwin plus some additional parameters\n class Mingw32CCompiler(distutils.cygwinccompiler.CygwinCCompiler):\n \"\"\" A modified MingW32 compiler compatible with an MSVC built Python.\n \n \"\"\"\n \n compiler_type = 'mingw32'\n \n def __init__ (self,\n verbose=0,\n dry_run=0,\n force=0):\n \n distutils.cygwinccompiler.CygwinCCompiler.__init__ (self, \n verbose,dry_run, force)\n \n # we need to support 3.2 which doesn't match the standard\n # get_versions methods regex\n if self.gcc_version is None:\n import re\n out = os.popen('gcc' + ' -dumpversion','r')\n out_string = out.read()\n out.close()\n result = re.search('(\\d+\\.\\d+)',out_string)\n if result:\n self.gcc_version = StrictVersion(result.group(1)) \n\n # A real mingw32 doesn't need to specify a different entry point,\n # but cygwin 2.91.57 in no-cygwin-mode needs it.\n if self.gcc_version <= \"2.91.57\":\n entry_point = '--entry _DllMain@12'\n else:\n entry_point = ''\n if self.linker_dll == 'dllwrap':\n self.linker = 'dllwrap' + ' --driver-name g++'\n elif self.linker_dll == 'gcc':\n self.linker = 'g++' \n\n # **changes: eric jones 4/11/01\n # 1. Check for import library on Windows. Build if it doesn't exist.\n if not import_library_exists():\n build_import_library()\n \n # **changes: eric jones 4/11/01\n # 2. increased optimization and turned off all warnings\n # 3. also added --driver-name g++\n #self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n # compiler_so='gcc -mno-cygwin -mdll -O2 -w',\n # linker_exe='gcc -mno-cygwin',\n # linker_so='%s --driver-name g++ -mno-cygwin -mdll -static %s' \n # % (self.linker, entry_point))\n if self.gcc_version <= \"3.0.0\":\n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -mno-cygwin -mdll -O2 -w -Wstrict-prototypes',\n linker_exe='g++ -mno-cygwin',\n linker_so='%s -mno-cygwin -mdll -static %s' \n % (self.linker, entry_point))\n else: \n self.set_executables(compiler='gcc -mno-cygwin -O2 -w',\n compiler_so='gcc -O2 -w -Wstrict-prototypes',\n linker_exe='g++ ',\n linker_so='g++ -shared')\n # added for python2.3 support\n # we can't pass it through set_executables because pre 2.2 would fail\n self.compiler_cxx = 'g++'\n \n # Maybe we should also append -mthreads, but then the finished\n # dlls need another dll (mingwm10.dll see Mingw32 docs)\n # (-mthreads: Support thread-safe exception handling on `Mingw32') \n \n # no additional libraries needed \n self.dll_libraries=[]\n \n # __init__ ()\n\n def link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n export_symbols = None,\n debug=0,\n extra_preargs=None,\n extra_postargs=None,\n build_temp=None):\n if self.gcc_version < \"3.0.0\":\n distutils.cygwinccompiler.CygwinCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, #export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n else:\n UnixCCompiler.link(self,\n target_desc,\n objects,\n output_filename,\n output_dir,\n libraries,\n library_dirs,\n runtime_library_dirs,\n None, # export_symbols, we do this in our def-file\n debug,\n extra_preargs,\n extra_postargs,\n build_temp,\n target_lang)\n\n def object_filenames (self,\n source_filenames,\n strip_dir=0,\n output_dir=''):\n if output_dir is None: output_dir = ''\n print 'cygiwn_output_dir:', output_dir\n obj_names = []\n for src_name in source_filenames:\n # use normcase to make sure '.rc' is really '.rc' and not '.RC'\n (base, ext) = os.path.splitext (os.path.normcase(src_name))\n \n # added these lines to strip off windows drive letters\n # without it, .o files are placed next to .c files\n # instead of the build directory\n drv,base = os.path.splitdrive(base)\n if drv:\n base = base[1:]\n \n if ext not in (self.src_extensions + ['.rc','.res']):\n raise UnknownFileError, \\\n \"unknown file type '%s' (from '%s')\" % \\\n (ext, src_name)\n if strip_dir:\n base = os.path.basename (base)\n if ext == '.res' or ext == '.rc':\n # these need to be compiled to object files\n obj_names.append (os.path.join (output_dir,\n base + ext + self.obj_extension))\n else:\n print 'here', os.path.join (output_dir,\n base + self.obj_extension)\n print '...:', output_dir, base + self.obj_extension \n obj_names.append (os.path.join (output_dir,\n base + self.obj_extension))\n return obj_names\n \n # object_filenames ()\n\n \n # On windows platforms, we want to default to mingw32 (gcc)\n # because msvc can't build blitz stuff.\n # We should also check the version of gcc available...\n #distutils.ccompiler._default_compilers['nt'] = 'mingw32'\n #distutils.ccompiler._default_compilers = (('nt', 'mingw32'))\n # reset the Mingw32 compiler in distutils to the one defined above\n distutils.cygwinccompiler.Mingw32CCompiler = Mingw32CCompiler\n \n def import_library_exists():\n \"\"\" on windows platforms, make sure a gcc import library exists\n \"\"\"\n if os.name == 'nt':\n lib_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n full_path = os.path.join(sys.prefix,'libs',lib_name)\n if not os.path.exists(full_path):\n return 0\n return 1\n \n def build_import_library():\n \"\"\" Build the import libraries for Mingw32-gcc on Windows\n \"\"\"\n from scipy_distutils import lib2def\n #libfile, deffile = parse_cmd()\n #if deffile is None:\n # deffile = sys.stdout\n #else:\n # deffile = open(deffile, 'w')\n lib_name = \"python%d%d.lib\" % tuple(sys.version_info[:2]) \n lib_file = os.path.join(sys.prefix,'libs',lib_name)\n def_name = \"python%d%d.def\" % tuple(sys.version_info[:2]) \n def_file = os.path.join(sys.prefix,'libs',def_name)\n nm_cmd = '%s %s' % (lib2def.DEFAULT_NM, lib_file)\n nm_output = lib2def.getnm(nm_cmd)\n dlist, flist = lib2def.parse_nm(nm_output)\n lib2def.output_def(dlist, flist, lib2def.DEF_HEADER, open(def_file, 'w'))\n \n out_name = \"libpython%d%d.a\" % tuple(sys.version_info[:2])\n out_file = os.path.join(sys.prefix,'libs',out_name)\n dll_name = \"python%d%d.dll\" % tuple(sys.version_info[:2])\n args = (dll_name,def_file,out_file)\n cmd = 'dlltool --dllname %s --def %s --output-lib %s' % args\n success = not os.system(cmd)\n # for now, fail silently\n if not success:\n print 'WARNING: failed to build import library for gcc. Linking will fail.'\n #if not success:\n # msg = \"Couldn't find import library, and failed to build it.\"\n # raise DistutilsPlatformError, msg\n\n if 1:\n # See build_flib.finalize_options method in build_flib.py\n # where set_windows_compiler is called with proper\n # compiler (there gcc/g77 is still default).\n\n def set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n \n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n ) \n def use_msvc():\n set_windows_compiler('msvc')\n \n def use_gcc(): \n set_windows_compiler('mingw32')\n\n standard_compiler_list = build_flib.all_compilers[:]\n def use_g77():\n build_flib.all_compilers = [build_flib.gnu_fortran_compiler] \n\n def use_standard_fortran_compiler():\n build_flib.all_compilers = standard_compiler_list\n\n # 2. force the use of gcc on windows platform\n use_gcc()\n # 3. force the use of g77 on windows platform\n use_g77()\n\n if not import_library_exists():\n build_import_library()\n", "methods": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 44, "complexity": 2, "token_count": 120, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 152, "end_line": 186, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 199, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 209, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 245, "end_line": 259, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 260, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 263, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 267, "end_line": 268, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 270, "end_line": 271, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "mingw32_support.py", "nloc": 37, "complexity": 8, "token_count": 210, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 40, "end_line": 103, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 64, "top_nesting_level": 2 }, { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 }, { "name": "object_filenames", "long_name": "object_filenames( self , source_filenames , strip_dir = 0 , output_dir = '' )", "filename": "mingw32_support.py", "nloc": 28, "complexity": 8, "token_count": 200, "parameters": [ "self", "source_filenames", "strip_dir", "output_dir" ], "start_line": 151, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 2 }, { "name": "import_library_exists", "long_name": "import_library_exists( )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 3, "token_count": 57, "parameters": [], "start_line": 198, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "build_import_library", "long_name": "build_import_library( )", "filename": "mingw32_support.py", "nloc": 18, "complexity": 2, "token_count": 190, "parameters": [], "start_line": 208, "end_line": 234, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "mingw32_support.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 244, "end_line": 258, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 2 }, { "name": "use_msvc", "long_name": "use_msvc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 259, "end_line": 260, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_gcc", "long_name": "use_gcc( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [], "start_line": 262, "end_line": 263, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_g77", "long_name": "use_g77( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 266, "end_line": 267, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 }, { "name": "use_standard_fortran_compiler", "long_name": "use_standard_fortran_compiler( )", "filename": "mingw32_support.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 269, "end_line": 270, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 2 } ], "changed_methods": [ { "name": "link", "long_name": "link( self , target_desc , objects , output_filename , output_dir , libraries , library_dirs , runtime_library_dirs , export_symbols = None , debug = 0 , extra_preargs = None , extra_postargs = None , build_temp = None , target_lang = None )", "filename": "mingw32_support.py", "nloc": 44, "complexity": 2, "token_count": 120, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp", "target_lang" ], "start_line": 107, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 44, "top_nesting_level": 2 }, { "name": "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 )", "filename": "mingw32_support.py", "nloc": 43, "complexity": 2, "token_count": 116, "parameters": [ "self", "target_desc", "objects", "output_filename", "output_dir", "libraries", "library_dirs", "runtime_library_dirs", "export_symbols", "debug", "extra_preargs", "extra_postargs", "build_temp" ], "start_line": 107, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 43, "top_nesting_level": 2 } ], "nloc": 179, "complexity": 28, "token_count": 967, "diff_parsed": { "added": [ " build_temp=None,", " target_lang=None):" ], "deleted": [ " build_temp=None):" ] } }, { "old_path": "weave/platform_info.py", "new_path": "weave/platform_info.py", "filename": "platform_info.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -195,7 +195,18 @@ def msvc_exists():\n except:\n #assume we're ok if devstudio exists\n import distutils.msvccompiler\n- version = distutils.msvccompiler.get_devstudio_versions()\n+\n+ # There was a change to 'distutils.msvccompiler' between Python 2.2\n+ # and Python 2.3.\n+ #\n+ # In Python 2.2 the function is 'get_devstudio_versions'\n+ # In Python 2.3 the function is 'get_build_version'\n+ try:\n+ version = distutils.msvccompiler.get_devstudio_versions()\n+ \n+ except:\n+ version = distutils.msvccompiler.get_build_version()\n+ \n if version:\n result = 1\n return result\n@@ -223,4 +234,4 @@ def msvc_exists():\n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n- pass \n\\ No newline at end of file\n+ pass \n", "added_lines": 13, "deleted_lines": 2, "source_code": "\"\"\" Information about platform and python version and compilers\n\n This information is manly used to build directory names that\n keep the object files and shared libaries straight when\n multiple platforms share the same file system.\n\"\"\"\n\nimport os, sys\n\nimport distutils\nfrom distutils.core import Extension, setup\nfrom distutils.command.build_ext import build_ext\nfrom distutils.sysconfig import customize_compiler\nfrom distutils.ccompiler import new_compiler\n\nimport distutils.bcppcompiler\n\n#from scipy_distutils import mingw32_support\n\ndef dummy_dist():\n # create a dummy distribution. It will look at any site configuration files\n # and parse the command line to pick up any user configured stuff. The \n # resulting Distribution object is returned from setup.\n # Setting _setup_stop_after prevents the any commands from actually executing.\n distutils.core._setup_stop_after = \"commandline\"\n dist = setup(name=\"dummy\")\n distutils.core._setup_stop_after = None\n return dist\n\ndef create_compiler_instance(dist): \n # build_ext is in charge of building C/C++ files.\n # We are using it and dist to parse config files, and command line \n # configurations. There may be other ways to handle this, but I'm\n # worried I may miss one of the steps in distutils if I do it my self.\n #ext_builder = build_ext(dist)\n #ext_builder.finalize_options ()\n \n # For some reason the build_ext stuff wasn't picking up the compiler \n # setting, so we grab it manually from the distribution object instead.\n opts = dist.command_options.get('build_ext',None)\n compiler_name = ''\n if opts:\n comp = opts.get('compiler',('',''))\n compiler_name = comp[1]\n \n # Create a new compiler, customize it based on the build settings,\n # and return it. \n if not compiler_name:\n compiler_name = None\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n\ndef compiler_exe_name(compiler): \n exe_name = ''\n # this is really ugly... Why aren't the attribute names \n # standardized and used in a consistent way?\n if hasattr(compiler, \"compiler\"):\n # standard unix format\n exe_name = compiler.compiler[0]\n elif hasattr(compiler, \"cc\"):\n exe_name = compiler.cc\n elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n exe_name = 'brcc32'\n return exe_name\n\ndef compiler_exe_path(exe_name):\n exe_path = None\n if os.path.exists(exe_name):\n exe_path = exe_name\n else:\n path_string = os.environ['PATH']\n path_string = os.path.expandvars(path_string)\n path_string = os.path.expanduser(path_string)\n paths = path_string.split(os.pathsep)\n for path in paths:\n path = os.path.join(path,exe_name)\n if os.path.exists(path):\n exe_path = path\n break \n # needed to catch gcc on mingw32 installations. \n path = path + '.exe' \n if os.path.exists(path):\n exe_path = path\n break\n return exe_path\n\ndef check_sum(file):\n \n import md5\n try:\n f = open(file,'r')\n bytes = f.read(-1)\n except IOError:\n bytes = '' \n chk_sum = md5.md5(bytes)\n return chk_sum.hexdigest()\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n compiler_type = choose_compiler(compiler_name)\n #print compiler_type\n configure_sys_argv(compiler_type)\n #print sys.argv\n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n #print compiler_obj.__class__\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n if not exe_path:\n raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n chk_sum = check_sum(exe_path) \n restore_sys_argv()\n \n return 'compiler_'+chk_sum\n\n#----------------------------------------------------------------------------\n# Not needed -- used for testing.\n#----------------------------------------------------------------------------\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 not compiler_name:\n compiler_name = ''\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\nold_argv = []\ndef configure_sys_argv(compiler_name):\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','--compiler='+compiler_name]\n\ndef restore_sys_argv():\n sys.argv = old_argv\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\n # There was a change to 'distutils.msvccompiler' between Python 2.2\n # and Python 2.3.\n #\n # In Python 2.2 the function is 'get_devstudio_versions'\n # In Python 2.3 the function is 'get_build_version'\n try:\n version = distutils.msvccompiler.get_devstudio_versions()\n \n except:\n version = distutils.msvccompiler.get_build_version()\n \n if version:\n result = 1\n return result\n\nif __name__ == \"__main__\":\n \"\"\"\n import time\n t1 = time.time() \n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n chk_sum = check_sum(exe_path) \n \n t2 = time.time()\n print 'compiler exe:', exe_path\n print 'check sum:', chk_sum\n print 'time (sec):', t2 - t1\n print\n \"\"\"\n path = get_compiler_dir('gcc')\n print 'gcc path:', path\n print\n try: \n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n pass \n", "source_code_before": "\"\"\" Information about platform and python version and compilers\n\n This information is manly used to build directory names that\n keep the object files and shared libaries straight when\n multiple platforms share the same file system.\n\"\"\"\n\nimport os, sys\n\nimport distutils\nfrom distutils.core import Extension, setup\nfrom distutils.command.build_ext import build_ext\nfrom distutils.sysconfig import customize_compiler\nfrom distutils.ccompiler import new_compiler\n\nimport distutils.bcppcompiler\n\n#from scipy_distutils import mingw32_support\n\ndef dummy_dist():\n # create a dummy distribution. It will look at any site configuration files\n # and parse the command line to pick up any user configured stuff. The \n # resulting Distribution object is returned from setup.\n # Setting _setup_stop_after prevents the any commands from actually executing.\n distutils.core._setup_stop_after = \"commandline\"\n dist = setup(name=\"dummy\")\n distutils.core._setup_stop_after = None\n return dist\n\ndef create_compiler_instance(dist): \n # build_ext is in charge of building C/C++ files.\n # We are using it and dist to parse config files, and command line \n # configurations. There may be other ways to handle this, but I'm\n # worried I may miss one of the steps in distutils if I do it my self.\n #ext_builder = build_ext(dist)\n #ext_builder.finalize_options ()\n \n # For some reason the build_ext stuff wasn't picking up the compiler \n # setting, so we grab it manually from the distribution object instead.\n opts = dist.command_options.get('build_ext',None)\n compiler_name = ''\n if opts:\n comp = opts.get('compiler',('',''))\n compiler_name = comp[1]\n \n # Create a new compiler, customize it based on the build settings,\n # and return it. \n if not compiler_name:\n compiler_name = None\n compiler = new_compiler(compiler=compiler_name)\n customize_compiler(compiler)\n return compiler\n\ndef compiler_exe_name(compiler): \n exe_name = ''\n # this is really ugly... Why aren't the attribute names \n # standardized and used in a consistent way?\n if hasattr(compiler, \"compiler\"):\n # standard unix format\n exe_name = compiler.compiler[0]\n elif hasattr(compiler, \"cc\"):\n exe_name = compiler.cc\n elif compiler.__class__ is distutils.bcppcompiler.BCPPCompiler:\n exe_name = 'brcc32'\n return exe_name\n\ndef compiler_exe_path(exe_name):\n exe_path = None\n if os.path.exists(exe_name):\n exe_path = exe_name\n else:\n path_string = os.environ['PATH']\n path_string = os.path.expandvars(path_string)\n path_string = os.path.expanduser(path_string)\n paths = path_string.split(os.pathsep)\n for path in paths:\n path = os.path.join(path,exe_name)\n if os.path.exists(path):\n exe_path = path\n break \n # needed to catch gcc on mingw32 installations. \n path = path + '.exe' \n if os.path.exists(path):\n exe_path = path\n break\n return exe_path\n\ndef check_sum(file):\n \n import md5\n try:\n f = open(file,'r')\n bytes = f.read(-1)\n except IOError:\n bytes = '' \n chk_sum = md5.md5(bytes)\n return chk_sum.hexdigest()\n\ndef get_compiler_dir(compiler_name):\n \"\"\" Try to figure out the compiler directory based on the\n input compiler name. This is fragile and really should\n be done at the distutils level inside the compiler. I\n think it is only useful on windows at the moment.\n \"\"\"\n compiler_type = choose_compiler(compiler_name)\n #print compiler_type\n configure_sys_argv(compiler_type)\n #print sys.argv\n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n #print compiler_obj.__class__\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n if not exe_path:\n raise ValueError, \"The '%s' compiler was not found.\" % compiler_name\n chk_sum = check_sum(exe_path) \n restore_sys_argv()\n \n return 'compiler_'+chk_sum\n\n#----------------------------------------------------------------------------\n# Not needed -- used for testing.\n#----------------------------------------------------------------------------\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 not compiler_name:\n compiler_name = ''\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\nold_argv = []\ndef configure_sys_argv(compiler_name):\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','--compiler='+compiler_name]\n\ndef restore_sys_argv():\n sys.argv = old_argv\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_versions()\n if version:\n result = 1\n return result\n\nif __name__ == \"__main__\":\n \"\"\"\n import time\n t1 = time.time() \n dist = dummy_dist() \n compiler_obj = create_compiler_instance(dist)\n exe_name = compiler_exe_name(compiler_obj)\n exe_path = compiler_exe_path(exe_name)\n chk_sum = check_sum(exe_path) \n \n t2 = time.time()\n print 'compiler exe:', exe_path\n print 'check sum:', chk_sum\n print 'time (sec):', t2 - t1\n print\n \"\"\"\n path = get_compiler_dir('gcc')\n print 'gcc path:', path\n print\n try: \n path = get_compiler_dir('msvc')\n print 'gcc path:', path\n except ValueError:\n pass ", "methods": [ { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "platform_info.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 20, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "platform_info.py", "nloc": 11, "complexity": 3, "token_count": 64, "parameters": [ "dist" ], "start_line": 30, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "platform_info.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 54, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "platform_info.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 67, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "platform_info.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 88, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "platform_info.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 99, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "platform_info.py", "nloc": 15, "complexity": 8, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 125, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "platform_info.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 152, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "platform_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 159, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 162, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "platform_info.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [], "start_line": 184, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 } ], "methods_before": [ { "name": "dummy_dist", "long_name": "dummy_dist( )", "filename": "platform_info.py", "nloc": 5, "complexity": 1, "token_count": 28, "parameters": [], "start_line": 20, "end_line": 28, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 }, { "name": "create_compiler_instance", "long_name": "create_compiler_instance( dist )", "filename": "platform_info.py", "nloc": 11, "complexity": 3, "token_count": 64, "parameters": [ "dist" ], "start_line": 30, "end_line": 52, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "top_nesting_level": 0 }, { "name": "compiler_exe_name", "long_name": "compiler_exe_name( compiler )", "filename": "platform_info.py", "nloc": 9, "complexity": 4, "token_count": 53, "parameters": [ "compiler" ], "start_line": 54, "end_line": 65, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "compiler_exe_path", "long_name": "compiler_exe_path( exe_name )", "filename": "platform_info.py", "nloc": 19, "complexity": 5, "token_count": 113, "parameters": [ "exe_name" ], "start_line": 67, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "check_sum", "long_name": "check_sum( file )", "filename": "platform_info.py", "nloc": 9, "complexity": 2, "token_count": 46, "parameters": [ "file" ], "start_line": 88, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "get_compiler_dir", "long_name": "get_compiler_dir( compiler_name )", "filename": "platform_info.py", "nloc": 12, "complexity": 2, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 99, "end_line": 119, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "choose_compiler", "long_name": "choose_compiler( compiler_name = '' )", "filename": "platform_info.py", "nloc": 15, "complexity": 8, "token_count": 62, "parameters": [ "compiler_name" ], "start_line": 125, "end_line": 149, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "configure_sys_argv", "long_name": "configure_sys_argv( compiler_name )", "filename": "platform_info.py", "nloc": 4, "complexity": 1, "token_count": 28, "parameters": [ "compiler_name" ], "start_line": 152, "end_line": 157, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "restore_sys_argv", "long_name": "restore_sys_argv( )", "filename": "platform_info.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [], "start_line": 159, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 0 }, { "name": "gcc_exists", "long_name": "gcc_exists( name = 'gcc' )", "filename": "platform_info.py", "nloc": 12, "complexity": 3, "token_count": 69, "parameters": [ "name" ], "start_line": 162, "end_line": 182, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 0 }, { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "platform_info.py", "nloc": 14, "complexity": 4, "token_count": 71, "parameters": [], "start_line": 184, "end_line": 201, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "msvc_exists", "long_name": "msvc_exists( )", "filename": "platform_info.py", "nloc": 17, "complexity": 5, "token_count": 84, "parameters": [], "start_line": 184, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 0 } ], "nloc": 153, "complexity": 35, "token_count": 705, "diff_parsed": { "added": [ "", " # There was a change to 'distutils.msvccompiler' between Python 2.2", " # and Python 2.3.", " #", " # In Python 2.2 the function is 'get_devstudio_versions'", " # In Python 2.3 the function is 'get_build_version'", " try:", " version = distutils.msvccompiler.get_devstudio_versions()", "", " except:", " version = distutils.msvccompiler.get_build_version()", "", " pass" ], "deleted": [ " version = distutils.msvccompiler.get_devstudio_versions()", " pass" ] } } ] }, { "hash": "c11bd2deb1f398d4770a830b23f0f6c796dcb3bf", "msg": "Fixed buglets found during presentation testing. General_function now works with zeros((0,)) inputs. Fixed rv_discrete when arbitrary samples given", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-19T07:26:32+00:00", "author_timezone": 0, "committer_date": "2003-09-19T07:26:32+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "2fc0d0ef97f6e3ae84e5c44afac88a4e388ed7b5" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 2, "insertions": 3, "lines": 5, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_base/polynomial.py", "new_path": "scipy_base/polynomial.py", "filename": "polynomial.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -318,6 +318,9 @@ def __array__(self,t=None):\n else:\n return Numeric.asarray(self.coeffs)\n \n+ def __coerce__(self,other):\n+ return None\n+ \n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n@@ -441,8 +444,6 @@ def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n \n def __getattr__(self, key):\n- if key == '__coerce__':\n- raise KeyError\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n", "added_lines": 3, "deleted_lines": 2, "source_code": "import Numeric\nfrom Numeric import *\nfrom scimath import *\n\nfrom type_check import isscalar\nfrom matrix_base import diag\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\n\n__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n \ndef get_eigval_func():\n try:\n import scipy.linalg\n eigvals = scipy.linalg.eigvals\n except ImportError:\n try:\n import linalg\n eigvals = linalg.eigvals\n except ImportError:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \\\n \"You must have scipy.linalg or LinearAlgebra to \"\\\n \"use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n eig = get_eigval_func()\n seq_of_zeros=eig(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = convolve(a,[1, -seq_of_zeros[k]], mode=2)\n\n \n if a.typecode() in ['F','D']:\n # if complex roots are all complex conjugates, the roots are real.\n roots = asarray(seq_of_zeros,'D')\n pos_roots = sort_complex(compress(roots.imag > 0,roots))\n neg_roots = conjugate(sort_complex(compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n eig = get_eigval_func()\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n \n # find non-zero array entries\n non_zero = nonzero(ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n \n # casting: if incoming array isn't floating point, make it floating point.\n if p.typecode() not in ['f','d','F','D']:\n p = p.astype('d')\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(ones((N-2,),p.typecode()),-1)\n A[0,:] = -p[1:] / p[0]\n roots = eig(A)\n else:\n return array([])\n\n # tack any zeros onto the back of the array \n roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n return roots\n\ndef polyint(p,m=1,k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*Numeric.ones(m)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n y = Numeric.zeros(len(p)+1,'d')\n y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)\n y[-1] = k[0] \n val = polyint(y,m-1,k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n \ndef polyder(p,m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y,m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyval(p,x):\n \"\"\"Evaluate the polymnomial p at x.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n \"\"\"\n x = Numeric.asarray(x)\n p = Numeric.asarray(p)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) + a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 + Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) - a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 - Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1,a2):\n \"\"\"Multiplies two polynomials represented as lists.\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n val = Numeric.convolve(a1,a2)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polydiv(a1,a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n q, r = deconvolve(a1,a2)\n while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q, r = map(poly1d,(q,r))\n return q, r\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal.\n \"\"\"\n try:\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = Numeric.ones(N-D+1,Numeric.Float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - Numeric.convolve(den,quot,mode=2)\n return quot, rem\n\nimport re\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr,n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else: \n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n \n \nclass poly1d:\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r,poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __coerce__(self,other):\n return None\n \n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", "source_code_before": "import Numeric\nfrom Numeric import *\nfrom scimath import *\n\nfrom type_check import isscalar\nfrom matrix_base import diag\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\n\n__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n \ndef get_eigval_func():\n try:\n import scipy.linalg\n eigvals = scipy.linalg.eigvals\n except ImportError:\n try:\n import linalg\n eigvals = linalg.eigvals\n except ImportError:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \\\n \"You must have scipy.linalg or LinearAlgebra to \"\\\n \"use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n eig = get_eigval_func()\n seq_of_zeros=eig(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = convolve(a,[1, -seq_of_zeros[k]], mode=2)\n\n \n if a.typecode() in ['F','D']:\n # if complex roots are all complex conjugates, the roots are real.\n roots = asarray(seq_of_zeros,'D')\n pos_roots = sort_complex(compress(roots.imag > 0,roots))\n neg_roots = conjugate(sort_complex(compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n eig = get_eigval_func()\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n \n # find non-zero array entries\n non_zero = nonzero(ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n \n # casting: if incoming array isn't floating point, make it floating point.\n if p.typecode() not in ['f','d','F','D']:\n p = p.astype('d')\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(ones((N-2,),p.typecode()),-1)\n A[0,:] = -p[1:] / p[0]\n roots = eig(A)\n else:\n return array([])\n\n # tack any zeros onto the back of the array \n roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n return roots\n\ndef polyint(p,m=1,k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*Numeric.ones(m)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n y = Numeric.zeros(len(p)+1,'d')\n y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)\n y[-1] = k[0] \n val = polyint(y,m-1,k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n \ndef polyder(p,m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y,m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyval(p,x):\n \"\"\"Evaluate the polymnomial p at x.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n \"\"\"\n x = Numeric.asarray(x)\n p = Numeric.asarray(p)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) + a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 + Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) - a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 - Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1,a2):\n \"\"\"Multiplies two polynomials represented as lists.\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n val = Numeric.convolve(a1,a2)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polydiv(a1,a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n q, r = deconvolve(a1,a2)\n while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q, r = map(poly1d,(q,r))\n return q, r\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal.\n \"\"\"\n try:\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = Numeric.ones(N-D+1,Numeric.Float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - Numeric.convolve(den,quot,mode=2)\n return quot, rem\n\nimport re\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr,n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else: \n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n \n \nclass poly1d:\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r,poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key == '__coerce__':\n raise KeyError\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", "methods": [ { "name": "get_eigval_func", "long_name": "get_eigval_func( )", "filename": "polynomial.py", "nloc": 17, "complexity": 4, "token_count": 52, "parameters": [], "start_line": 13, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "poly", "long_name": "poly( seq_of_zeros )", "filename": "polynomial.py", "nloc": 23, "complexity": 9, "token_count": 195, "parameters": [ "seq_of_zeros" ], "start_line": 31, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "roots", "long_name": "roots( p )", "filename": "polynomial.py", "nloc": 19, "complexity": 4, "token_count": 190, "parameters": [ "p" ], "start_line": 71, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "polyint", "long_name": "polyint( p , m = 1 , k = None )", "filename": "polynomial.py", "nloc": 24, "complexity": 8, "token_count": 192, "parameters": [ "p", "m", "k" ], "start_line": 110, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "polyder", "long_name": "polyder( p , m = 1 )", "filename": "polynomial.py", "nloc": 15, "complexity": 4, "token_count": 99, "parameters": [ "p", "m" ], "start_line": 142, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 7, "complexity": 2, "token_count": 63, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "polyadd", "long_name": "polyadd( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 175, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polysub", "long_name": "polysub( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 193, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polymul", "long_name": "polymul( a1 , a2 )", "filename": "polynomial.py", "nloc": 6, "complexity": 3, "token_count": 46, "parameters": [ "a1", "a2" ], "start_line": 212, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "polydiv", "long_name": "polydiv( a1 , a2 )", "filename": "polynomial.py", "nloc": 8, "complexity": 5, "token_count": 94, "parameters": [ "a1", "a2" ], "start_line": 221, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "deconvolve", "long_name": "deconvolve( signal , divisor )", "filename": "polynomial.py", "nloc": 18, "complexity": 3, "token_count": 115, "parameters": [ "signal", "divisor" ], "start_line": 232, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_raise_power", "long_name": "_raise_power( astr , wrap = 70 )", "filename": "polynomial.py", "nloc": 25, "complexity": 5, "token_count": 194, "parameters": [ "astr", "wrap" ], "start_line": 255, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , c_or_r , r = 0 )", "filename": "polynomial.py", "nloc": 15, "complexity": 6, "token_count": 122, "parameters": [ "self", "c_or_r", "r" ], "start_line": 299, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__array__", "long_name": "__array__( self , t = None )", "filename": "polynomial.py", "nloc": 5, "complexity": 2, "token_count": 34, "parameters": [ "self", "t" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__coerce__", "long_name": "__coerce__( self , other )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "other" ], "start_line": 321, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 324, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 329, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "polynomial.py", "nloc": 41, "complexity": 17, "token_count": 244, "parameters": [ "self" ], "start_line": 332, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "val" ], "start_line": 376, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__mul__", "long_name": "__mul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 379, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rmul__", "long_name": "__rmul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 386, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__add__", "long_name": "__add__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 393, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 400, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__pow__", "long_name": "__pow__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 5, "token_count": 57, "parameters": [ "self", "val" ], "start_line": 407, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__sub__", "long_name": "__sub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 415, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__div__", "long_name": "__div__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 429, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rdiv__", "long_name": "__rdiv__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 436, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , key , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "key", "val" ], "start_line": 443, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , key )", "filename": "polynomial.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self", "key" ], "start_line": 446, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "val" ], "start_line": 456, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , key , val )", "filename": "polynomial.py", "nloc": 11, "complexity": 3, "token_count": 94, "parameters": [ "self", "key", "val" ], "start_line": 464, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "integ", "long_name": "integ( self , m = 1 , k = 0 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "self", "m", "k" ], "start_line": 476, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "deriv", "long_name": "deriv( self , m = 1 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "m" ], "start_line": 479, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_eigval_func", "long_name": "get_eigval_func( )", "filename": "polynomial.py", "nloc": 17, "complexity": 4, "token_count": 52, "parameters": [], "start_line": 13, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "poly", "long_name": "poly( seq_of_zeros )", "filename": "polynomial.py", "nloc": 23, "complexity": 9, "token_count": 195, "parameters": [ "seq_of_zeros" ], "start_line": 31, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "roots", "long_name": "roots( p )", "filename": "polynomial.py", "nloc": 19, "complexity": 4, "token_count": 190, "parameters": [ "p" ], "start_line": 71, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "polyint", "long_name": "polyint( p , m = 1 , k = None )", "filename": "polynomial.py", "nloc": 24, "complexity": 8, "token_count": 192, "parameters": [ "p", "m", "k" ], "start_line": 110, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "polyder", "long_name": "polyder( p , m = 1 )", "filename": "polynomial.py", "nloc": 15, "complexity": 4, "token_count": 99, "parameters": [ "p", "m" ], "start_line": 142, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 7, "complexity": 2, "token_count": 63, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "polyadd", "long_name": "polyadd( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 175, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polysub", "long_name": "polysub( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 193, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polymul", "long_name": "polymul( a1 , a2 )", "filename": "polynomial.py", "nloc": 6, "complexity": 3, "token_count": 46, "parameters": [ "a1", "a2" ], "start_line": 212, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "polydiv", "long_name": "polydiv( a1 , a2 )", "filename": "polynomial.py", "nloc": 8, "complexity": 5, "token_count": 94, "parameters": [ "a1", "a2" ], "start_line": 221, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "deconvolve", "long_name": "deconvolve( signal , divisor )", "filename": "polynomial.py", "nloc": 18, "complexity": 3, "token_count": 115, "parameters": [ "signal", "divisor" ], "start_line": 232, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_raise_power", "long_name": "_raise_power( astr , wrap = 70 )", "filename": "polynomial.py", "nloc": 25, "complexity": 5, "token_count": 194, "parameters": [ "astr", "wrap" ], "start_line": 255, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , c_or_r , r = 0 )", "filename": "polynomial.py", "nloc": 15, "complexity": 6, "token_count": 122, "parameters": [ "self", "c_or_r", "r" ], "start_line": 299, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__array__", "long_name": "__array__( self , t = None )", "filename": "polynomial.py", "nloc": 5, "complexity": 2, "token_count": 34, "parameters": [ "self", "t" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 321, "end_line": 324, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 326, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "polynomial.py", "nloc": 41, "complexity": 17, "token_count": 244, "parameters": [ "self" ], "start_line": 329, "end_line": 370, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "val" ], "start_line": 373, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__mul__", "long_name": "__mul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 376, "end_line": 381, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rmul__", "long_name": "__rmul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 383, "end_line": 388, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__add__", "long_name": "__add__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 390, "end_line": 395, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 397, "end_line": 402, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__pow__", "long_name": "__pow__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 5, "token_count": 57, "parameters": [ "self", "val" ], "start_line": 404, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__sub__", "long_name": "__sub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 412, "end_line": 417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 419, "end_line": 424, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__div__", "long_name": "__div__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 426, "end_line": 431, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rdiv__", "long_name": "__rdiv__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 433, "end_line": 438, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , key , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "key", "val" ], "start_line": 440, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , key )", "filename": "polynomial.py", "nloc": 11, "complexity": 5, "token_count": 65, "parameters": [ "self", "key" ], "start_line": 443, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "val" ], "start_line": 455, "end_line": 461, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , key , val )", "filename": "polynomial.py", "nloc": 11, "complexity": 3, "token_count": 94, "parameters": [ "self", "key", "val" ], "start_line": 463, "end_line": 473, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "integ", "long_name": "integ( self , m = 1 , k = 0 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "self", "m", "k" ], "start_line": 475, "end_line": 476, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "deriv", "long_name": "deriv( self , m = 1 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "m" ], "start_line": 478, "end_line": 479, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "__coerce__", "long_name": "__coerce__( self , other )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "other" ], "start_line": 321, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , key )", "filename": "polynomial.py", "nloc": 11, "complexity": 5, "token_count": 65, "parameters": [ "self", "key" ], "start_line": 443, "end_line": 453, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 } ], "nloc": 379, "complexity": 120, "token_count": 2719, "diff_parsed": { "added": [ " def __coerce__(self,other):", " return None", "" ], "deleted": [ " if key == '__coerce__':", " raise KeyError" ] } } ] }, { "hash": "71a86896141c8c93638d61d3fcb9965bb63c11f3", "msg": "Fixed version regex string for g77-3.x compilers", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-19T08:50:55+00:00", "author_timezone": 0, "committer_date": "2003-09-19T08:50:55+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c11bd2deb1f398d4770a830b23f0f6c796dcb3bf" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "scipy_distutils/command/build_flib.py", "new_path": "scipy_distutils/command/build_flib.py", "filename": "build_flib.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -997,7 +997,7 @@ def get_version(self):\n class gnu_fortran_compiler(fortran_compiler_base):\n \n vendor = 'Gnu'\n- ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\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", "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\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' \\\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 self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\)|\\(GCC.*\\)\\)|)\\s*(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' \\\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 self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 138, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 159, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 209, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 268, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 281, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 294, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 353, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 391, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 418, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 449, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 456, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 461, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 493, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 505, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 519, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 522, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 543, "end_line": 588, "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": 590, "end_line": 598, "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": 600, "end_line": 601, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 603, "end_line": 628, "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": 630, "end_line": 631, "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": 632, "end_line": 633, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 643, "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": 645, "end_line": 660, "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": 668, "end_line": 669, "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": 671, "end_line": 676, "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": 684, "end_line": 747, "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": 749, "end_line": 764, "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": 766, "end_line": 767, "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": 800, "end_line": 841, "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": 843, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 850, "end_line": 868, "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": 873, "end_line": 874, "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": 886, "end_line": 906, "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": 908, "end_line": 928, "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": 930, "end_line": 932, "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": 934, "end_line": 935, "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": 937, "end_line": 947, "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": 954, "end_line": 975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 977, "end_line": 995, "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": 1003, "end_line": 1049, "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": 1051, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1115, "end_line": 1132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1134, "end_line": 1140, "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": 1142, "end_line": 1150, "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": 1152, "end_line": 1153, "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": 1155, "end_line": 1156, "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": 1167, "end_line": 1196, "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": 1198, "end_line": 1212, "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": 1214, "end_line": 1215, "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": 1217, "end_line": 1226, "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": 1235, "end_line": 1238, "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": 1246, "end_line": 1267, "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": 1269, "end_line": 1271, "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": 1273, "end_line": 1274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1288, "end_line": 1316, "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": 1322, "end_line": 1323, "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": 1336, "end_line": 1367, "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": 1369, "end_line": 1370, "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": 1378, "end_line": 1402, "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": 1404, "end_line": 1407, "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": 1409, "end_line": 1413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1429, "end_line": 1456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1458, "end_line": 1460, "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": 1470, "end_line": 1495, "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": 1497, "end_line": 1499, "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": 1501, "end_line": 1502, "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": 1510, "end_line": 1535, "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": 1537, "end_line": 1538, "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": 1540, "end_line": 1543, "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": 1545, "end_line": 1551, "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": 1556, "end_line": 1564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 138, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 159, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 209, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 268, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 281, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 294, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 353, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 391, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 418, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 449, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 456, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 461, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 493, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 505, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 519, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 522, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 543, "end_line": 588, "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": 590, "end_line": 598, "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": 600, "end_line": 601, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 603, "end_line": 628, "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": 630, "end_line": 631, "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": 632, "end_line": 633, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 643, "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": 645, "end_line": 660, "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": 668, "end_line": 669, "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": 671, "end_line": 676, "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": 684, "end_line": 747, "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": 749, "end_line": 764, "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": 766, "end_line": 767, "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": 800, "end_line": 841, "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": 843, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 850, "end_line": 868, "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": 873, "end_line": 874, "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": 886, "end_line": 906, "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": 908, "end_line": 928, "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": 930, "end_line": 932, "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": 934, "end_line": 935, "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": 937, "end_line": 947, "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": 954, "end_line": 975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 977, "end_line": 995, "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": 1003, "end_line": 1049, "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": 1051, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1115, "end_line": 1132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1134, "end_line": 1140, "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": 1142, "end_line": 1150, "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": 1152, "end_line": 1153, "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": 1155, "end_line": 1156, "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": 1167, "end_line": 1196, "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": 1198, "end_line": 1212, "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": 1214, "end_line": 1215, "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": 1217, "end_line": 1226, "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": 1235, "end_line": 1238, "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": 1246, "end_line": 1267, "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": 1269, "end_line": 1271, "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": 1273, "end_line": 1274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1288, "end_line": 1316, "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": 1322, "end_line": 1323, "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": 1336, "end_line": 1367, "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": 1369, "end_line": 1370, "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": 1378, "end_line": 1402, "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": 1404, "end_line": 1407, "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": 1409, "end_line": 1413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1429, "end_line": 1456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1458, "end_line": 1460, "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": 1470, "end_line": 1495, "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": 1497, "end_line": 1499, "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": 1501, "end_line": 1502, "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": 1510, "end_line": 1535, "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": 1537, "end_line": 1538, "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": 1540, "end_line": 1543, "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": 1545, "end_line": 1551, "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": 1556, "end_line": 1564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 1166, "complexity": 305, "token_count": 6847, "diff_parsed": { "added": [ " ver_match = r'GNU Fortran (\\(GCC\\)|\\(GCC.*\\)\\)|)\\s*(?P[^\\s*\\)]+)'" ], "deleted": [ " ver_match = r'GNU Fortran (\\(GCC\\s*|)(?P[^\\s*\\)]+)'" ] } } ] }, { "hash": "a9cd02eb6215a09029cbfaeb16478f2535da3042", "msg": "Use environment when showing compilers with 'python build_flib.py'", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-19T08:59:17+00:00", "author_timezone": 0, "committer_date": "2003-09-19T08:59:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "71a86896141c8c93638d61d3fcb9965bb63c11f3" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 1, "insertions": 5, "lines": 6, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.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": "@@ -99,8 +99,12 @@ def run_command(command):\n r'|Lahey|PG|F'\n \n def 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()\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", "added_lines": 5, "deleted_lines": 1, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n 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 self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' \\\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 self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\)|\\(GCC.*\\)\\)|)\\s*(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print cyan_text(compiler)\n else:\n print yellow_text('Not found/available: %s Fortran compiler'\\\n % (compiler.vendor))\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib=', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp=', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' \\\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 self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\)|\\(GCC.*\\)\\)|)\\s*(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 101, "end_line": 112, "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": 123, "parameters": [ "self" ], "start_line": 142, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 163, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "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": 197, "end_line": 200, "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": 204, "end_line": 211, "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": 213, "end_line": 233, "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": 235, "end_line": 240, "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": 242, "end_line": 247, "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": 251, "end_line": 268, "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": 272, "end_line": 281, "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": 285, "end_line": 296, "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": 298, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 342, "end_line": 347, "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": 357, "end_line": 378, "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": 395, "end_line": 420, "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": 422, "end_line": 451, "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": 453, "end_line": 458, "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": 460, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 465, "end_line": 493, "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": 497, "end_line": 500, "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": 502, "end_line": 507, "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": 509, "end_line": 513, "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": 515, "end_line": 517, "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": 519, "end_line": 521, "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": 523, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 526, "end_line": 545, "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": 547, "end_line": 592, "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": 594, "end_line": 602, "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": 604, "end_line": 605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 607, "end_line": 632, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 639, "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": 640, "end_line": 641, "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": 642, "end_line": 647, "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": 649, "end_line": 664, "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": 672, "end_line": 673, "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": 675, "end_line": 680, "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": 688, "end_line": 751, "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": 753, "end_line": 768, "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": 770, "end_line": 771, "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": 804, "end_line": 845, "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": 847, "end_line": 852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 854, "end_line": 872, "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": 877, "end_line": 878, "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": 890, "end_line": 910, "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": 912, "end_line": 932, "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": 934, "end_line": 936, "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": 938, "end_line": 939, "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": 941, "end_line": 951, "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": 958, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 981, "end_line": 999, "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": 1007, "end_line": 1053, "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": 1055, "end_line": 1117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1119, "end_line": 1136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1138, "end_line": 1144, "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": 1146, "end_line": 1154, "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": 1156, "end_line": 1157, "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": 1159, "end_line": 1160, "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": 1171, "end_line": 1200, "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": 1202, "end_line": 1216, "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": 1218, "end_line": 1219, "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": 1221, "end_line": 1230, "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": 1239, "end_line": 1242, "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": 1250, "end_line": 1271, "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": 1273, "end_line": 1275, "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": 1277, "end_line": 1278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1292, "end_line": 1320, "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": 1326, "end_line": 1327, "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": 1340, "end_line": 1371, "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": 1373, "end_line": 1374, "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": 1382, "end_line": 1406, "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": 1408, "end_line": 1411, "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": 1413, "end_line": 1417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1433, "end_line": 1460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1462, "end_line": 1464, "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": 1474, "end_line": 1499, "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": 1501, "end_line": 1503, "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": 1505, "end_line": 1506, "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": 1514, "end_line": 1539, "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": 1541, "end_line": 1542, "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": 1544, "end_line": 1547, "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": 1549, "end_line": 1555, "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": 1560, "end_line": 1568, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 40, "parameters": [], "start_line": 101, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 123, "parameters": [ "self" ], "start_line": 138, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 159, "end_line": 185, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 189, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 22, "parameters": [ "self" ], "start_line": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "has_f_library", "long_name": "has_f_library( self , name )", "filename": "build_flib.py", "nloc": 5, "complexity": 4, "token_count": 32, "parameters": [ "self", "name" ], "start_line": 200, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "get_library_names", "long_name": "get_library_names( self , name = None )", "filename": "build_flib.py", "nloc": 17, "complexity": 8, "token_count": 117, "parameters": [ "self", "name" ], "start_line": 209, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 21, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_names", "long_name": "get_fcompiler_library_names( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 231, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_fcompiler_library_dirs", "long_name": "get_fcompiler_library_dirs( self )", "filename": "build_flib.py", "nloc": 4, "complexity": 2, "token_count": 24, "parameters": [ "self" ], "start_line": 238, "end_line": 243, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "get_library_dirs", "long_name": "get_library_dirs( self , name = None )", "filename": "build_flib.py", "nloc": 15, "complexity": 7, "token_count": 109, "parameters": [ "self", "name" ], "start_line": 247, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_runtime_library_dirs", "long_name": "get_runtime_library_dirs( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 31, "parameters": [ "self" ], "start_line": 268, "end_line": 277, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_flib.py", "nloc": 8, "complexity": 3, "token_count": 49, "parameters": [ "self" ], "start_line": 281, "end_line": 292, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 1 }, { "name": "build_libraries", "long_name": "build_libraries( self , fortran_libraries )", "filename": "build_flib.py", "nloc": 28, "complexity": 10, "token_count": 188, "parameters": [ "self", "fortran_libraries" ], "start_line": 294, "end_line": 329, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 338, "end_line": 343, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "is_free_format", "long_name": "is_free_format( file )", "filename": "build_flib.py", "nloc": 19, "complexity": 8, "token_count": 105, "parameters": [ "file" ], "start_line": 353, "end_line": 374, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 105, "parameters": [ "self", "verbose", "dry_run", "force" ], "start_line": 391, "end_line": 416, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 1 }, { "name": "to_object", "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 24, "complexity": 7, "token_count": 133, "parameters": [ "self", "dirty_files", "module_dirs", "temp_dir" ], "start_line": 418, "end_line": 447, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 30, "top_nesting_level": 1 }, { "name": "source_to_object_names", "long_name": "source_to_object_names( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 89, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 449, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "source_and_object_pairs", "long_name": "source_and_object_pairs( self , source_files , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 31, "parameters": [ "self", "source_files", "temp_dir" ], "start_line": 456, "end_line": 459, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 461, "end_line": 489, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "f90_compile", "long_name": "f90_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 4, "complexity": 1, "token_count": 48, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 493, "end_line": 496, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f90_fixed_compile", "long_name": "f90_fixed_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 6, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 498, "end_line": 503, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "f77_compile", "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 52, "parameters": [ "self", "source_files", "module_dirs", "temp_dir" ], "start_line": 505, "end_line": 509, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "find_existing_modules", "long_name": "find_existing_modules( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 6, "parameters": [ "self" ], "start_line": 511, "end_line": 513, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "cleanup_modules", "long_name": "cleanup_modules( self , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 8, "parameters": [ "self", "temp_dir" ], "start_line": 515, "end_line": 517, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "build_module_switch", "long_name": "build_module_switch( self , module_dirs , temp_dir )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 11, "parameters": [ "self", "module_dirs", "temp_dir" ], "start_line": 519, "end_line": 520, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 522, "end_line": 541, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 }, { "name": "build_library", "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' , build_dir = '' )", "filename": "build_flib.py", "nloc": 26, "complexity": 8, "token_count": 180, "parameters": [ "self", "library_name", "source_list", "module_dirs", "temp_dir", "build_dir" ], "start_line": 543, "end_line": 588, "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": 590, "end_line": 598, "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": 600, "end_line": 601, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 603, "end_line": 628, "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": 630, "end_line": 631, "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": 632, "end_line": 633, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 643, "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": 645, "end_line": 660, "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": 668, "end_line": 669, "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": 671, "end_line": 676, "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": 684, "end_line": 747, "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": 749, "end_line": 764, "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": 766, "end_line": 767, "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": 800, "end_line": 841, "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": 843, "end_line": 848, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 850, "end_line": 868, "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": 873, "end_line": 874, "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": 886, "end_line": 906, "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": 908, "end_line": 928, "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": 930, "end_line": 932, "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": 934, "end_line": 935, "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": 937, "end_line": 947, "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": 954, "end_line": 975, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 977, "end_line": 995, "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": 1003, "end_line": 1049, "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": 1051, "end_line": 1113, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1115, "end_line": 1132, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1134, "end_line": 1140, "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": 1142, "end_line": 1150, "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": 1152, "end_line": 1153, "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": 1155, "end_line": 1156, "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": 1167, "end_line": 1196, "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": 1198, "end_line": 1212, "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": 1214, "end_line": 1215, "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": 1217, "end_line": 1226, "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": 1235, "end_line": 1238, "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": 1246, "end_line": 1267, "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": 1269, "end_line": 1271, "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": 1273, "end_line": 1274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1288, "end_line": 1316, "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": 1322, "end_line": 1323, "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": 1336, "end_line": 1367, "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": 1369, "end_line": 1370, "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": 1378, "end_line": 1402, "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": 1404, "end_line": 1407, "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": 1409, "end_line": 1413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1429, "end_line": 1456, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1458, "end_line": 1460, "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": 1470, "end_line": 1495, "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": 1497, "end_line": 1499, "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": 1501, "end_line": 1502, "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": 1510, "end_line": 1535, "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": 1537, "end_line": 1538, "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": 1540, "end_line": 1543, "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": 1545, "end_line": 1551, "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": 1556, "end_line": 1564, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 101, "end_line": 112, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 } ], "nloc": 1170, "complexity": 306, "token_count": 6883, "diff_parsed": { "added": [ " fcompiler_exec = os.environ.get('F77')", " f90compiler_exec = os.environ.get('F90')", " compiler = compiler_class(fcompiler_exec,f90compiler_exec)", " if not compiler.is_available():", " compiler = compiler_class()" ], "deleted": [ " compiler = compiler_class()" ] } } ] }, { "hash": "3d0d2999801160151f4d9aa6523514e0c376d183", "msg": "Using distutils.log for displaying messages. This feature (from Python 2.3) works also with earlier versions of Python.", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-19T12:30:38+00:00", "author_timezone": 0, "committer_date": "2003-09-19T12:30:38+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "a9cd02eb6215a09029cbfaeb16478f2535da3042" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 54, "insertions": 136, "lines": 190, "files": 8, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 0.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": "@@ -19,13 +19,14 @@\n # two modules, mainly because a number of subtle details changed in the\n # cut 'n paste. Sigh.\n \n-import os, string\n+import os, string, sys\n from glob import glob\n from types import *\n from distutils.core import Command\n from distutils.errors import *\n from distutils.sysconfig import customize_compiler\n from scipy_distutils.misc_util import red_text,yellow_text\n+from scipy_distutils import log\n \n def show_compilers ():\n from distutils.ccompiler import show_compilers\n@@ -233,7 +234,7 @@ def build_libraries (self, libraries):\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n \n- self.announce(\"building '%s' library\" % lib_name)\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@@ -254,11 +255,11 @@ def build_libraries (self, libraries):\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- self.announce(yellow_text(cmd))\n+ log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n- self.warn(red_text('Ignoring failure during build'\\\n- ' (exit status = %s)'%failure))\n+ log.warn('Ignoring failure during %s, build'\\\n+ ' (exit status = %s)', lib_name, failure)\n \n # for libraries\n \n", "added_lines": 6, "deleted_lines": 5, "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 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", "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\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\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 self.announce(\"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 self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n self.warn(red_text('Ignoring failure during build'\\\n ' (exit status = %s)'%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": 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 } ], "methods_before": [ { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_clib.py", "nloc": 3, "complexity": 1, "token_count": 13, "parameters": [], "start_line": 30, "end_line": 32, "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": 34, "end_line": 41, "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": 43, "end_line": 51, "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": 78, "end_line": 91, "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": 96, "end_line": 122, "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": 129, "end_line": 152, "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": 157, "end_line": 190, "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": 196, "end_line": 206, "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": 211, "end_line": 221, "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": 185, "parameters": [ "self", "libraries" ], "start_line": 223, "end_line": 261, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "build_libraries", "long_name": "build_libraries( self , libraries )", "filename": "build_clib.py", "nloc": 27, "complexity": 5, "token_count": 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 } ], "nloc": 158, "complexity": 40, "token_count": 948, "diff_parsed": { "added": [ "import os, string, sys", "from scipy_distutils import log", " log.info(\"building '%s' library\", lib_name)", " log.debug(cmd)", " log.warn('Ignoring failure during %s, build'\\", " ' (exit status = %s)', lib_name, failure)" ], "deleted": [ "import os, string", " self.announce(\"building '%s' library\" % lib_name)", " self.announce(yellow_text(cmd))", " self.warn(red_text('Ignoring failure during build'\\", " ' (exit status = %s)'%failure))" ] } }, { "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": "@@ -1,14 +1,14 @@\n \"\"\" Modified version of build_ext that handles fortran source files.\n \"\"\"\n \n-import os, string\n+import os, string, sys\n from types import *\n \n from distutils.dep_util import newer_group, newer\n from distutils.command.build_ext import build_ext as old_build_ext\n \n from scipy_distutils.command.build_clib import get_headers,get_directories\n-from scipy_distutils import misc_util\n+from scipy_distutils import misc_util, log\n \n \n class build_ext (old_build_ext):\n@@ -77,9 +77,9 @@ def build_extension(self, ext):\n \n if linker_so is not None:\n if linker_so is not save_linker_so:\n- self.announce('replacing linker_so %r with %r' %(\\\n- ' '.join(save_linker_so),\n- ' '.join(linker_so)))\n+ 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@@ -108,15 +108,15 @@ def build_extension(self, ext):\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n- self.announce('replacing linker_so %r with %r' %(\\\n- ' '.join(save_linker_so),\n- ' '.join(linker_so)))\n+ 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- self.announce('restoring linker_so %r' % ' '.join(save_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@@ -133,5 +133,3 @@ def get_source_files (self):\n filenames.extend(get_headers(get_directories(ext.sources)))\n \n return filenames\n-\n- \n", "added_lines": 9, "deleted_lines": 11, "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 # 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", "source_code_before": "\"\"\" Modified version of build_ext that handles fortran source files.\n\"\"\"\n\nimport os, string\nfrom types import *\n\nfrom distutils.dep_util import newer_group, newer\nfrom distutils.command.build_ext import build_ext as old_build_ext\n\nfrom scipy_distutils.command.build_clib import get_headers,get_directories\nfrom scipy_distutils import misc_util\n\n\nclass build_ext (old_build_ext):\n\n def finalize_options (self):\n old_build_ext.finalize_options(self)\n extra_includes = misc_util.get_environ_include_dirs()\n self.include_dirs.extend(extra_includes)\n \n def build_extension(self, ext):\n \n # The MSVC compiler doesn't have a linker_so attribute.\n # Giving it a dummy one of None seems to do the trick.\n if not hasattr(self.compiler,'linker_so'):\n self.compiler.linker_so = None\n \n #XXX: anything else we need to save?\n save_linker_so = self.compiler.linker_so\n save_compiler_libs = self.compiler.libraries\n save_compiler_libs_dirs = self.compiler.library_dirs\n \n # support for building static fortran libraries\n need_f_libs = 0\n need_f_opts = getattr(ext,'need_fcompiler_opts',0)\n ext_name = string.split(ext.name,'.')[-1]\n flib_name = ext_name + '_f2py'\n\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n if build_flib.has_f_library(flib_name):\n need_f_libs = 1\n else:\n for lib_name in ext.libraries:\n if build_flib.has_f_library(lib_name):\n need_f_libs = 1\n break\n elif need_f_opts:\n build_flib = self.get_finalized_command('build_flib')\n\n #self.announce('%s %s needs fortran libraries %s %s'%(\\\n # ext.name,ext_name,need_f_libs,need_f_opts))\n \n if need_f_libs:\n if build_flib.has_f_library(flib_name) and \\\n flib_name not in ext.libraries:\n ext.libraries.insert(0,flib_name)\n for lib_name in ext.libraries[:]:\n ext.libraries.extend(build_flib.get_library_names(lib_name))\n ext.library_dirs.extend(build_flib.get_library_dirs(lib_name))\n d = build_flib.build_flib\n if d not in ext.library_dirs:\n ext.library_dirs.append(d)\n\n if need_f_libs or need_f_opts:\n moreargs = build_flib.fcompiler.get_extra_link_args()\n if moreargs != []:\n if ext.extra_link_args is None:\n ext.extra_link_args = moreargs\n else:\n ext.extra_link_args += moreargs\n\n runtime_dirs = build_flib.get_runtime_library_dirs()\n ext.runtime_library_dirs.extend(runtime_dirs or [])\n\n linker_so = build_flib.fcompiler.get_linker_so()\n\n if linker_so is not None:\n if linker_so is not save_linker_so:\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n self.compiler.linker_so = linker_so\n l = build_flib.get_fcompiler_library_names()\n #l = self.compiler.libraries + l\n self.compiler.libraries = l\n l = ( self.compiler.library_dirs +\n build_flib.get_fcompiler_library_dirs() )\n self.compiler.library_dirs = l\n else:\n libs = build_flib.get_fcompiler_library_names()\n for lib in libs:\n if lib not in self.compiler.libraries:\n self.compiler.libraries.append(lib)\n\n lib_dirs = build_flib.get_fcompiler_library_dirs()\n for lib_dir in lib_dirs:\n if lib_dir not in self.compiler.library_dirs:\n self.compiler.library_dirs.append(lib_dir)\n # check for functions existence so that we can mix distutils\n # extension with scipy_distutils functions without breakage\n elif (hasattr(ext,'has_cxx_sources') and\n ext.has_cxx_sources()):\n\n if save_linker_so and save_linker_so[0]=='gcc':\n #XXX: need similar hooks that are in weave.build_tools.py\n # Or more generally, implement cxx_compiler_class\n # hooks similar to fortran_compiler_class.\n linker_so = ['g++'] + save_linker_so[1:]\n self.compiler.linker_so = linker_so\n self.announce('replacing linker_so %r with %r' %(\\\n ' '.join(save_linker_so),\n ' '.join(linker_so)))\n\n # end of fortran source support\n res = old_build_ext.build_extension(self,ext)\n\n if save_linker_so is not self.compiler.linker_so:\n self.announce('restoring linker_so %r' % ' '.join(save_linker_so))\n self.compiler.linker_so = save_linker_so\n self.compiler.libraries = save_compiler_libs\n self.compiler.library_dirs = save_compiler_libs_dirs\n\n return res\n\n def get_source_files (self):\n self.check_extensions_list(self.extensions)\n filenames = []\n\n # Get sources and any include files in the same directory.\n for ext in self.extensions:\n filenames.extend(ext.sources)\n filenames.extend(get_headers(get_directories(ext.sources)))\n\n return filenames\n\n \n", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_ext.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 16, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "build_extension", "long_name": "build_extension( self , ext )", "filename": "build_ext.py", "nloc": 76, "complexity": 28, "token_count": 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 } ], "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": 559, "parameters": [ "self", "ext" ], "start_line": 21, "end_line": 124, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 104, "top_nesting_level": 1 }, { "name": "get_source_files", "long_name": "get_source_files( self )", "filename": "build_ext.py", "nloc": 7, "complexity": 2, "token_count": 48, "parameters": [ "self" ], "start_line": 126, "end_line": 135, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 } ], "changed_methods": [ { "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 } ], "nloc": 96, "complexity": 31, "token_count": 681, "diff_parsed": { "added": [ "import os, string, sys", "from scipy_distutils import misc_util, log", " log.debug('replacing linker_so %r with %r',", " ' '.join(save_linker_so),", " ' '.join(linker_so))", " log.debug('replacing linker_so %r with %r',", " ' '.join(save_linker_so),", " ' '.join(linker_so))", " log.debug('restoring linker_so %r' % ' '.join(save_linker_so))" ], "deleted": [ "import os, string", "from scipy_distutils import misc_util", " self.announce('replacing linker_so %r with %r' %(\\", " ' '.join(save_linker_so),", " ' '.join(linker_so)))", " self.announce('replacing linker_so %r with %r' %(\\", " ' '.join(save_linker_so),", " ' '.join(linker_so)))", " self.announce('restoring linker_so %r' % ' '.join(save_linker_so))", "", "" ] } }, { "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": "@@ -60,8 +60,8 @@\n from distutils.command.build_clib import build_clib\n from distutils.errors import *\n from distutils.version import LooseVersion\n-from scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n- cyan_text\n+from scipy_distutils.misc_util import yellow_text, cyan_text\n+from scipy_distutils import log\n \n class FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\n@@ -152,8 +152,8 @@ def initialize_options (self):\n self.fcompiler = os.environ.get('FC_VENDOR')\n if self.fcompiler \\\n and not re.match(r'\\A('+fcompiler_vendors+r')\\Z',self.fcompiler):\n- self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n- %(self.fcompiler,fcompiler_vendors)))\n+ 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@@ -167,7 +167,7 @@ def finalize_options (self):\n ('debug', 'debug'),\n ('force', 'force'))\n \n- self.announce('running find_fortran_compiler')\n+ log.debug('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n@@ -176,7 +176,7 @@ def finalize_options (self):\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n- self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n+ log.info('using %s Fortran compiler', fc)\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n@@ -300,7 +300,7 @@ def build_libraries (self, fortran_libraries):\n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n- self.announce(\" building '%s' library\" % lib_name)\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@@ -311,8 +311,6 @@ def build_libraries (self, fortran_libraries):\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n-\n-\n include_dirs = build_info.get('include_dirs')\n \n if include_dirs:\n@@ -482,7 +480,7 @@ def f_compile(self,compiler,switches, source_files,\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n- self.announce(yellow_text(cmd))\n+ log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n@@ -530,7 +528,7 @@ def create_static_lib(self, object_files, library_name,\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n- self.announce(yellow_text(cmd))\n+ log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n@@ -538,7 +536,7 @@ def create_static_lib(self, object_files, library_name,\n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n- self.announce(yellow_text(cmd))\n+ log.debug(cmd)\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n@@ -616,19 +614,19 @@ def get_version(self):\n self.version = ''\n # works I think only for unix...\n #if self.verbose:\n- self.announce('detecting %s Fortran compiler...'%(self.vendor))\n- self.announce(yellow_text(self.ver_cmd))\n+ 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- self.announce('found %s' %(green_text(out_text2)))\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- self.announce(red_text('failed to match version!'))\n+ log.warn('failed to match version!')\n else:\n- self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n+ log.warn('%s: %s', exit_status,out_text2)\n return self.version\n \n def get_libraries(self):\n@@ -857,7 +855,7 @@ def find_lib_dir(self):\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n- self.announce(yellow_text(cmd))\n+ log.debug(cmd)\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n@@ -982,7 +980,7 @@ def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n- self.announce(yellow_text(self.ver_cmd))\n+ 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@@ -990,12 +988,12 @@ def get_version(self):\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n- self.announce('found: '+green_text(out_text))\n+ 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- self.announce('%s: %s' % (exit_status,red_text(out_text)))\n+ log.warn('%s: %s', exit_status,out_text)\n return self.version\n \n class gnu_fortran_compiler(fortran_compiler_base):\n@@ -1119,14 +1117,13 @@ def get_opt(self):\n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n- self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n \n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n- self.announce(yellow_text(cmd))\n+ log.debug(cmd)\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n@@ -1309,7 +1306,7 @@ def __init__(self, fc=None, f90c=None, verbose=0):\n return\n \n if self.verbose:\n- print red_text(\"\"\"\n+ log.warn(\"\"\"\n WARNING: 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", "added_lines": 21, "deleted_lines": 24, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import 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\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 if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n 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.debug(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.debug(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.debug(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 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 #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import red_text,green_text,yellow_text,\\\n cyan_text\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\nclass FortranBuildError (FortranCompilerError):\n \"\"\"Failure to build Fortran library.\"\"\"\n\ndef set_windows_compiler(compiler):\n distutils.ccompiler._default_compilers = (\n # Platform string mappings\n \n # on a cygwin built python we can use gcc like an ordinary UNIXish\n # compiler\n ('cygwin.*', 'unix'),\n \n # OS name mappings\n ('posix', 'unix'),\n ('nt', compiler),\n ('mac', 'mwerks'),\n \n )\n\nif os.name == 'nt':\n def run_command(command):\n \"\"\" not sure how to get exit status on nt. \"\"\"\n in_pipe,out_pipe = os.popen4(command)\n in_pipe.close()\n text = out_pipe.read()\n return 0, text\nelse:\n run_command = commands.getstatusoutput\n\nfcompiler_vendors = r'Absoft|Forte|Sun|SGI|Intel|Itanium|NAG|Compaq|Gnu|VAST'\\\n r'|Lahey|PG|F'\n\ndef show_compilers():\n 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 self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\\n %(self.fcompiler,fcompiler_vendors)))\n self.fcompiler = None\n self.fcompiler_exec = os.environ.get('F77')\n self.f90compiler_exec = os.environ.get('F90')\n\n # initialize_options()\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_flib'),\n ('build_temp', 'build_temp'),\n ('debug', 'debug'),\n ('force', 'force'))\n\n self.announce('running find_fortran_compiler')\n fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec,\n verbose = self.verbose)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'\\\n % (self.fcompiler)\n else:\n self.announce('using '+cyan_text('%s Fortran compiler' % fc))\n if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n self.announce(\" building '%s' library\" % lib_name)\n\n sources = build_info.get('sources')\n if sources is None or type(sources) not in (ListType, TupleType):\n raise DistutilsSetupError, \\\n (\"in 'fortran_libraries' option (library '%s'), \" +\n \"'sources' must be present and must be \" +\n \"a list of source filenames\") % lib_name\n sources = list(sources)\n module_dirs = build_info.get('module_dirs')\n module_files = build_info.get('module_files')\n\n\n include_dirs = build_info.get('include_dirs')\n\n if include_dirs:\n fcompiler.set_include_dirs(include_dirs)\n for n,v in build_info.get('define_macros') or []:\n fcompiler.define_macro(n,v)\n for n in build_info.get('undef_macros') or []:\n fcompiler.undefine_macro(n)\n\n if module_files:\n fcompiler.build_library(lib_name, module_files,\n temp_dir=self.build_temp)\n \n fcompiler.build_library(lib_name, sources,\n module_dirs,\n temp_dir=self.build_temp,\n build_dir=self.build_flib,\n )\n\n # for loop\n\n # build_libraries ()\n\n#############################################################\n\nremove_files = []\ndef remove_files_atexit(files = remove_files):\n for f in files:\n try:\n os.remove(f)\n except OSError:\n pass\nimport atexit\natexit.register(remove_files_atexit)\n\n\nis_f_file = re.compile(r'.*[.](for|ftn|f77|f)\\Z',re.I).match\n_has_f_header = re.compile(r'-[*]-\\s*fortran\\s*-[*]-',re.I).search\n_has_f90_header = re.compile(r'-[*]-\\s*f90\\s*-[*]-',re.I).search\n_free_f90_start = re.compile(r'[^c*][^\\s\\d\\t]',re.I).match\n\ndef is_free_format(file):\n \"\"\"Check if file is in free format Fortran.\"\"\"\n # f90 allows both fixed and free format, assuming fixed unless\n # signs of free format are detected.\n result = 0\n f = open(file,'r')\n line = f.readline()\n n = 15\n if _has_f_header(line):\n n = 0\n elif _has_f90_header(line):\n n = 0\n result = 1\n while n>0 and line:\n if line[0]!='!':\n n -= 1\n if _free_f90_start(line[:5]) or line[-2:-1]=='&':\n result = 1\n break\n line = f.readline()\n f.close()\n return result\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\n\n compile_switch = ' -c '\n object_switch = ' -o '\n lib_prefix = 'lib'\n lib_suffix = '.a'\n lib_ar = 'ar -cur '\n lib_ranlib = 'ranlib '\n\n def __init__(self,verbose=0,dry_run=0,force=0):\n # Default initialization. Constructors of derived classes MUST\n # call this function.\n CCompiler.__init__(self,verbose,dry_run,force)\n\n self.version = None\n \n self.f77_switches = ''\n self.f77_opt = ''\n self.f77_debug = ''\n \n self.f90_switches = ''\n self.f90_opt = ''\n self.f90_debug = ''\n\n self.f90_fixed_switch = ''\n\n #self.libraries = []\n #self.library_dirs = []\n\n if self.vendor is None:\n raise DistutilsInternalError,\\\n '%s must define vendor attribute'%(self.__class__)\n if self.ver_match is None:\n raise DistutilsInternalError,\\\n '%s must define ver_match attribute'%(self.__class__)\n\n def to_object(self,\n dirty_files,\n module_dirs=None,\n temp_dir=''):\n\n f77_files,f90_fixed_files,f90_files = [],[],[]\n objects = []\n for f in dirty_files:\n if is_f_file(f):\n f77_files.append(f)\n elif is_free_format(f):\n f90_files.append(f)\n else:\n f90_fixed_files.append(f)\n\n #XXX: F90 files containing modules should be compiled\n # before F90 files that use these modules.\n if f77_files:\n objects.extend(\\\n self.f77_compile(f77_files,temp_dir=temp_dir))\n\n if f90_fixed_files:\n objects.extend(\\\n self.f90_fixed_compile(f90_fixed_files,\n module_dirs,temp_dir=temp_dir))\n if f90_files:\n objects.extend(\\\n self.f90_compile(f90_files,module_dirs,temp_dir=temp_dir))\n\n return objects\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir='', ignore_modules = 0):\n \n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n if ignore_modules:\n module_switch = ''\n else:\n module_switch = self.build_module_switch(module_dirs,temp_dir)\n file_pairs = self.source_and_object_pairs(source_files,temp_dir)\n object_files = []\n for source,object in file_pairs:\n if distutils.dep_util.newer(source,object):\n self.find_existing_modules()\n cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n 'failure during compile (exit status = %s)' % failure\n object_files.append(object)\n self.cleanup_modules(temp_dir)\n \n return object_files\n #return all object files to make sure everything is archived \n #return map(lambda x: x[1], file_pairs)\n\n def f90_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_switches, self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f90_fixed_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f90_fixed_switch,\n self.f90_switches,\n self.f90_opt))\n return self.f_compile(self.f90_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n def f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs, temp_dir,\n ignore_modules = 1)\n\n def find_existing_modules(self):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def cleanup_modules(self,temp_dir):\n # added to handle lack of -moddir flag in absoft\n pass\n \n def build_module_switch(self, module_dirs,temp_dir):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None, skip_ranlib=0):\n lib_file = os.path.join(output_dir,\n self.lib_prefix+library_name+self.lib_suffix)\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n if self.lib_ranlib and not skip_ranlib:\n # Digital,MIPSPro compilers do not have ranlib.\n cmd = '%s %s' %(self.lib_ranlib,lib_file)\n self.announce(yellow_text(cmd))\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n 'failure during build (exit status = %s)'%failure \n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = '', build_dir = ''):\n #make sure the temp directory exists before trying to build files\n if not build_dir:\n build_dir = temp_dir\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_dir)\n distutils.dir_util.mkpath(build_dir)\n\n #this compiles the files\n object_list = self.to_object(source_list,\n module_dirs,\n temp_dir)\n\n # actually we need to use all the object file names here to\n # make sure the library is always built. It could occur that an\n # object file exists but hasn't been put in the archive. (happens\n # a lot when builds fail once and are restarted).\n object_list = self.source_to_object_names(source_list, temp_dir)\n\n if os.name == 'nt' \\\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 self.announce('detecting %s Fortran compiler...'%(self.vendor))\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n out_text2 = out_text.split('\\n')[0]\n if not exit_status:\n self.announce('found %s' %(green_text(out_text2)))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n if not self.version:\n self.announce(red_text('failed to match version!'))\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text2)))\n return self.version\n\n def get_libraries(self):\n return self.libraries\n def get_library_dirs(self):\n return self.library_dirs\n def get_extra_link_args(self):\n return []\n def get_runtime_library_dirs(self):\n return []\n def get_linker_so(self):\n \"\"\"\n If a compiler requires specific linker then return a list\n containing a linker executable name and linker options.\n Otherwise, return None.\n \"\"\"\n\n def __str__(self):\n s = [\"%s\\n version=%r\" % (self.vendor, self.get_version())]\n s.extend([' F77=%r' % (self.f77_compiler),\n ' F77FLAGS=%r' % (self.f77_switches),\n ' F77OPT=%r' % (self.f77_opt)])\n if hasattr(self,'f90_compiler'):\n s.extend([' F90=%r' % (self.f90_compiler),\n ' F90FLAGS=%r' % (self.f90_switches),\n ' F90OPT=%r' % (self.f90_opt),\n ' F90FIXED=%r' % (self.f90_fixed_switch)])\n if self.libraries:\n s.append(' LIBS=%r' % ' '.join(['-l%s'%n for n in self.libraries]))\n if self.library_dirs:\n s.append(' LIBDIRS=%r' % \\\n ' '.join(['-L%s'%n for n in self.library_dirs]))\n return string.join(s,'\\n')\n\nclass move_modules_mixin:\n \"\"\" Neither Absoft or MIPS have a flag for specifying the location\n where module files should be written as far as I can tell.\n This does the manual movement of the files from the local\n directory to the build direcotry.\n \"\"\"\n def find_existing_modules(self):\n self.existing_modules = glob.glob('*.mod')\n \n def cleanup_modules(self,temp_dir):\n all_modules = glob.glob('*.mod')\n created_modules = [mod for mod in all_modules \n if mod not in self.existing_modules]\n for mod in created_modules:\n distutils.file_util.move_file(mod,temp_dir) \n\n\nclass absoft_fortran_compiler(move_modules_mixin,fortran_compiler_base):\n\n vendor = 'Absoft'\n ver_match = r'FORTRAN 77 Compiler (?P[^\\s*,]*).*?Absoft Corp'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n # got rid of -B108 cause it was generating 2 underscores instead\n # of one on the newest version. Now we use -YEXT_SFX=_ to \n # specify the output format\n if os.name == 'nt':\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = ' -O -Q100'\n self.f77_switches = ' -N22 -N90 -N110'\n self.f77_opt = ' -O -Q100'\n\n self.f90_fixed_switch = ' -f fixed '\n \n self.libraries = ['fio', 'f90math', 'fmath', 'COMDLG32']\n elif sys.platform=='darwin':\n # http://www.absoft.com/literature/osxuserguide.pdf\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_' \\\n ' -YEXT_NAMES=LCS -s'\n self.f90_opt = ' -O' \n self.f90_fixed_switch = ' -f fixed '\n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n self.libraries = ['fio', 'f77math', 'f90math']\n else:\n self.f90_switches = ' -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \\\n ' -s'\n self.f90_opt = ' -O' \n self.f77_switches = ' -N22 -N90 -N110 -f -s'\n self.f77_opt = ' -O'\n\n self.f90_fixed_switch = ' -f fixed '\n\n self.libraries = ['fio', 'f77math', 'f90math']\n\n try:\n dir = os.environ['ABSOFT'] \n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.ver_cmd = self.f77_compiler + ' -V -c %s -o %s' % \\\n self.dummy_fortran_files()\n\n if os.name != 'nt' and self.is_available():\n if LooseVersion(self.get_version())<='4.6':\n self.f77_switches += ' -B108'\n else:\n # Though -N15 is undocumented, it works with Absoft 8.0 on Linux\n self.f77_switches += ' -N15'\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \n !! CHECK: does absoft handle multiple -p flags? if not, does\n !! it look at the first or last?\n # AbSoft f77 v8 doesn't accept -p, f90 requires space\n # after -p and manual indicates it accepts multiples.\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p ' + mod\n res = res + ' -p ' + temp_dir \n return res\n\n def get_extra_link_args(self):\n return []\n # Couldn't get this to link for anything using gcc.\n #dr = \"c:\\\\Absoft62\\\\lib\"\n #libs = ['fio.lib', 'COMDLG32.lib','fmath.lib', 'f90math.lib','libcomdlg32.a' ] \n #libs = map(lambda x,dr=dr:os.path.join(dr,x),libs)\n #return libs\n\n\nclass sun_fortran_compiler(fortran_compiler_base):\n \"\"\"specify/detect settings for Sun's Forte compiler\n\n Recent Sun Fortran compilers are FORTRAN 90/95 beasts. F77 support is\n handled by the same compiler, so even if you are asking for F77 you're\n getting a FORTRAN 95 compiler. Since most (all?) the code currently\n being compiled for SciPy is FORTRAN 77 code, the list of libraries\n contains various F77-related libraries. Not sure what would happen if\n you tried to actually compile and link FORTRAN 95 code with these\n settings.\n\n Note also that the 'Forte' name is passe. Sun's latest compiler is\n named 'Sun ONE Studio 7, Compiler Collection'. Heaven only knows what\n the version string for that baby will be.\n\n Consider renaming this class to forte_fortran_compiler and define\n sun_fortran_compiler separately for older Sun f77 compilers.\n \"\"\"\n \n vendor = 'Sun'\n\n # old compiler - any idea what the proper flags would be?\n #ver_match = r'f77: (?P[^\\s*,]*)'\n\n ver_match = r'f90: (Forte Developer 7 Fortran 95|Sun) (?P[^\\s*,]*)'\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -xcode=pic32 -f77 -ftrap=%none '\n self.f77_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -xcode=pic32 '\n self.f90_opt = ' -fast -dalign -xtarget=generic '\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n self.libraries = ['fsu','sunmath','mvec','f77compat']\n\n return\n\n # When using f90 as a linker, nothing from below is needed.\n # Tested against:\n # Forte Developer 7 Fortran 95 7.0 2002/03/09\n # If there are issues with older Sun compilers, then these must be\n # solved explicitly (possibly defining separate Sun compiler class)\n # while keeping this simple/minimal configuration\n # for the latest Forte compilers.\n\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath',\n 'mvec', 'f77compat', 'm']\n\n #self.libraries = ['fsu','sunmath']\n\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n if self.is_available():\n self.library_dirs = self.find_lib_dir()\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -moddir='+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -M' + mod \n return res\n\n def find_lib_dir(self):\n library_dirs = [\"/opt/SUNWspro/prod/lib\"]\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n dummy_file = self.dummy_fortran_files()[0]\n cmd = self.f90_compiler + ' -dryrun ' + dummy_file\n self.announce(yellow_text(cmd))\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\n if libs and libs[0] == \"(null)\":\n del libs[0]\n if libs:\n library_dirs = string.split(libs[0],':')\n self.get_version() # force version calculation\n compiler_home = os.path.dirname(library_dirs[0])\n library_dirs.append(os.path.join(compiler_home,\n self.version,'lib'))\n return library_dirs\n\n #def get_extra_link_args(self):\n # return [\"-Bdynamic\", \"-G\"]\n\n def get_linker_so(self):\n return [self.f90_compiler,'-Bdynamic','-G']\n\nclass forte_fortran_compiler(sun_fortran_compiler):\n vendor = 'Forte'\n ver_match = r'(f90|f95): Forte Developer 7 Fortran 95 (?P[^\\s]+).*'\n\nclass mips_fortran_compiler(move_modules_mixin, fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' -n32 -KPIC '\n\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC '\n\n\n self.f90_fixed_switch = ' -fixedform '\n self.ver_cmd = self.f90_compiler + ' -version '\n\n self.f90_opt = self.get_opt()\n self.f77_opt = self.get_opt('f77')\n\n def get_opt(self,mode='f90'):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 '\n if self.get_version():\n r = None\n if cpu.is_r10000(): r = 10000\n elif cpu.is_r12000(): r = 12000\n elif cpu.is_r8000(): r = 8000\n elif cpu.is_r5000(): r = 5000\n elif cpu.is_r4000(): r = 4000\n if r is not None:\n if mode=='f77':\n opt = opt + ' r%s ' % (r)\n else:\n opt = opt + ' -r%s ' % (r)\n for a in '19 20 21 22_4k 22_5k 24 25 26 27 28 30 32_5k 32_10k'.split():\n if getattr(cpu,'is_IP%s'%a)():\n opt=opt+' -TARG:platform=IP%s ' % a\n break\n return opt\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ''\n return res \n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n \"\"\" Absoft 6.2 is brain dead as far as I can tell and doesn't have\n a way to specify where to put output directories. This will have\n to be handled in f_compile...\n \"\"\"\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I ' + mod\n res = res + '-I ' + temp_dir \n return res\n\nclass hpux_fortran_compiler(fortran_compiler_base):\n\n vendor = 'HP'\n ver_match = r'HP F90 (?P[^\\s*,]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f90'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f77_switches = ' +pic=long +ppu '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' +pic=long +ppu '\n self.f90_opt = ' -O3 '\n\n self.f90_fixed_switch = ' ' # XXX: need fixed format flag\n\n self.ver_cmd = self.f77_compiler + ' +version '\n\n self.libraries = ['m']\n self.library_dirs = []\n\n def get_version(self):\n if self.version is not None:\n return self.version\n self.version = ''\n self.announce(yellow_text(self.ver_cmd))\n exit_status, out_text = run_command(self.ver_cmd)\n if self.verbose:\n out_text = out_text.split('\\n')[0]\n if exit_status in [0,256]:\n # 256 seems to indicate success on HP-UX but keeping\n # also 0. Or does 0 exit status mean something different\n # in this platform?\n self.announce('found: '+green_text(out_text))\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\n else:\n self.announce('%s: %s' % (exit_status,red_text(out_text)))\n return self.version\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'GNU Fortran (\\(GCC\\)|\\(GCC.*\\)\\)|)\\s*(?P[^\\s*\\)]+)'\n gcc_lib_dir = None\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n\n gcc_lib_dir = self.find_lib_directories()\n if gcc_lib_dir:\n found_g2c = 0\n dirs = gcc_lib_dir[:]\n while not found_g2c and dirs:\n for d in dirs:\n for g2c in ['g2c-pic','g2c']:\n f = os.path.join(d,'lib'+g2c+'.a')\n if os.path.isfile(f):\n found_g2c = 1\n if d not in gcc_lib_dir:\n gcc_lib_dir.append(d)\n break\n if found_g2c:\n break\n dirs = [d for d in map(os.path.dirname,dirs) if len(d)>1]\n else:\n g2c = 'g2c'\n if sys.platform == 'win32':\n self.libraries = ['gcc',g2c]\n self.library_dirs = gcc_lib_dir\n elif sys.platform == 'darwin':\n self.libraries = [g2c]\n self.library_dirs = gcc_lib_dir\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = [g2c]\n\n switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fPIC '\n\n self.f77_switches = switches\n self.ver_cmd = self.f77_compiler + ' --version '\n\n self.f77_opt = self.get_opt()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -funroll-loops '\n\n # only check for more optimization if g77 can handle it.\n if self.get_version():\n if sys.platform=='darwin':\n if cpu.is_ppc():\n opt = opt + ' -arch ppc '\n elif cpu.is_i386():\n opt = opt + ' -arch i386 '\n for a in '601 602 603 603e 604 604e 620 630 740 7400 7450 750'\\\n '403 505 801 821 823 860'.split():\n if getattr(cpu,'is_ppc%s'%a)():\n opt=opt+' -mcpu=%s -mtune=%s ' % (a,a)\n break \n return opt\n march_flag = 1\n if self.version == '0.5.26': # gcc 3.0\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n else:\n march_flag = 0\n elif self.version >= '3.1.1': # gcc >= 3.1.1\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK6_2():\n opt = opt + ' -march=k6-2 '\n elif cpu.is_AthlonK6_3():\n opt = opt + ' -march=k6-3 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n elif cpu.is_PentiumIV():\n opt = opt + ' -march=pentium4 '\n elif cpu.is_PentiumIII():\n opt = opt + ' -march=pentium3 '\n elif cpu.is_PentiumII():\n opt = opt + ' -march=pentium2 '\n else:\n march_flag = 0\n if cpu.has_mmx(): opt = opt + ' -mmmx '\n if cpu.has_sse(): opt = opt + ' -msse '\n if self.version > '3.2.2':\n if cpu.has_sse2(): opt = opt + ' -msse2 '\n if cpu.has_3dnow(): opt = opt + ' -m3dnow '\n else:\n march_flag = 0\n if march_flag:\n pass\n elif cpu.is_i686():\n opt = opt + ' -march=i686 '\n elif cpu.is_i586():\n opt = opt + ' -march=i586 '\n elif cpu.is_i486():\n opt = opt + ' -march=i486 '\n elif cpu.is_i386():\n opt = opt + ' -march=i386 '\n if cpu.is_Intel():\n opt = opt + ' -malign-double -fomit-frame-pointer '\n return opt\n \n def find_lib_directories(self):\n if self.gcc_lib_dir is not None:\n return self.gcc_lib_dir\n self.announce('running gnu_fortran_compiler.find_lib_directories')\n self.gcc_lib_dir = []\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix...\n cmd = '%s -v' % self.f77_compiler\n self.announce(yellow_text(cmd))\n exit_status, out_text = run_command(cmd)\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n assert len(m)==1,`m`\n self.gcc_lib_dir = m\n return self.gcc_lib_dir\n\n def get_linker_so(self):\n lnk = None\n # win32 linking should be handled by standard linker\n # Darwin g77 cannot be used as a linker.\n if sys.platform not in ['win32','cygwin','darwin']:\n lnk = [self.f77_compiler,'-shared']\n return lnk\n\n def get_extra_link_args(self):\n # SunOS often has dynamically loaded symbols defined in the\n # static library libg2c.a The linker doesn't like this. To\n # ignore the problem, use the -mimpure-text flag. It isn't\n # the safest thing, but seems to work.\n args = [] \n if (hasattr(os,'uname') and (os.uname()[0] == 'SunOS')):\n args = ['-mimpure-text']\n return args\n\n def f90_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n def f90_fixed_compile(self,source_files,module_files,temp_dir=''):\n raise DistutilsExecError, 'f90 not supported by Gnu'\n\n\n#http://developer.intel.com/software/products/compilers/f60l/\n#http://developer.intel.com/software/products/compilers/flin/\nclass intel_ia32_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Intel' # Intel(R) Corporation \n ver_match = r'Intel\\(R\\) Fortran Compiler for 32-bit applications, '\\\n 'Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'ifc'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -KPIC '\n\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n if cpu.has_fdiv_bug():\n switches = switches + ' -fdiv_check '\n if cpu.has_f00f_bug():\n switches = switches + ' -0f_check '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -FI -w90 -w95 -cm -c '\n self.f90_fixed_switch = ' -FI -72 -cm -w '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g ' # usage of -C sometimes causes segfaults\n self.f77_debug = self.f90_debug = debug\n\n self.ver_cmd = self.f77_compiler+' -FI -V -c %s -o %s' %\\\n self.dummy_fortran_files()\n\n def get_opt(self):\n import cpuinfo\n cpu = cpuinfo.cpuinfo()\n opt = ' -O3 -unroll '\n if cpu.is_PentiumPro() or cpu.is_PentiumII():\n opt = opt + ' -tpp6 -xi '\n elif cpu.is_PentiumIII():\n opt = opt + ' -tpp6 '\n elif cpu.is_Pentium():\n opt = opt + ' -tpp5 '\n elif cpu.is_PentiumIV():\n opt = opt + ' -tpp7 -xW '\n elif cpu.has_mmx():\n opt = opt + ' -xM '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\n def build_module_switch(self,module_dirs,temp_dir):\n if self.get_version() and self.version >= '7.0':\n res = ' -module '+temp_dir\n else:\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\nclass intel_itanium_fortran_compiler(intel_ia32_fortran_compiler):\n\n vendor = 'Itanium'\n ver_match = r'Intel\\(R\\) Fortran 90 Compiler Itanium\\(TM\\) Compiler'\\\n ' for the Itanium\\(TM\\)-based applications,'\\\n ' Version (?P[^\\s*]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c, verbose=verbose)\n\n\nclass nag_fortran_compiler(fortran_compiler_base):\n\n vendor = 'NAG'\n ver_match = r'NAGWare Fortran 95 compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'f95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g -gline -g90 -nan -C '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' -fixed '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -target=native '\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler,'-Wl,-shared']\n\n\n# http://www.fortran.com/F/compilers.html\n#\n# We define F compiler here but it is quite useless\n# because it does not support external procedures\n# which are needed for calling F90 module routines\n# through f2py generated wrappers.\nclass f_fortran_compiler(fortran_compiler_base):\n\n vendor = 'F'\n ver_match = r'Fortran Company/NAG F compiler Release (?P[^\\s]*)'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'F'\n if f90c is None:\n f90c = 'F'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f90_compiler+' -V '\n\n gnu = gnu_fortran_compiler('g77')\n if not gnu.is_available(): # F compiler requires gcc.\n self.version = ''\n return\n if not self.is_available():\n return\n\n if self.verbose:\n print red_text(\"\"\"\nWARNING: F compiler is unsupported due to its incompleteness.\n Send complaints to its vendor. For adding its support\n to scipy_distutils, it must support external procedures.\n\"\"\")\n\n self.f90_switches = ''\n self.f90_debug = ' -g -gline -g90 -C '\n self.f90_opt = ' -O '\n\n #self.f77_switches = gnu.f77_switches\n #self.f77_debug = gnu.f77_debug\n #self.f77_opt = gnu.f77_opt\n\n def get_linker_so(self):\n return ['gcc','-shared']\n\n\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)'\\\n '\\s+(?P[^\\s]*)'\n\n # VAST f90 does not support -o with -c. So, object files are created\n # to the current directory and then moved to build directory\n object_switch = ' && function _mvfile { mv -v `basename $1` $1 ; } && _mvfile '\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'g77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n d,b = os.path.split(f90c)\n vf90 = os.path.join(d,'v'+b)\n self.ver_cmd = vf90+' -v '\n\n # VAST compiler requires g77.\n gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available():\n self.version = ''\n return\n if not self.is_available():\n return\n\n self.f77_switches = gnu.f77_switches\n self.f77_debug = gnu.f77_debug\n self.f77_opt = gnu.f77_opt \n\n self.f90_switches = gnu.f77_switches\n self.f90_debug = gnu.f77_debug\n self.f90_opt = gnu.f77_opt\n\n self.f90_fixed_switch = ' -Wv,-ya '\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\n#http://www.compaq.com/fortran/docs/\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n if sys.platform[:5]=='linux':\n fc = 'fort'\n else:\n fc = 'f90'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check bounds '\n\n self.f77_switches = ' -f77rtl -fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' -fixed '\n\n self.ver_cmd = self.f77_compiler+' -version'\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays'\\\n ' -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n if sys.platform[:5]=='linux':\n return [self.f77_compiler,'-shared']\n else:\n return [self.f77_compiler,'-shared','-Wl,-expect_unresolved,*']\n\n#http://www.compaq.com/fortran\nclass compaq_visual_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'(DIGITAL|Compaq) Visual Fortran Optimizing Compiler'\\\n ' Version (?P[^\\s]*).*'\n\n compile_switch = ' /c '\n object_switch = ' /object:'\n lib_prefix = ''\n lib_suffix = '.lib'\n lib_ar = 'lib.exe /OUT:'\n lib_ranlib = ''\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'DF'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n self.ver_cmd = self.f77_compiler+' /what '\n\n if self.is_available():\n #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 101, "end_line": 112, "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": 142, "end_line": 159, "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": 143, "parameters": [ "self" ], "start_line": 163, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "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": 197, "end_line": 200, "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": 204, "end_line": 211, "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": 213, "end_line": 233, "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": 235, "end_line": 240, "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": 242, "end_line": 247, "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": 251, "end_line": 268, "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": 272, "end_line": 281, "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": 285, "end_line": 296, "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": 298, "end_line": 331, "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": 340, "end_line": 345, "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": 355, "end_line": 376, "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": 393, "end_line": 418, "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": 420, "end_line": 449, "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": 451, "end_line": 456, "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": 458, "end_line": 461, "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": 463, "end_line": 491, "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": 495, "end_line": 498, "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": 500, "end_line": 505, "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": 507, "end_line": 511, "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": 513, "end_line": 515, "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": 517, "end_line": 519, "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": 521, "end_line": 522, "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": 524, "end_line": 543, "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": 545, "end_line": 590, "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": 592, "end_line": 600, "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": 602, "end_line": 603, "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": 605, "end_line": 630, "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": 632, "end_line": 633, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 639, "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": 640, "end_line": 645, "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": 647, "end_line": 662, "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": 670, "end_line": 671, "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": 673, "end_line": 678, "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": 686, "end_line": 749, "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": 751, "end_line": 766, "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": 768, "end_line": 769, "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": 802, "end_line": 843, "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": 845, "end_line": 850, "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": 852, "end_line": 870, "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": 875, "end_line": 876, "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": 888, "end_line": 908, "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": 910, "end_line": 930, "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": 932, "end_line": 934, "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": 936, "end_line": 937, "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": 939, "end_line": 949, "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": 956, "end_line": 977, "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": 979, "end_line": 997, "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": 1005, "end_line": 1051, "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": 1053, "end_line": 1115, "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": 1117, "end_line": 1133, "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": 1135, "end_line": 1141, "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": 1143, "end_line": 1151, "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": 1153, "end_line": 1154, "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": 1156, "end_line": 1157, "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": 1168, "end_line": 1197, "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": 1199, "end_line": 1213, "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": 1215, "end_line": 1216, "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": 1218, "end_line": 1227, "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": 1236, "end_line": 1239, "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": 1247, "end_line": 1268, "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": 1270, "end_line": 1272, "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": 1274, "end_line": 1275, "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": 1289, "end_line": 1317, "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": 1323, "end_line": 1324, "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": 1337, "end_line": 1368, "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": 1370, "end_line": 1371, "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": 1379, "end_line": 1403, "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": 1405, "end_line": 1408, "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": 1410, "end_line": 1414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1430, "end_line": 1457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1459, "end_line": 1461, "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": 1471, "end_line": 1496, "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": 1498, "end_line": 1500, "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": 1502, "end_line": 1503, "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": 1511, "end_line": 1536, "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": 1538, "end_line": 1539, "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": 1541, "end_line": 1544, "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": 1546, "end_line": 1552, "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": 1557, "end_line": 1565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 101, "end_line": 112, "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": 123, "parameters": [ "self" ], "start_line": 142, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 148, "parameters": [ "self" ], "start_line": 163, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "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": 197, "end_line": 200, "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": 204, "end_line": 211, "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": 213, "end_line": 233, "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": 235, "end_line": 240, "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": 242, "end_line": 247, "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": 251, "end_line": 268, "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": 272, "end_line": 281, "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": 285, "end_line": 296, "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": 298, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 36, "top_nesting_level": 1 }, { "name": "remove_files_atexit", "long_name": "remove_files_atexit( files = remove_files )", "filename": "build_flib.py", "nloc": 6, "complexity": 3, "token_count": 24, "parameters": [ "files" ], "start_line": 342, "end_line": 347, "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": 357, "end_line": 378, "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": 395, "end_line": 420, "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": 422, "end_line": 451, "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": 453, "end_line": 458, "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": 460, "end_line": 463, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "f_compile", "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' , ignore_modules = 0 )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 172, "parameters": [ "self", "compiler", "switches", "source_files", "module_dirs", "temp_dir", "ignore_modules" ], "start_line": 465, "end_line": 493, "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": 497, "end_line": 500, "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": 502, "end_line": 507, "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": 509, "end_line": 513, "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": 515, "end_line": 517, "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": 519, "end_line": 521, "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": 523, "end_line": 524, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "create_static_lib", "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None , skip_ranlib = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 6, "token_count": 138, "parameters": [ "self", "object_files", "library_name", "output_dir", "debug", "skip_ranlib" ], "start_line": 526, "end_line": 545, "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": 547, "end_line": 592, "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": 594, "end_line": 602, "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": 604, "end_line": 605, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 18, "complexity": 5, "token_count": 145, "parameters": [ "self" ], "start_line": 607, "end_line": 632, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 639, "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": 640, "end_line": 641, "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": 642, "end_line": 647, "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": 649, "end_line": 664, "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": 672, "end_line": 673, "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": 675, "end_line": 680, "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": 688, "end_line": 751, "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": 753, "end_line": 768, "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": 770, "end_line": 771, "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": 804, "end_line": 845, "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": 847, "end_line": 852, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "find_lib_dir", "long_name": "find_lib_dir( self )", "filename": "build_flib.py", "nloc": 19, "complexity": 5, "token_count": 136, "parameters": [ "self" ], "start_line": 854, "end_line": 872, "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": 877, "end_line": 878, "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": 890, "end_line": 910, "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": 912, "end_line": 932, "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": 934, "end_line": 936, "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": 938, "end_line": 939, "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": 941, "end_line": 951, "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": 958, "end_line": 979, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 1 }, { "name": "get_version", "long_name": "get_version( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 5, "token_count": 125, "parameters": [ "self" ], "start_line": 981, "end_line": 999, "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": 1007, "end_line": 1053, "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": 1055, "end_line": 1117, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 63, "top_nesting_level": 1 }, { "name": "find_lib_directories", "long_name": "find_lib_directories( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 4, "token_count": 98, "parameters": [ "self" ], "start_line": 1119, "end_line": 1136, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 }, { "name": "get_linker_so", "long_name": "get_linker_so( self )", "filename": "build_flib.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "self" ], "start_line": 1138, "end_line": 1144, "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": 1146, "end_line": 1154, "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": 1156, "end_line": 1157, "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": 1159, "end_line": 1160, "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": 1171, "end_line": 1200, "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": 1202, "end_line": 1216, "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": 1218, "end_line": 1219, "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": 1221, "end_line": 1230, "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": 1239, "end_line": 1242, "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": 1250, "end_line": 1271, "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": 1273, "end_line": 1275, "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": 1277, "end_line": 1278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 24, "complexity": 6, "token_count": 116, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1292, "end_line": 1320, "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": 1326, "end_line": 1327, "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": 1340, "end_line": 1371, "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": 1373, "end_line": 1374, "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": 1382, "end_line": 1406, "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": 1408, "end_line": 1411, "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": 1413, "end_line": 1417, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1433, "end_line": 1460, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1462, "end_line": 1464, "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": 1474, "end_line": 1499, "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": 1501, "end_line": 1503, "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": 1505, "end_line": 1506, "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": 1514, "end_line": 1539, "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": 1541, "end_line": 1542, "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": 1544, "end_line": 1547, "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": 1549, "end_line": 1555, "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": 1560, "end_line": 1568, "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": 24, "complexity": 6, "token_count": 117, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1289, "end_line": 1317, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "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": 605, "end_line": 630, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "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": 852, "end_line": 870, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 19, "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": 298, "end_line": 331, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "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": 524, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "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": 463, "end_line": 491, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "build_flib.py", "nloc": 25, "complexity": 5, "token_count": 143, "parameters": [ "self" ], "start_line": 163, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "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": 1117, "end_line": 1133, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "build_flib.py", "nloc": 16, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 142, "end_line": 159, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 18, "top_nesting_level": 1 } ], "nloc": 1169, "complexity": 306, "token_count": 6824, "diff_parsed": { "added": [ "from scipy_distutils.misc_util import yellow_text, cyan_text", "from scipy_distutils import log", " log.warn('Unknown FC_VENDOR=%s (expected %s)',", " self.fcompiler,fcompiler_vendors)", " log.debug('running find_fortran_compiler')", " log.info('using %s Fortran compiler', fc)", " log.info(\" building '%s' library\" % lib_name)", " log.debug(cmd)", " log.debug(cmd)", " log.debug(cmd)", " log.info('detecting %s Fortran compiler...'%(self.vendor))", " log.debug(self.ver_cmd)", " log.info('found %s', out_text2)", " log.warn('failed to match version!')", " log.warn('%s: %s', exit_status,out_text2)", " log.debug(cmd)", " log.debug(self.ver_cmd)", " log.info('found: '+out_text)", " log.warn('%s: %s', exit_status,out_text)", " log.debug(cmd)", " log.warn(\"\"\"" ], "deleted": [ "from scipy_distutils.misc_util import red_text,green_text,yellow_text,\\", " cyan_text", " self.warn(red_text('Unknown FC_VENDOR=%s (expected %s)'\\", " %(self.fcompiler,fcompiler_vendors)))", " self.announce('running find_fortran_compiler')", " self.announce('using '+cyan_text('%s Fortran compiler' % fc))", " self.announce(\" building '%s' library\" % lib_name)", "", "", " self.announce(yellow_text(cmd))", " self.announce(yellow_text(cmd))", " self.announce(yellow_text(cmd))", " self.announce('detecting %s Fortran compiler...'%(self.vendor))", " self.announce(yellow_text(self.ver_cmd))", " self.announce('found %s' %(green_text(out_text2)))", " self.announce(red_text('failed to match version!'))", " self.announce('%s: %s' % (exit_status,red_text(out_text2)))", " self.announce(yellow_text(cmd))", " self.announce(yellow_text(self.ver_cmd))", " self.announce('found: '+green_text(out_text))", " self.announce('%s: %s' % (exit_status,red_text(out_text)))", " self.announce('running gnu_fortran_compiler.find_lib_directories')", " self.announce(yellow_text(cmd))", " print red_text(\"\"\"" ] } }, { "old_path": "scipy_distutils/command/build_py.py", "new_path": "scipy_distutils/command/build_py.py", "filename": "build_py.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -5,6 +5,7 @@\n #from distutils.command.build_py import *\n from distutils.command.build_py import build_py as old_build_py\n from fnmatch import fnmatch\n+from scipy_distutils import log\n \n def is_setup_script(file):\n file = os.path.basename(file)\n@@ -44,5 +45,5 @@ def find_package_modules(self, package, package_dir):\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n else:\n- self.debug_print(\"excluding %s\" % f)\n+ log.debug(\"excluding %s\", f)\n return modules\n", "added_lines": 2, "deleted_lines": 1, "source_code": "\nimport os\nimport sys\nfrom glob import glob\n#from distutils.command.build_py import *\nfrom distutils.command.build_py import build_py as old_build_py\nfrom fnmatch import fnmatch\nfrom scipy_distutils import log\n\ndef is_setup_script(file):\n file = os.path.basename(file)\n return fnmatch(file,\"setup.py\")\n #return (fnmatch(file,\"setup.py\") or fnmatch(file,\"setup_*.py\"))\n\ndef in_build_py_ignore(file, _cache={}):\n base,file = os.path.split(file)\n ignore_list = _cache.get(base)\n if ignore_list is None:\n ignore_list = []\n fn = os.path.join(base,'.build_py_ignore')\n if os.path.isfile(fn):\n f = open(fn,'r')\n ignore_list = [x for x in f.read().split('\\n') if x]\n f.close()\n _cache[base] = ignore_list\n return file in ignore_list\n\nclass build_py(old_build_py):\n\n def find_package_modules(self, package, package_dir):\n # we filter all files that are setup.py or setup_xxx.py\n # or listed in .build_py_ignore file of files base directory.\n if 'sdist' in sys.argv:\n return old_build_py.find_package_modules(self,package,package_dir)\n\n self.check_package(package, package_dir)\n module_files = glob(os.path.join(package_dir, \"*.py\"))\n modules = []\n setup_script = os.path.abspath(self.distribution.script_name)\n\n for f in module_files:\n abs_f = os.path.abspath(f)\n if not in_build_py_ignore(abs_f) \\\n and abs_f != setup_script and not is_setup_script(f):\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n else:\n log.debug(\"excluding %s\", f)\n return modules\n", "source_code_before": "\nimport os\nimport sys\nfrom glob import glob\n#from distutils.command.build_py import *\nfrom distutils.command.build_py import build_py as old_build_py\nfrom fnmatch import fnmatch\n\ndef is_setup_script(file):\n file = os.path.basename(file)\n return fnmatch(file,\"setup.py\")\n #return (fnmatch(file,\"setup.py\") or fnmatch(file,\"setup_*.py\"))\n\ndef in_build_py_ignore(file, _cache={}):\n base,file = os.path.split(file)\n ignore_list = _cache.get(base)\n if ignore_list is None:\n ignore_list = []\n fn = os.path.join(base,'.build_py_ignore')\n if os.path.isfile(fn):\n f = open(fn,'r')\n ignore_list = [x for x in f.read().split('\\n') if x]\n f.close()\n _cache[base] = ignore_list\n return file in ignore_list\n\nclass build_py(old_build_py):\n\n def find_package_modules(self, package, package_dir):\n # we filter all files that are setup.py or setup_xxx.py\n # or listed in .build_py_ignore file of files base directory.\n if 'sdist' in sys.argv:\n return old_build_py.find_package_modules(self,package,package_dir)\n\n self.check_package(package, package_dir)\n module_files = glob(os.path.join(package_dir, \"*.py\"))\n modules = []\n setup_script = os.path.abspath(self.distribution.script_name)\n\n for f in module_files:\n abs_f = os.path.abspath(f)\n if not in_build_py_ignore(abs_f) \\\n and abs_f != setup_script and not is_setup_script(f):\n module = os.path.splitext(os.path.basename(f))[0]\n modules.append((package, module, f))\n else:\n self.debug_print(\"excluding %s\" % f)\n return modules\n", "methods": [ { "name": "is_setup_script", "long_name": "is_setup_script( file )", "filename": "build_py.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "file" ], "start_line": 10, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "in_build_py_ignore", "long_name": "in_build_py_ignore( file , _cache = { } )", "filename": "build_py.py", "nloc": 12, "complexity": 5, "token_count": 104, "parameters": [ "file", "_cache" ], "start_line": 15, "end_line": 26, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_package_modules", "long_name": "find_package_modules( self , package , package_dir )", "filename": "build_py.py", "nloc": 16, "complexity": 6, "token_count": 145, "parameters": [ "self", "package", "package_dir" ], "start_line": 30, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "methods_before": [ { "name": "is_setup_script", "long_name": "is_setup_script( file )", "filename": "build_py.py", "nloc": 3, "complexity": 1, "token_count": 22, "parameters": [ "file" ], "start_line": 9, "end_line": 11, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "in_build_py_ignore", "long_name": "in_build_py_ignore( file , _cache = { } )", "filename": "build_py.py", "nloc": 12, "complexity": 5, "token_count": 104, "parameters": [ "file", "_cache" ], "start_line": 14, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_package_modules", "long_name": "find_package_modules( self , package , package_dir )", "filename": "build_py.py", "nloc": 16, "complexity": 6, "token_count": 145, "parameters": [ "self", "package", "package_dir" ], "start_line": 29, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "find_package_modules", "long_name": "find_package_modules( self , package , package_dir )", "filename": "build_py.py", "nloc": 16, "complexity": 6, "token_count": 145, "parameters": [ "self", "package", "package_dir" ], "start_line": 30, "end_line": 49, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 1 } ], "nloc": 38, "complexity": 12, "token_count": 306, "diff_parsed": { "added": [ "from scipy_distutils import log", " log.debug(\"excluding %s\", f)" ], "deleted": [ " self.debug_print(\"excluding %s\" % f)" ] } }, { "old_path": "scipy_distutils/command/install.py", "new_path": "scipy_distutils/command/install.py", "filename": "install.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -4,6 +4,7 @@\n from distutils.util import convert_path\n from distutils.file_util import write_file\n from distutils.errors import DistutilsOptionError\n+from scipy_distutils import log\n \n #install support for Numeric.pth setup\n class install(old_install):\n@@ -51,4 +52,4 @@ def create_path_file (self):\n (filename, [self.pth_file]),\n \"creating %s\" % filename)\n else:\n- self.warn(\"path file '%s' not created\" % filename)\n\\ No newline at end of file\n+ log.warn(\"path file '%s' not created\" % filename)\n", "added_lines": 2, "deleted_lines": 1, "source_code": "from types import StringType\nfrom distutils.command.install import *\nfrom distutils.command.install import install as old_install\nfrom distutils.util import convert_path\nfrom distutils.file_util import write_file\nfrom distutils.errors import DistutilsOptionError\nfrom scipy_distutils import log\n\n#install support for Numeric.pth setup\nclass install(old_install):\n def finalize_options (self):\n old_install.finalize_options(self)\n self.install_lib = self.install_libbase\n \n def handle_extra_path (self):\n if self.extra_path is None:\n self.extra_path = self.distribution.extra_path\n\n if self.extra_path is not None:\n if type(self.extra_path) is StringType:\n self.extra_path = string.split(self.extra_path, ',')\n if len(self.extra_path) == 1:\n path_file = extra_dirs = self.extra_path[0]\n elif len(self.extra_path) == 2:\n (path_file, extra_dirs) = self.extra_path\n else:\n raise DistutilsOptionError, \\\n \"'extra_path' option must be a list, tuple, or \" + \\\n \"comma-separated string with 1 or 2 elements\"\n\n # convert to local form in case Unix notation used (as it\n # should be in setup scripts)\n extra_dirs = convert_path(extra_dirs)\n\n else:\n path_file = None\n extra_dirs = ''\n\n # XXX should we warn if path_file and not extra_dirs? (in which\n # case the path file would be harmless but pointless)\n self.path_file = path_file\n self.extra_dirs = ''\n self.pth_file = extra_dirs\n\n # handle_extra_path ()\n\n def create_path_file (self):\n filename = os.path.join(self.install_libbase,\n self.path_file + \".pth\")\n if self.install_path_file:\n self.execute(write_file,\n (filename, [self.pth_file]),\n \"creating %s\" % filename)\n else:\n log.warn(\"path file '%s' not created\" % filename)\n", "source_code_before": "from types import StringType\nfrom distutils.command.install import *\nfrom distutils.command.install import install as old_install\nfrom distutils.util import convert_path\nfrom distutils.file_util import write_file\nfrom distutils.errors import DistutilsOptionError\n\n#install support for Numeric.pth setup\nclass install(old_install):\n def finalize_options (self):\n old_install.finalize_options(self)\n self.install_lib = self.install_libbase\n \n def handle_extra_path (self):\n if self.extra_path is None:\n self.extra_path = self.distribution.extra_path\n\n if self.extra_path is not None:\n if type(self.extra_path) is StringType:\n self.extra_path = string.split(self.extra_path, ',')\n if len(self.extra_path) == 1:\n path_file = extra_dirs = self.extra_path[0]\n elif len(self.extra_path) == 2:\n (path_file, extra_dirs) = self.extra_path\n else:\n raise DistutilsOptionError, \\\n \"'extra_path' option must be a list, tuple, or \" + \\\n \"comma-separated string with 1 or 2 elements\"\n\n # convert to local form in case Unix notation used (as it\n # should be in setup scripts)\n extra_dirs = convert_path(extra_dirs)\n\n else:\n path_file = None\n extra_dirs = ''\n\n # XXX should we warn if path_file and not extra_dirs? (in which\n # case the path file would be harmless but pointless)\n self.path_file = path_file\n self.extra_dirs = ''\n self.pth_file = extra_dirs\n\n # handle_extra_path ()\n\n def create_path_file (self):\n filename = os.path.join(self.install_libbase,\n self.path_file + \".pth\")\n if self.install_path_file:\n self.execute(write_file,\n (filename, [self.pth_file]),\n \"creating %s\" % filename)\n else:\n self.warn(\"path file '%s' not created\" % filename)", "methods": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "install.py", "nloc": 3, "complexity": 1, "token_count": 18, "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": "handle_extra_path", "long_name": "handle_extra_path( self )", "filename": "install.py", "nloc": 21, "complexity": 6, "token_count": 131, "parameters": [ "self" ], "start_line": 15, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "create_path_file", "long_name": "create_path_file( self )", "filename": "install.py", "nloc": 9, "complexity": 2, "token_count": 58, "parameters": [ "self" ], "start_line": 47, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "methods_before": [ { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "install.py", "nloc": 3, "complexity": 1, "token_count": 18, "parameters": [ "self" ], "start_line": 10, "end_line": 12, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 1 }, { "name": "handle_extra_path", "long_name": "handle_extra_path( self )", "filename": "install.py", "nloc": 21, "complexity": 6, "token_count": 131, "parameters": [ "self" ], "start_line": 14, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 }, { "name": "create_path_file", "long_name": "create_path_file( self )", "filename": "install.py", "nloc": 9, "complexity": 2, "token_count": 58, "parameters": [ "self" ], "start_line": 46, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "create_path_file", "long_name": "create_path_file( self )", "filename": "install.py", "nloc": 9, "complexity": 2, "token_count": 58, "parameters": [ "self" ], "start_line": 47, "end_line": 55, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": 41, "complexity": 9, "token_count": 260, "diff_parsed": { "added": [ "from scipy_distutils import log", " log.warn(\"path file '%s' not created\" % filename)" ], "deleted": [ " self.warn(\"path file '%s' not created\" % filename)" ] } }, { "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": "@@ -12,6 +12,7 @@\n #from scipy_distutils.core import Command\n from scipy_distutils.system_info import F2pyNotFoundError\n from scipy_distutils.misc_util import red_text,yellow_text\n+from scipy_distutils import log\n \n import re,os,sys,string\n \n@@ -82,7 +83,7 @@ def f2py_sources (self, sources, ext):\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n- self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n+ 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@@ -128,8 +129,8 @@ def f2py_sources (self, sources, ext):\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n- self.warn(red_text('%s provides %s but this extension is %s' \\\n- % (source,`base`,`ext_name`)))\n+ 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@@ -161,8 +162,8 @@ def f2py_sources (self, sources, ext):\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n- self.announce(yellow_text(\"f2py %s\" % \\\n- string.join(fortran_sources + f2py_opts2,' ')))\n+ 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@@ -177,8 +178,8 @@ def f2py_sources (self, sources, ext):\n new_sources.extend(fortran_sources)\n \n if len(f2py_sources) > 1:\n- self.warn(red_text('Only one .pyf file can be used per Extension'\\\n- ' but got %s.' % (len(f2py_sources))))\n+ 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@@ -196,8 +197,8 @@ def f2py_sources (self, sources, ext):\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n- self.announce(yellow_text(\"f2py %s\" % \\\n- string.join(f2py_options+[source],' ')))\n+ 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", "added_lines": 10, "deleted_lines": 9, "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\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 (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n 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 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\n\nimport re,os,sys,string\n\nmodule_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\nuser_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?'\\\n '__user__[\\w_]*)',re.I).match\nfortran_ext_re = re.compile(r'.*[.](f90|f95|f77|for|ftn|f)\\Z',re.I).match\n\nclass run_f2py(Command):\n\n description = \"\\\"run_f2py\\\" runs f2py that builds Fortran wrapper sources\"\\\n \"(C and occasionally Fortran).\"\n\n user_options = [('build-dir=', 'b',\n \"directory to build fortran wrappers to\"),\n ('debug-capi', None,\n \"generate C/API extensions with debugging code\"),\n ('no-wrap-functions', None,\n \"do not generate wrappers for Fortran functions,etc.\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ]\n\n def initialize_options (self):\n self.build_dir = None\n self.debug_capi = None\n self.force = None\n self.no_wrap_functions = None\n self.f2py_options = []\n # initialize_options()\n\n\n def finalize_options (self):\n self.set_undefined_options('build',\n ('build_temp', 'build_dir'),\n ('force', 'force'))\n\n self.f2py_options.extend(['--build-dir',self.build_dir])\n\n if self.debug_capi is not None:\n self.f2py_options.append('--debug-capi')\n if self.no_wrap_functions is not None:\n self.f2py_options.append('--no-wrap-functions')\n\n # finalize_options()\n\n def run (self):\n if self.distribution.has_ext_modules():\n # XXX: might need also\n # build_flib = self.get_finalized_command('build_flib')\n # ...\n # for getting extra f2py_options that are specific to\n # a given fortran compiler.\n for ext in self.distribution.ext_modules:\n ext.sources = self.f2py_sources(ext.sources,ext)\n self.fortran_sources_to_flib(ext)\n # run()\n\n def f2py_sources (self, sources, ext):\n\n \"\"\" Walk the list of source files in `sources`, looking for f2py\n interface (.pyf) files. Run f2py on all that are found, and\n return the modified `sources` list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains no .pyf files, then create a temporary\n .pyf file from the Fortran files found in 'sources'.\n \"\"\"\n try:\n import f2py2e\n if not hasattr(self,'_f2py_sources_been_here'):\n self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))\n setattr(self,'_f2py_sources_been_here',1)\n except ImportError:\n print sys.exc_value\n raise F2pyNotFoundError,F2pyNotFoundError.__doc__\n # f2py generates the following files for an extension module\n # with a name :\n # module.c\n # -f2pywrappers.f [occasionally]\n # -f2pywrappers2.f90 [occasionally]\n # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains definitions for exactly\n # one extension module.\n\n target_dir = self.build_dir\n \n new_sources = []\n f2py_sources = []\n fortran_sources = []\n f2py_targets = {}\n f2py_fortran_targets = {}\n target_ext = 'module.c'\n fortran_target_ext = '-f2pywrappers.f'\n fortran90_target_ext = '-f2pywrappers2.f90'\n ext_name = string.split(ext.name,'.')[-1]\n\n for source in sources:\n (base, source_ext) = os.path.splitext(source)\n (source_dir, base) = os.path.split(base)\n if source_ext == \".pyf\": # f2py interface file\n # get extension module name\n f = open(source)\n f_readlines = getattr(f,'xreadlines',f.readlines)\n for line in f_readlines():\n m = module_name_re(line)\n if m:\n if user_module_name_re(line): # skip *__user__* names\n continue\n base = m.group('name')\n break\n f.close()\n if ext.name == 'untitled':\n ext.name = base\n if base != ext_name:\n # XXX: Should we do here more than just warn?\n self.warn(red_text('%s provides %s but this extension is %s' \\\n % (source,`base`,`ext_name`)))\n target_file = os.path.join(target_dir,base+target_ext)\n fortran_target_file = os.path.join(target_dir,\n base+fortran_target_ext)\n fortran90_target_file = os.path.join(target_dir,\n base+fortran90_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = [fortran_target_file,\n fortran90_target_file]\n elif fortran_ext_re(source_ext):\n fortran_sources.append(source) \n else:\n new_sources.append(source)\n\n if not (f2py_sources or fortran_sources):\n return new_sources\n\n # make sure the target dir exists\n from distutils.dir_util import mkpath\n mkpath(target_dir)\n\n if not f2py_sources:\n # creating a temporary pyf file from fortran sources\n pyf_target = os.path.join(target_dir,ext_name+'.pyf')\n pyf_target_file = os.path.join(target_dir,ext_name+target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_opts2.append('--quiet')\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(fortran_sources + f2py_opts2,' ')))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\n pyf_fortran_target_file = os.path.join(target_dir,\n ext_name+fortran_target_ext)\n pyf_fortran90_target_file = os.path.join(target_dir,\n ext_name+fortran90_target_ext)\n f2py_sources.append(pyf_target)\n f2py_targets[pyf_target] = pyf_target_file\n f2py_fortran_targets[pyf_target] = [pyf_fortran_target_file,\n pyf_fortran90_target_file]\n\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn(red_text('Only one .pyf file can be used per Extension'\\\n ' but got %s.' % (len(f2py_sources))))\n\n # a bit of a hack, but I think it'll work. Just include one of\n # the fortranobject.c files that was copied into most \n d = os.path.dirname(f2py2e.__file__)\n new_sources.append(os.path.join(d,'src','fortranobject.c'))\n ext.include_dirs.append(os.path.join(d,'src'))\n\n if ext.f2py_options != self.f2py_options:\n f2py_options = ext.f2py_options + self.f2py_options\n else:\n f2py_options = self.f2py_options[:]\n if not self.verbose:\n if f2py2e.f2py2e.f2py_version>'2.21.184-1312':\n f2py_options.append('--quiet')\n for source in f2py_sources:\n target = f2py_targets[source]\n if newer(source,target) or self.force:\n self.announce(yellow_text(\"f2py %s\" % \\\n string.join(f2py_options+[source],' ')))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n for fortran_target in f2py_fortran_targets[source]:\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name+'_f2py'\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {}\n fortran_libraries.append((name,flib))\n\n flib.setdefault('sources',[]).extend(f_files)\n flib.setdefault('define_macros',[]).extend(ext.define_macros)\n flib.setdefault('undef_macros',[]).extend(ext.undef_macros)\n flib.setdefault('include_dirs',[]).extend(ext.include_dirs)\n \n# class run_f2py\n", "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": 101, "complexity": 28, "token_count": 701, "parameters": [ "self", "sources", "ext" ], "start_line": 74, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 198, "parameters": [ "self", "ext" ], "start_line": 211, "end_line": 247, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "methods_before": [ { "name": "initialize_options", "long_name": "initialize_options( self )", "filename": "run_f2py.py", "nloc": 6, "complexity": 1, "token_count": 31, "parameters": [ "self" ], "start_line": 38, "end_line": 43, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "finalize_options", "long_name": "finalize_options( self )", "filename": "run_f2py.py", "nloc": 9, "complexity": 3, "token_count": 69, "parameters": [ "self" ], "start_line": 47, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "run", "long_name": "run( self )", "filename": "run_f2py.py", "nloc": 5, "complexity": 3, "token_count": 43, "parameters": [ "self" ], "start_line": 61, "end_line": 70, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 101, "complexity": 28, "token_count": 722, "parameters": [ "self", "sources", "ext" ], "start_line": 73, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 1 }, { "name": "fortran_sources_to_flib", "long_name": "fortran_sources_to_flib( self , ext )", "filename": "run_f2py.py", "nloc": 28, "complexity": 8, "token_count": 198, "parameters": [ "self", "ext" ], "start_line": 210, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 37, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "f2py_sources", "long_name": "f2py_sources( self , sources , ext )", "filename": "run_f2py.py", "nloc": 101, "complexity": 28, "token_count": 701, "parameters": [ "self", "sources", "ext" ], "start_line": 74, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 134, "top_nesting_level": 1 } ], "nloc": 176, "complexity": 43, "token_count": 1183, "diff_parsed": { "added": [ "from scipy_distutils import log", " log.info('using F2PY %s', f2py2e.f2py2e.f2py_version)", " log.warn('%s provides %s but this extension is %s',", " source,`base`,`ext_name`)", " log.debug(\"f2py %s\",", " string.join(fortran_sources + f2py_opts2,' '))", " log.warn('Only one .pyf file can be used per Extension'\\", " ' but got %s.', len(f2py_sources))", " log.debug(\"f2py %s\",", " string.join(f2py_options+[source],' '))" ], "deleted": [ " self.announce('using F2PY %s' % (f2py2e.f2py2e.f2py_version))", " self.warn(red_text('%s provides %s but this extension is %s' \\", " % (source,`base`,`ext_name`)))", " self.announce(yellow_text(\"f2py %s\" % \\", " string.join(fortran_sources + f2py_opts2,' ')))", " self.warn(red_text('Only one .pyf file can be used per Extension'\\", " ' but got %s.' % (len(f2py_sources))))", " self.announce(yellow_text(\"f2py %s\" % \\", " string.join(f2py_options+[source],' ')))" ] } }, { "old_path": "scipy_distutils/command/sdist.py", "new_path": "scipy_distutils/command/sdist.py", "filename": "sdist.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -1,5 +1,6 @@\n from distutils.command.sdist import *\n from distutils.command.sdist import sdist as old_sdist\n+from scipy_distutils import log\n \n import sys, os\n mod = __import__(__name__)\n@@ -50,15 +51,15 @@ def make_release_tree (self, base_dir, files):\n msg = \"copying files to %s...\" % base_dir\n \n if not files:\n- self.warn(\"no files to distribute -- empty manifest?\")\n+ log.warn(\"no files to distribute -- empty manifest?\")\n else:\n- self.announce(msg)\n+ log.info(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n- self.warn(\"'%s' not a regular file -- skipping\" % file)\n+ log.warn(\"'%s' not a regular file -- skipping\", file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n", "added_lines": 4, "deleted_lines": 3, "source_code": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\nfrom scipy_distutils import log\n\nimport sys, os\nmod = __import__(__name__)\nsys.path.append(os.path.dirname(mod.__file__))\nimport line_endings\nsys.path = sys.path[:-1]\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n \n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n log.warn(\"no files to distribute -- empty manifest?\")\n else:\n log.info(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n log.warn(\"'%s' not a regular file -- skipping\", file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\n def make_distribution (self):\n \"\"\" Overridden to force a build of zip files to have Windows line \n endings and tar balls to have Unix line endings.\n \n Create the source distribution(s). First, we create the release\n tree with 'make_release_tree()'; then, we create all required\n archive files (according to 'self.formats') from the release tree.\n Finally, we clean up by blowing away the release tree (unless\n 'self.keep_temp' is true). The list of archive files created is\n stored so it can be retrieved later by 'get_archive_files()'.\n \"\"\"\n # Don't warn about missing meta-data here -- should be (and is!)\n # done elsewhere.\n base_dir = self.distribution.get_fullname()\n base_name = os.path.join(self.dist_dir, base_dir)\n files = map(os.path.abspath, self.filelist.files)\n self.make_release_tree(base_dir, files)\n archive_files = [] # remember names of files we create\n for fmt in self.formats: \n self.convert_line_endings(base_dir,fmt)\n file = self.make_archive(base_name, fmt, base_dir=base_dir)\n archive_files.append(file)\n \n self.archive_files = archive_files\n\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n\n def convert_line_endings(self,base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n if fmt == 'gztar':\n line_endings.dos2unix_dir(base_dir)\n elif fmt == 'zip':\n line_endings.unix2dos_dir(base_dir)\n \ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [string.replace(file,base,'') for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return ''\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d \n", "source_code_before": "from distutils.command.sdist import *\nfrom distutils.command.sdist import sdist as old_sdist\n\nimport sys, os\nmod = __import__(__name__)\nsys.path.append(os.path.dirname(mod.__file__))\nimport line_endings\nsys.path = sys.path[:-1]\n\nclass sdist(old_sdist):\n def add_defaults (self):\n old_sdist.add_defaults(self)\n if self.distribution.has_f_libraries():\n build_flib = self.get_finalized_command('build_flib')\n self.filelist.extend(build_flib.get_source_files())\n\n if self.distribution.has_data_files():\n self.filelist.extend(self.distribution.get_data_files())\n\n def make_release_tree (self, base_dir, files):\n \"\"\"Create the directory tree that will become the source\n distribution archive. All directories implied by the filenames in\n 'files' are created under 'base_dir', and then we hard link or copy\n (if hard linking is unavailable) those files into place.\n Essentially, this duplicates the developer's source tree, but in a\n directory named after the distribution, containing only the files\n to be distributed.\n \"\"\"\n # Create all the directories under 'base_dir' necessary to\n # put 'files' there; the 'mkpath()' is just so we don't die\n # if the manifest happens to be empty.\n \n dest_files = remove_common_base(files)\n self.mkpath(base_dir)\n dir_util.create_tree(base_dir, dest_files,\n verbose=self.verbose, dry_run=self.dry_run)\n\n # And walk over the list of files, either making a hard link (if\n # os.link exists) to each one that doesn't already exist in its\n # corresponding location under 'base_dir', or copying each file\n # that's out-of-date in 'base_dir'. (Usually, all files will be\n # out-of-date, because by default we blow away 'base_dir' when\n # we're done making the distribution archives.)\n \n if hasattr(os, 'link'): # can make hard links on this system\n link = 'hard'\n msg = \"making hard links in %s...\" % base_dir\n else: # nope, have to copy\n link = None\n msg = \"copying files to %s...\" % base_dir\n\n if not files:\n self.warn(\"no files to distribute -- empty manifest?\")\n else:\n self.announce(msg)\n \n dest_files = [os.path.join(base_dir,file) for file in dest_files]\n file_pairs = zip(files,dest_files) \n for file,dest in file_pairs:\n if not os.path.isfile(file):\n self.warn(\"'%s' not a regular file -- skipping\" % file)\n else:\n #ej: here is the only change -- made to handle\n # absolute paths to files as well as relative\n #par,file_name = os.path.split(file)\n #dest = os.path.join(base_dir, file_name)\n # end of changes\n \n # old code\n #dest = os.path.join(base_dir, file)\n #end old code\n self.copy_file(file, dest, link=link)\n\n self.distribution.metadata.write_pkg_info(base_dir)\n #raise ValueError\n # make_release_tree ()\n\n def make_distribution (self):\n \"\"\" Overridden to force a build of zip files to have Windows line \n endings and tar balls to have Unix line endings.\n \n Create the source distribution(s). First, we create the release\n tree with 'make_release_tree()'; then, we create all required\n archive files (according to 'self.formats') from the release tree.\n Finally, we clean up by blowing away the release tree (unless\n 'self.keep_temp' is true). The list of archive files created is\n stored so it can be retrieved later by 'get_archive_files()'.\n \"\"\"\n # Don't warn about missing meta-data here -- should be (and is!)\n # done elsewhere.\n base_dir = self.distribution.get_fullname()\n base_name = os.path.join(self.dist_dir, base_dir)\n files = map(os.path.abspath, self.filelist.files)\n self.make_release_tree(base_dir, files)\n archive_files = [] # remember names of files we create\n for fmt in self.formats: \n self.convert_line_endings(base_dir,fmt)\n file = self.make_archive(base_name, fmt, base_dir=base_dir)\n archive_files.append(file)\n \n self.archive_files = archive_files\n\n if not self.keep_temp:\n dir_util.remove_tree(base_dir, self.verbose, self.dry_run)\n\n def convert_line_endings(self,base_dir,fmt):\n \"\"\" Convert all text files in a tree to have correct line endings.\n \n gztar --> \\n (Unix style)\n zip --> \\r\\n (Windows style)\n \"\"\"\n if fmt == 'gztar':\n line_endings.dos2unix_dir(base_dir)\n elif fmt == 'zip':\n line_endings.unix2dos_dir(base_dir)\n \ndef remove_common_base(files):\n \"\"\" Remove the greatest common base directory from all the\n absolute file paths in the list of files. files in the\n list without a parent directory are not affected.\n \"\"\"\n rel_files = filter(lambda x: not os.path.dirname(x),files)\n abs_files = filter(os.path.dirname,files)\n base = find_common_base(abs_files)\n # will leave files with local path unaffected\n # and maintains original file order\n results = [string.replace(file,base,'') for file in files]\n return results\n\ndef find_common_base(files):\n \"\"\" Find the \"greatest common base directory\" of a list of files\n \"\"\"\n if not files:\n return ''\n result = ''\n d,f = os.path.split(files[0])\n keep_looking = 1 \n while(keep_looking and d):\n keep_looking = 0\n for file in files:\n if string.find('start'+file,'start'+d) == -1:\n keep_looking = 1\n break\n if keep_looking:\n d,f = os.path.split(d)\n else:\n result = d\n \n if d: \n d = os.path.join(d,'')\n return d \n", "methods": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 12, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 21, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 1 }, { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 13, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 79, "end_line": 105, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( self , base_dir , fmt )", "filename": "sdist.py", "nloc": 5, "complexity": 3, "token_count": 32, "parameters": [ "self", "base_dir", "fmt" ], "start_line": 107, "end_line": 116, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "files" ], "start_line": 118, "end_line": 129, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 131, "end_line": 152, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "methods_before": [ { "name": "add_defaults", "long_name": "add_defaults( self )", "filename": "sdist.py", "nloc": 7, "complexity": 3, "token_count": 63, "parameters": [ "self" ], "start_line": 11, "end_line": 18, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 1 }, { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 20, "end_line": 74, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 1 }, { "name": "make_distribution", "long_name": "make_distribution( self )", "filename": "sdist.py", "nloc": 13, "complexity": 3, "token_count": 117, "parameters": [ "self" ], "start_line": 78, "end_line": 104, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "convert_line_endings", "long_name": "convert_line_endings( self , base_dir , fmt )", "filename": "sdist.py", "nloc": 5, "complexity": 3, "token_count": 32, "parameters": [ "self", "base_dir", "fmt" ], "start_line": 106, "end_line": 115, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 1 }, { "name": "remove_common_base", "long_name": "remove_common_base( files )", "filename": "sdist.py", "nloc": 6, "complexity": 2, "token_count": 63, "parameters": [ "files" ], "start_line": 117, "end_line": 128, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "find_common_base", "long_name": "find_common_base( files )", "filename": "sdist.py", "nloc": 19, "complexity": 8, "token_count": 106, "parameters": [ "files" ], "start_line": 130, "end_line": 151, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "make_release_tree", "long_name": "make_release_tree( self , base_dir , files )", "filename": "sdist.py", "nloc": 23, "complexity": 6, "token_count": 162, "parameters": [ "self", "base_dir", "files" ], "start_line": 21, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 55, "top_nesting_level": 1 } ], "nloc": 82, "complexity": 25, "token_count": 618, "diff_parsed": { "added": [ "from scipy_distutils import log", " log.warn(\"no files to distribute -- empty manifest?\")", " log.info(msg)", " log.warn(\"'%s' not a regular file -- skipping\", file)" ], "deleted": [ " self.warn(\"no files to distribute -- empty manifest?\")", " self.announce(msg)", " self.warn(\"'%s' not a regular file -- skipping\" % file)" ] } }, { "old_path": null, "new_path": "scipy_distutils/log.py", "filename": "log.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,82 @@\n+# Python 2.3 distutils.log backported to Python 2.1.x, 2.2.x\n+\n+import sys\n+\n+if sys.version[:3]>='2.3':\n+ from distutils.log import *\n+ from distutils.log import Log as old_Log\n+ from distutils.log import _global_log\n+ class Log(old_Log):\n+ def _log(self, level, msg, args):\n+ if level>= self.threshold:\n+ print _global_color_map[level](msg % args)\n+ sys.stdout.flush()\n+ _global_log.__class__ = Log\n+\n+else:\n+ exec \"\"\"\n+# Here follows (slightly) modified copy of Python 2.3 distutils/log.py\n+\n+DEBUG = 1\n+INFO = 2\n+WARN = 3\n+ERROR = 4\n+FATAL = 5\n+class Log:\n+\n+ def __init__(self, threshold=WARN):\n+ self.threshold = threshold\n+\n+ def _log(self, level, msg, args):\n+ if level >= self.threshold:\n+ print _global_color_map[level](msg % args)\n+ sys.stdout.flush()\n+\n+ def log(self, level, msg, *args):\n+ self._log(level, msg, args)\n+\n+ def debug(self, msg, *args):\n+ self._log(DEBUG, msg, args)\n+ \n+ def info(self, msg, *args):\n+ self._log(INFO, msg, args)\n+ \n+ def warn(self, msg, *args):\n+ self._log(WARN, red_text(msg), args)\n+ \n+ def error(self, msg, *args):\n+ self._log(ERROR, msg, args)\n+ \n+ def fatal(self, msg, *args):\n+ self._log(FATAL, msg, args)\n+\n+_global_log = Log()\n+log = _global_log.log\n+debug = _global_log.debug\n+info = _global_log.info\n+warn = _global_log.warn\n+error = _global_log.error\n+fatal = _global_log.fatal\n+\n+def set_threshold(level):\n+ _global_log.threshold = level\n+\n+def set_verbosity(v):\n+ if v <= 0:\n+ set_threshold(WARN)\n+ elif v == 1:\n+ set_threshold(INFO)\n+ elif v >= 2:\n+ set_threshold(DEBUG)\n+\"\"\"\n+\n+from misc_util import red_text, yellow_text, cyan_text\n+_global_color_map = {\n+ DEBUG:cyan_text,\n+ INFO:yellow_text,\n+ WARN:red_text,\n+ ERROR:red_text,\n+ FATAL:red_text\n+}\n+\n+set_verbosity(2)\n", "added_lines": 82, "deleted_lines": 0, "source_code": "# Python 2.3 distutils.log backported to Python 2.1.x, 2.2.x\n\nimport sys\n\nif sys.version[:3]>='2.3':\n from distutils.log import *\n from distutils.log import Log as old_Log\n from distutils.log import _global_log\n class Log(old_Log):\n def _log(self, level, msg, args):\n if level>= self.threshold:\n print _global_color_map[level](msg % args)\n sys.stdout.flush()\n _global_log.__class__ = Log\n\nelse:\n exec \"\"\"\n# Here follows (slightly) modified copy of Python 2.3 distutils/log.py\n\nDEBUG = 1\nINFO = 2\nWARN = 3\nERROR = 4\nFATAL = 5\nclass Log:\n\n def __init__(self, threshold=WARN):\n self.threshold = threshold\n\n def _log(self, level, msg, args):\n if level >= self.threshold:\n print _global_color_map[level](msg % args)\n sys.stdout.flush()\n\n def log(self, level, msg, *args):\n self._log(level, msg, args)\n\n def debug(self, msg, *args):\n self._log(DEBUG, msg, args)\n \n def info(self, msg, *args):\n self._log(INFO, msg, args)\n \n def warn(self, msg, *args):\n self._log(WARN, red_text(msg), args)\n \n def error(self, msg, *args):\n self._log(ERROR, msg, args)\n \n def fatal(self, msg, *args):\n self._log(FATAL, msg, args)\n\n_global_log = Log()\nlog = _global_log.log\ndebug = _global_log.debug\ninfo = _global_log.info\nwarn = _global_log.warn\nerror = _global_log.error\nfatal = _global_log.fatal\n\ndef set_threshold(level):\n _global_log.threshold = level\n\ndef set_verbosity(v):\n if v <= 0:\n set_threshold(WARN)\n elif v == 1:\n set_threshold(INFO)\n elif v >= 2:\n set_threshold(DEBUG)\n\"\"\"\n\nfrom misc_util import red_text, yellow_text, cyan_text\n_global_color_map = {\n DEBUG:cyan_text,\n INFO:yellow_text,\n WARN:red_text,\n ERROR:red_text,\n FATAL:red_text\n}\n\nset_verbosity(2)\n", "source_code_before": null, "methods": [ { "name": "_log", "long_name": "_log( self , level , msg , args )", "filename": "log.py", "nloc": 4, "complexity": 2, "token_count": 35, "parameters": [ "self", "level", "msg", "args" ], "start_line": 10, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "methods_before": [], "changed_methods": [ { "name": "_log", "long_name": "_log( self , level , msg , args )", "filename": "log.py", "nloc": 4, "complexity": 2, "token_count": 35, "parameters": [ "self", "level", "msg", "args" ], "start_line": 10, "end_line": 13, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 2 } ], "nloc": 76, "complexity": 2, "token_count": 119, "diff_parsed": { "added": [ "# Python 2.3 distutils.log backported to Python 2.1.x, 2.2.x", "", "import sys", "", "if sys.version[:3]>='2.3':", " from distutils.log import *", " from distutils.log import Log as old_Log", " from distutils.log import _global_log", " class Log(old_Log):", " def _log(self, level, msg, args):", " if level>= self.threshold:", " print _global_color_map[level](msg % args)", " sys.stdout.flush()", " _global_log.__class__ = Log", "", "else:", " exec \"\"\"", "# Here follows (slightly) modified copy of Python 2.3 distutils/log.py", "", "DEBUG = 1", "INFO = 2", "WARN = 3", "ERROR = 4", "FATAL = 5", "class Log:", "", " def __init__(self, threshold=WARN):", " self.threshold = threshold", "", " def _log(self, level, msg, args):", " if level >= self.threshold:", " print _global_color_map[level](msg % args)", " sys.stdout.flush()", "", " def log(self, level, msg, *args):", " self._log(level, msg, args)", "", " def debug(self, msg, *args):", " self._log(DEBUG, msg, args)", "", " def info(self, msg, *args):", " self._log(INFO, msg, args)", "", " def warn(self, msg, *args):", " self._log(WARN, red_text(msg), args)", "", " def error(self, msg, *args):", " self._log(ERROR, msg, args)", "", " def fatal(self, msg, *args):", " self._log(FATAL, msg, args)", "", "_global_log = Log()", "log = _global_log.log", "debug = _global_log.debug", "info = _global_log.info", "warn = _global_log.warn", "error = _global_log.error", "fatal = _global_log.fatal", "", "def set_threshold(level):", " _global_log.threshold = level", "", "def set_verbosity(v):", " if v <= 0:", " set_threshold(WARN)", " elif v == 1:", " set_threshold(INFO)", " elif v >= 2:", " set_threshold(DEBUG)", "\"\"\"", "", "from misc_util import red_text, yellow_text, cyan_text", "_global_color_map = {", " DEBUG:cyan_text,", " INFO:yellow_text,", " WARN:red_text,", " ERROR:red_text,", " FATAL:red_text", "}", "", "set_verbosity(2)" ], "deleted": [] } } ] }, { "hash": "c9016bbbc986f076a2c5f28aa251e395135ed62d", "msg": "Showing system commands with log.info", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-19T13:14:00+00:00", "author_timezone": 0, "committer_date": "2003-09-19T13:14:00+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "3d0d2999801160151f4d9aa6523514e0c376d183" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 3, "insertions": 3, "lines": 6, "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": "@@ -480,7 +480,7 @@ def f_compile(self,compiler,switches, source_files,\n module_switch + \\\n self.compile_switch + source + \\\n self.object_switch + object\n- log.debug(cmd)\n+ log.info(cmd)\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError,\\\n@@ -528,7 +528,7 @@ def create_static_lib(self, object_files, library_name,\n objects = string.join(object_files)\n if objects:\n cmd = '%s%s %s' % (self.lib_ar,lib_file,objects)\n- log.debug(cmd)\n+ log.info(cmd)\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n@@ -536,7 +536,7 @@ def create_static_lib(self, object_files, library_name,\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.debug(cmd)\n+ log.info(cmd)\n failure = os.system(cmd)\n if failure:\n raise FortranBuildError,\\\n", "added_lines": 3, "deleted_lines": 3, "source_code": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import 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\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 if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n 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 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 #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "source_code_before": "\"\"\" Implements the build_flib command which should go into Distutils\n at some point.\n \n Note:\n Right now, we're dynamically linking to the Fortran libraries on \n some platforms (Sun for sure). This is fine for local installations\n but a bad thing for redistribution because these libraries won't\n live on any machine that doesn't have a fortran compiler installed.\n It is pretty hard (impossible?) to get gcc to pass the right compiler\n flags on Sun to get the linker to use static libs for the fortran\n stuff. Investigate further...\n\nBugs:\n *** Options -e and -x have no effect when used with --help-compiler\n options. E.g. \n ./setup.py build_flib --help-compiler -e g77-3.0\n finds g77-2.95.\n How to extract these options inside the show_compilers function?\n *** compiler.is_available() method may not work correctly on nt\n because of lack of knowledge how to get exit status in\n run_command function. However, it may give reasonable results\n based on a version string.\n *** Some vendors provide different compilers for F77 and F90\n compilations. Currently, checking the availability of these\n compilers is based on only checking the availability of the\n corresponding F77 compiler. If it exists, then F90 is assumed\n to exist also.\n *** F compiler from Fortran Compiler is _not_ supported, though it\n is defined below. The reasons is that this F95 compiler is\n incomplete: it does not support external procedures\n that are needed to facilitate calling F90 module routines\n from C and subsequently from Python. See also\n http://cens.ioc.ee/pipermail/f2py-users/2002-May/000265.html\n\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Forte\n (Sun)\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n F [unsupported]\n Lahey\n PG\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util, distutils.file_util\nimport os,sys,string,glob\nimport commands,re\nfrom types import *\nfrom distutils.ccompiler import CCompiler,gen_preprocess_options\nfrom distutils.command.build_clib import build_clib\nfrom distutils.errors import *\nfrom distutils.version import LooseVersion\nfrom scipy_distutils.misc_util import 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\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 if sys.platform=='win32':\n if fc.vendor in ['Compaq']:\n set_windows_compiler('msvc')\n else:\n set_windows_compiler('mingw32')\n\n self.fcompiler = fc\n if self.has_f_libraries():\n self.fortran_libraries = self.distribution.fortran_libraries\n self.check_library_list(self.fortran_libraries)\n \n # finalize_options()\n\n def has_f_libraries(self):\n return self.distribution.fortran_libraries \\\n and len(self.distribution.fortran_libraries) > 0\n\n def run (self):\n if not self.has_f_libraries():\n return\n self.build_libraries(self.fortran_libraries)\n\n # run ()\n\n def has_f_library(self,name):\n if self.has_f_libraries():\n # If self.fortran_libraries is None at this point\n # then it means that build_flib was called before\n # build. Always call build before build_flib.\n for (lib_name, build_info) in self.fortran_libraries:\n if lib_name == name:\n return 1\n \n def get_library_names(self, name=None):\n if not self.has_f_libraries():\n return None\n\n lib_names = []\n\n if name is None:\n for (lib_name, build_info) in self.fortran_libraries:\n lib_names.append(lib_name)\n\n if self.fcompiler is not None:\n lib_names.extend(self.fcompiler.get_libraries())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n for n in build_info.get('libraries',[]):\n lib_names.append(n)\n #XXX: how to catch recursive calls here?\n lib_names.extend(self.get_library_names(n))\n break\n return lib_names\n\n def get_fcompiler_library_names(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_libraries()\n return []\n\n def get_fcompiler_library_dirs(self):\n #if not self.has_f_libraries():\n # return None\n if self.fcompiler is not None:\n return self.fcompiler.get_library_dirs()\n return []\n\n # get_library_names ()\n\n def get_library_dirs(self, name=None):\n if not self.has_f_libraries():\n return []\n\n lib_dirs = [] \n\n if name is None:\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_library_dirs())\n else:\n for (lib_name, build_info) in self.fortran_libraries:\n if name != lib_name: continue\n lib_dirs.extend(build_info.get('library_dirs',[]))\n for n in build_info.get('libraries',[]):\n lib_dirs.extend(self.get_library_dirs(n))\n break\n\n return lib_dirs\n\n # get_library_dirs ()\n\n def get_runtime_library_dirs(self):\n #if not self.has_f_libraries():\n # return []\n\n lib_dirs = []\n\n if self.fcompiler is not None:\n lib_dirs.extend(self.fcompiler.get_runtime_library_dirs())\n \n return lib_dirs\n\n # get_library_dirs ()\n\n def get_source_files (self):\n if not self.has_f_libraries():\n return []\n\n self.check_library_list(self.fortran_libraries)\n filenames = []\n\n # Gets source files specified \n for ext in self.fortran_libraries:\n filenames.extend(ext[1]['sources'])\n\n return filenames \n \n def build_libraries (self, fortran_libraries):\n \n fcompiler = self.fcompiler\n \n for (lib_name, build_info) in fortran_libraries:\n 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.debug(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.debug(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.debug(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 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 #XXX: is this really necessary???\n from distutils.msvccompiler import find_exe\n self.lib_ar = find_exe(\"lib.exe\", self.version) + ' /OUT:'\n\n switches = ' /nologo /MD /W1 /iface:cref /iface=nomixed_str_len_arg '\n #switches += ' /libs:dll /threads '\n debug = ' '\n #debug = ' /debug:full /dbglibs '\n \n self.f77_switches = ' /f77rtl /fixed ' + switches\n self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n self.f90_fixed_switch = ' /fixed '\n\n def get_opt(self):\n # XXX: use also /architecture, see gnu_fortran_compiler\n return ' /Ox '\n\n# fperez\n# Code copied from Pierre Schnizer's tutorial, slightly modified. Fixed a\n# bug in the version matching regexp and added verbose flag.\n# /fperez\nclass lahey_fortran_compiler(fortran_compiler_base):\n vendor = 'Lahey'\n ver_match = r'Lahey/Fujitsu Fortran 95 Compiler Release (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None,verbose=0):\n fortran_compiler_base.__init__(self,verbose=verbose)\n \n if fc is None:\n fc = 'lf95'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ''\n debug = ' -g --chk --chkglobal '\n self.f77_switches = self.f90_switches = switches\n self.f77_switches = self.f77_switches + ' --fix '\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n \n self.ver_cmd = self.f77_compiler+' --version'\n try:\n dir = os.environ['LAHEY']\n self.library_dirs = [os.path.join(dir,'lib')]\n except KeyError:\n self.library_dirs = []\n\n self.libraries = ['fj9f6', 'fj9i6', 'fj9ipp', 'fj9e6']\n\n def get_opt(self):\n opt = ' -O'\n return opt\n\n def get_linker_so(self):\n return [self.f77_compiler ,'--shared']\n\n# http://www.pgroup.com\nclass pgroup_fortran_compiler(fortran_compiler_base):\n\n vendor = 'PG' # The Portland Group, Inc \n ver_match = r'\\s*pg(f77|f90|hpf) (?P[\\d.-]+).*'\n\n def __init__(self, fc=None, f90c=None, verbose=0):\n fortran_compiler_base.__init__(self, verbose=verbose)\n\n if fc is None:\n fc = 'pgf77'\n if f90c is None:\n f90c = 'pgf90'\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -fpic' # linux only\n switches = switches + ' -Minform=inform -Mnosecond_underscore' \n\n self.f77_switches = self.f90_switches = switches\n self.f90_fixed_switch = ' -Mfixed'\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g '\n self.f77_debug = self.f90_debug = debug\n\n if os.name=='posix':\n self.ver_cmd = self.f77_compiler+' -V 2>/dev/null '\n else:\n self.ver_cmd = self.f90_compiler+' -V '\n\n def get_opt(self):\n return ' -fast '\n\n def get_linker_so(self):\n return [self.f90_compiler,\n '-shared', # linux only\n ]\n\n def build_module_switch(self,module_dirs,temp_dir):\n res = ' -module '+temp_dir\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -I' + mod \n res += ' -I '+temp_dir\n return res\n\n\n##############################################################################\n\ndef find_fortran_compiler(vendor=None, fc=None, f90c=None, verbose=0):\n for compiler_class in all_compilers:\n if vendor is not None and vendor != compiler_class.vendor:\n continue\n #print compiler_class\n compiler = compiler_class(fc,f90c,verbose = verbose)\n if compiler.is_available():\n return compiler\n return None\n\nif sys.platform=='win32':\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_visual_fortran_compiler,\n vast_fortran_compiler,\n f_fortran_compiler,\n gnu_fortran_compiler,\n ]\nelse:\n all_compilers = [\n pgroup_fortran_compiler,\n absoft_fortran_compiler,\n mips_fortran_compiler,\n forte_fortran_compiler,\n sun_fortran_compiler,\n intel_ia32_fortran_compiler,\n intel_itanium_fortran_compiler,\n nag_fortran_compiler,\n compaq_fortran_compiler,\n vast_fortran_compiler,\n hpux_fortran_compiler,\n f_fortran_compiler,\n lahey_fortran_compiler,\n gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", "methods": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 101, "end_line": 112, "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": 142, "end_line": 159, "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": 143, "parameters": [ "self" ], "start_line": 163, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "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": 197, "end_line": 200, "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": 204, "end_line": 211, "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": 213, "end_line": 233, "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": 235, "end_line": 240, "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": 242, "end_line": 247, "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": 251, "end_line": 268, "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": 272, "end_line": 281, "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": 285, "end_line": 296, "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": 298, "end_line": 331, "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": 340, "end_line": 345, "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": 355, "end_line": 376, "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": 393, "end_line": 418, "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": 420, "end_line": 449, "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": 451, "end_line": 456, "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": 458, "end_line": 461, "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": 463, "end_line": 491, "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": 495, "end_line": 498, "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": 500, "end_line": 505, "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": 507, "end_line": 511, "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": 513, "end_line": 515, "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": 517, "end_line": 519, "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": 521, "end_line": 522, "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": 524, "end_line": 543, "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": 545, "end_line": 590, "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": 592, "end_line": 600, "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": 602, "end_line": 603, "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": 605, "end_line": 630, "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": 632, "end_line": 633, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 639, "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": 640, "end_line": 645, "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": 647, "end_line": 662, "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": 670, "end_line": 671, "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": 673, "end_line": 678, "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": 686, "end_line": 749, "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": 751, "end_line": 766, "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": 768, "end_line": 769, "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": 802, "end_line": 843, "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": 845, "end_line": 850, "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": 852, "end_line": 870, "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": 875, "end_line": 876, "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": 888, "end_line": 908, "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": 910, "end_line": 930, "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": 932, "end_line": 934, "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": 936, "end_line": 937, "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": 939, "end_line": 949, "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": 956, "end_line": 977, "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": 979, "end_line": 997, "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": 1005, "end_line": 1051, "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": 1053, "end_line": 1115, "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": 1117, "end_line": 1133, "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": 1135, "end_line": 1141, "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": 1143, "end_line": 1151, "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": 1153, "end_line": 1154, "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": 1156, "end_line": 1157, "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": 1168, "end_line": 1197, "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": 1199, "end_line": 1213, "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": 1215, "end_line": 1216, "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": 1218, "end_line": 1227, "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": 1236, "end_line": 1239, "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": 1247, "end_line": 1268, "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": 1270, "end_line": 1272, "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": 1274, "end_line": 1275, "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": 1289, "end_line": 1317, "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": 1323, "end_line": 1324, "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": 1337, "end_line": 1368, "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": 1370, "end_line": 1371, "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": 1379, "end_line": 1403, "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": 1405, "end_line": 1408, "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": 1410, "end_line": 1414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1430, "end_line": 1457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1459, "end_line": 1461, "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": 1471, "end_line": 1496, "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": 1498, "end_line": 1500, "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": 1502, "end_line": 1503, "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": 1511, "end_line": 1536, "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": 1538, "end_line": 1539, "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": 1541, "end_line": 1544, "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": 1546, "end_line": 1552, "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": 1557, "end_line": 1565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "methods_before": [ { "name": "set_windows_compiler", "long_name": "set_windows_compiler( compiler )", "filename": "build_flib.py", "nloc": 7, "complexity": 1, "token_count": 37, "parameters": [ "compiler" ], "start_line": 73, "end_line": 86, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "run_command", "long_name": "run_command( command )", "filename": "build_flib.py", "nloc": 5, "complexity": 1, "token_count": 32, "parameters": [ "command" ], "start_line": 89, "end_line": 94, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "show_compilers", "long_name": "show_compilers( )", "filename": "build_flib.py", "nloc": 12, "complexity": 4, "token_count": 76, "parameters": [], "start_line": 101, "end_line": 112, "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": 142, "end_line": 159, "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": 143, "parameters": [ "self" ], "start_line": 163, "end_line": 189, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 27, "top_nesting_level": 1 }, { "name": "has_f_libraries", "long_name": "has_f_libraries( self )", "filename": "build_flib.py", "nloc": 3, "complexity": 2, "token_count": 23, "parameters": [ "self" ], "start_line": 193, "end_line": 195, "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": 197, "end_line": 200, "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": 204, "end_line": 211, "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": 213, "end_line": 233, "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": 235, "end_line": 240, "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": 242, "end_line": 247, "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": 251, "end_line": 268, "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": 272, "end_line": 281, "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": 285, "end_line": 296, "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": 298, "end_line": 331, "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": 340, "end_line": 345, "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": 355, "end_line": 376, "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": 393, "end_line": 418, "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": 420, "end_line": 449, "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": 451, "end_line": 456, "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": 458, "end_line": 461, "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": 463, "end_line": 491, "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": 495, "end_line": 498, "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": 500, "end_line": 505, "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": 507, "end_line": 511, "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": 513, "end_line": 515, "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": 517, "end_line": 519, "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": 521, "end_line": 522, "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": 524, "end_line": 543, "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": 545, "end_line": 590, "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": 592, "end_line": 600, "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": 602, "end_line": 603, "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": 605, "end_line": 630, "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": 632, "end_line": 633, "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": 634, "end_line": 635, "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": 636, "end_line": 637, "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": 638, "end_line": 639, "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": 640, "end_line": 645, "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": 647, "end_line": 662, "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": 670, "end_line": 671, "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": 673, "end_line": 678, "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": 686, "end_line": 749, "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": 751, "end_line": 766, "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": 768, "end_line": 769, "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": 802, "end_line": 843, "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": 845, "end_line": 850, "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": 852, "end_line": 870, "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": 875, "end_line": 876, "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": 888, "end_line": 908, "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": 910, "end_line": 930, "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": 932, "end_line": 934, "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": 936, "end_line": 937, "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": 939, "end_line": 949, "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": 956, "end_line": 977, "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": 979, "end_line": 997, "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": 1005, "end_line": 1051, "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": 1053, "end_line": 1115, "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": 1117, "end_line": 1133, "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": 1135, "end_line": 1141, "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": 1143, "end_line": 1151, "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": 1153, "end_line": 1154, "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": 1156, "end_line": 1157, "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": 1168, "end_line": 1197, "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": 1199, "end_line": 1213, "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": 1215, "end_line": 1216, "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": 1218, "end_line": 1227, "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": 1236, "end_line": 1239, "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": 1247, "end_line": 1268, "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": 1270, "end_line": 1272, "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": 1274, "end_line": 1275, "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": 1289, "end_line": 1317, "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": 1323, "end_line": 1324, "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": 1337, "end_line": 1368, "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": 1370, "end_line": 1371, "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": 1379, "end_line": 1403, "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": 1405, "end_line": 1408, "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": 1410, "end_line": 1414, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__init__", "long_name": "__init__( self , fc = None , f90c = None , verbose = 0 )", "filename": "build_flib.py", "nloc": 19, "complexity": 4, "token_count": 134, "parameters": [ "self", "fc", "f90c", "verbose" ], "start_line": 1430, "end_line": 1457, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 28, "top_nesting_level": 1 }, { "name": "get_opt", "long_name": "get_opt( self )", "filename": "build_flib.py", "nloc": 2, "complexity": 1, "token_count": 7, "parameters": [ "self" ], "start_line": 1459, "end_line": 1461, "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": 1471, "end_line": 1496, "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": 1498, "end_line": 1500, "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": 1502, "end_line": 1503, "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": 1511, "end_line": 1536, "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": 1538, "end_line": 1539, "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": 1541, "end_line": 1544, "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": 1546, "end_line": 1552, "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": 1557, "end_line": 1565, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 0 } ], "changed_methods": [ { "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": 524, "end_line": 543, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "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": 463, "end_line": 491, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 29, "top_nesting_level": 1 } ], "nloc": 1169, "complexity": 306, "token_count": 6824, "diff_parsed": { "added": [ " log.info(cmd)", " log.info(cmd)", " log.info(cmd)" ], "deleted": [ " log.debug(cmd)", " log.debug(cmd)", " log.debug(cmd)" ] } } ] }, { "hash": "c16960ea4bbba55bec719b019e3e1014984e457b", "msg": "Added fortran utility functions to scipy_base as part of f2py demo.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-19T21:08:51+00:00", "author_timezone": 0, "committer_date": "2003-09-19T21:08:51+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c9016bbbc986f076a2c5f28aa251e395135ed62d" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 2, "insertions": 150, "lines": 152, "files": 4, "dmm_unit_size": 0.024390243902439025, "dmm_unit_complexity": 0.056910569105691054, "dmm_unit_interfacing": 0.6666666666666666, "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": "@@ -5,17 +5,23 @@\n from type_check import ScalarType\n from fastumath import PINF as inf\n import _compiled_base\n+import futil\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']\n+ 'nanargmin','nanmin','sum','find_repeats']\n \n round = Numeric.around\n any = Numeric.sometrue\n all = Numeric.alltrue\n \n+def find_repeats(arr):\n+ \"\"\"Find repeats in arr and return (repeats, repeat_count)\n+ \"\"\" \n+ v1,v2, n = futil.dfreps(arr)\n+ return v1[:n],v2[:n]\n \n # Need this to change array type for low precision values\n def sum(x,axis=0): # could change default axis here\n", "added_lines": 7, "deleted_lines": 1, "source_code": "\nimport types\nimport Numeric\nfrom Numeric import *\nfrom type_check import ScalarType\nfrom fastumath import PINF as inf\nimport _compiled_base\nimport futil\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','find_repeats']\n\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\n\ndef find_repeats(arr):\n \"\"\"Find repeats in arr and return (repeats, repeat_count)\n \"\"\" \n v1,v2, n = futil.dfreps(arr)\n return v1[:n],v2[:n]\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 extract(arr,mask):\n \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(mask)))\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\n \n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()\n", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import *\nfrom type_check import ScalarType\nfrom fastumath import PINF as inf\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']\n\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\n\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 extract(arr,mask):\n \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(mask)))\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\n \n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "find_repeats", "long_name": "find_repeats( arr )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "arr" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "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": 27, "end_line": 31, "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": 34, "end_line": 47, "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": 49, "end_line": 65, "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": 67, "end_line": 72, "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": 74, "end_line": 80, "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": 82, "end_line": 128, "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": 131, "end_line": 139, "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": 141, "end_line": 149, "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": 153, "end_line": 161, "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": 163, "end_line": 171, "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": 173, "end_line": 181, "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": 183, "end_line": 191, "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": 193, "end_line": 205, "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": 208, "end_line": 221, "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": 223, "end_line": 238, "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": 244, "end_line": 248, "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": 240, "end_line": 251, "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": 253, "end_line": 272, "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": 274, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 282, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 287, "end_line": 291, "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": 293, "end_line": 298, "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": 300, "end_line": 305, "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": 307, "end_line": 312, "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": 315, "end_line": 320, "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": 322, "end_line": 327, "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": 329, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 348, "end_line": 350, "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": 352, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 21, "end_line": 25, "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": 28, "end_line": 41, "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": 43, "end_line": 59, "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": 61, "end_line": 66, "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": 68, "end_line": 74, "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": 76, "end_line": 122, "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": 125, "end_line": 133, "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": 135, "end_line": 143, "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": 147, "end_line": 155, "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": 157, "end_line": 165, "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": 167, "end_line": 175, "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": 177, "end_line": 185, "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": 187, "end_line": 199, "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": 202, "end_line": 215, "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": 217, "end_line": 232, "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": 238, "end_line": 242, "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": 234, "end_line": 245, "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": 247, "end_line": 266, "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": 268, "end_line": 274, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 276, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 281, "end_line": 285, "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": 287, "end_line": 292, "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": 294, "end_line": 299, "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": 301, "end_line": 306, "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": 309, "end_line": 314, "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": 316, "end_line": 321, "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": 323, "end_line": 334, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 342, "end_line": 344, "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": 346, "end_line": 348, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "find_repeats", "long_name": "find_repeats( arr )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "arr" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 216, "complexity": 63, "token_count": 1785, "diff_parsed": { "added": [ "import futil", " 'nanargmin','nanmin','sum','find_repeats']", "def find_repeats(arr):", " \"\"\"Find repeats in arr and return (repeats, repeat_count)", " \"\"\"", " v1,v2, n = futil.dfreps(arr)", " return v1[:n],v2[:n]" ], "deleted": [ " 'nanargmin','nanmin','sum']" ] } }, { "old_path": null, "new_path": "scipy_base/futil.f", "filename": "futil.f", "extension": "f", "change_type": "ADD", "diff": "@@ -0,0 +1,136 @@\n+C Sorts an array arr(1:N) into ascending numerical order \n+C using the QuickSort algorithm. On output arr is replaced with its\n+C sorted rearrangement.\n+ SUBROUTINE DQSORT(N,ARR)\n+CF2PY INTENT(IN,OUT,COPY), ARR\n+CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n+ INTEGER N,M,NSTACK\n+ REAL*8 ARR(N)\n+ PARAMETER (M=7, NSTACK=100)\n+ INTEGER I, IR, J, JSTACK, K, L, ISTACK(NSTACK)\n+ REAL*8 A, TEMP\n+\n+ JSTACK = 0\n+ L = 1\n+ IR = N\n+ 1 IF(IR-L.LT.M)THEN\n+ DO J=L+1,IR\n+ A = ARR(J)\n+ DO I = J-1,L,-1\n+ IF (ARR(I).LE.A) GOTO 2\n+ ARR(I+1)=ARR(I)\n+ ENDDO\n+ I = L-1\n+ 2 ARR(I+1) = A\n+ ENDDO\n+ \n+ IF(JSTACK.EQ.0)RETURN\n+ IR=ISTACK(JSTACK)\n+ L=ISTACK(JSTACK-1)\n+ JSTACK = JSTACK - 2\n+ \n+ ELSE\n+ K = (L+IR)/2\n+ TEMP = ARR(K)\n+ ARR(K) = ARR(L+1)\n+ ARR(L+1) = TEMP\n+ IF(ARR(L).GT.ARR(IR))THEN\n+ TEMP = ARR(L)\n+ ARR(L) = ARR(IR)\n+ ARR(IR) = TEMP\n+ ENDIF\n+ IF(ARR(L+1).GT.ARR(IR))THEN\n+ TEMP=ARR(L+1)\n+ ARR(L+1)=ARR(IR)\n+ ARR(IR)=TEMP\n+ ENDIF\n+ IF(ARR(L).GT.ARR(L+1))THEN\n+ TEMP=ARR(L)\n+ ARR(L) = ARR(L+1)\n+ ARR(L+1) = TEMP\n+ ENDIF\n+\n+ I=L+1\n+ J=IR\n+ A=ARR(L+1)\n+ 3 CONTINUE\n+ I=I+1\n+ IF(ARR(I).LT.A)GOTO 3\n+ 4 CONTINUE\n+ J=J-1\n+ IF(ARR(J).GT.A)GOTO 4\n+ IF(J.LT.I)GOTO 5\n+ TEMP = ARR(I)\n+ ARR(I) = ARR(J)\n+ ARR(J) = TEMP\n+ GOTO 3\n+ 5 ARR(L+1) = ARR(J)\n+ ARR(J) = A\n+ JSTACK = JSTACK + 2\n+ IF(JSTACK.GT.NSTACK)RETURN\n+ IF(IR-I+1.GE.J-1)THEN\n+ ISTACK(JSTACK)=IR\n+ ISTACK(JSTACK-1)=I\n+ IR=J-1\n+ ELSE\n+ ISTACK(JSTACK)=J-1\n+ ISTACK(JSTACK-1)=L\n+ L=I\n+ ENDIF\n+ ENDIF\n+ GOTO 1\n+ END\n+\n+C Finds repeated elements of ARR and their occurrence incidence\n+C reporting the result in REPLIST and REPNUM respectively.\n+C NLIST is the number of repeated elements found.\n+C Algorithm first sorts the list and then walks down it\n+C counting repeats as they are found.\n+ SUBROUTINE DFREPS(ARR,N,REPLIST,REPNUM,NLIST)\n+CF2PY INTENT(IN), ARR\n+CF2PY INTENT(OUT), REPLIST\n+CF2PY INTENT(OUT), REPNUM\n+CF2PY INTENT(OUT), NLIST\n+CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n+ REAL*8 REPLIST(N), ARR(N)\n+ REAL*8 LASTVAL\n+ INTEGER REPNUM(N)\n+ INTEGER HOWMANY, REPEAT, IND, NLIST, NNUM\n+\n+ CALL DQSORT(N,ARR)\n+ LASTVAL = ARR(1)\n+ HOWMANY = 0\n+ IND = 2\n+ NNUM = 1\n+ NLIST = 1\n+ REPEAT = 0\n+ DO WHILE(IND.LE.N)\n+ IF(ARR(IND).NE.LASTVAL)THEN\n+ IF (REPEAT.EQ.1)THEN\n+ REPNUM(NNUM)=HOWMANY+1\n+ NNUM=NNUM+1 \n+ REPEAT=0\n+ HOWMANY=0\n+ ENDIF\n+ ELSE\n+ HOWMANY=HOWMANY+1\n+ REPEAT=1\n+ IF(HOWMANY.EQ.1)THEN\n+ REPLIST(NLIST)=ARR(IND)\n+ NLIST=NLIST+1\n+ ENDIF\n+ ENDIF\n+ LASTVAL=ARR(IND)\n+ IND=IND+1\n+ ENDDO\n+ IF(REPEAT.EQ.1)THEN\n+ REPNUM(NNUM)=HOWMANY+1\n+ ENDIF\n+ NLIST = NLIST - 1\n+ END\n+\n+\n+\n+ \n+ \n+ \n", "added_lines": 136, "deleted_lines": 0, "source_code": "C Sorts an array arr(1:N) into ascending numerical order \nC using the QuickSort algorithm. On output arr is replaced with its\nC sorted rearrangement.\n SUBROUTINE DQSORT(N,ARR)\nCF2PY INTENT(IN,OUT,COPY), ARR\nCF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n INTEGER N,M,NSTACK\n REAL*8 ARR(N)\n PARAMETER (M=7, NSTACK=100)\n INTEGER I, IR, J, JSTACK, K, L, ISTACK(NSTACK)\n REAL*8 A, TEMP\n\n JSTACK = 0\n L = 1\n IR = N\n 1 IF(IR-L.LT.M)THEN\n DO J=L+1,IR\n A = ARR(J)\n DO I = J-1,L,-1\n IF (ARR(I).LE.A) GOTO 2\n ARR(I+1)=ARR(I)\n ENDDO\n I = L-1\n 2 ARR(I+1) = A\n ENDDO\n \n IF(JSTACK.EQ.0)RETURN\n IR=ISTACK(JSTACK)\n L=ISTACK(JSTACK-1)\n JSTACK = JSTACK - 2\n \n ELSE\n K = (L+IR)/2\n TEMP = ARR(K)\n ARR(K) = ARR(L+1)\n ARR(L+1) = TEMP\n IF(ARR(L).GT.ARR(IR))THEN\n TEMP = ARR(L)\n ARR(L) = ARR(IR)\n ARR(IR) = TEMP\n ENDIF\n IF(ARR(L+1).GT.ARR(IR))THEN\n TEMP=ARR(L+1)\n ARR(L+1)=ARR(IR)\n ARR(IR)=TEMP\n ENDIF\n IF(ARR(L).GT.ARR(L+1))THEN\n TEMP=ARR(L)\n ARR(L) = ARR(L+1)\n ARR(L+1) = TEMP\n ENDIF\n\n I=L+1\n J=IR\n A=ARR(L+1)\n 3 CONTINUE\n I=I+1\n IF(ARR(I).LT.A)GOTO 3\n 4 CONTINUE\n J=J-1\n IF(ARR(J).GT.A)GOTO 4\n IF(J.LT.I)GOTO 5\n TEMP = ARR(I)\n ARR(I) = ARR(J)\n ARR(J) = TEMP\n GOTO 3\n 5 ARR(L+1) = ARR(J)\n ARR(J) = A\n JSTACK = JSTACK + 2\n IF(JSTACK.GT.NSTACK)RETURN\n IF(IR-I+1.GE.J-1)THEN\n ISTACK(JSTACK)=IR\n ISTACK(JSTACK-1)=I\n IR=J-1\n ELSE\n ISTACK(JSTACK)=J-1\n ISTACK(JSTACK-1)=L\n L=I\n ENDIF\n ENDIF\n GOTO 1\n END\n\nC Finds repeated elements of ARR and their occurrence incidence\nC reporting the result in REPLIST and REPNUM respectively.\nC NLIST is the number of repeated elements found.\nC Algorithm first sorts the list and then walks down it\nC counting repeats as they are found.\n SUBROUTINE DFREPS(ARR,N,REPLIST,REPNUM,NLIST)\nCF2PY INTENT(IN), ARR\nCF2PY INTENT(OUT), REPLIST\nCF2PY INTENT(OUT), REPNUM\nCF2PY INTENT(OUT), NLIST\nCF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n REAL*8 REPLIST(N), ARR(N)\n REAL*8 LASTVAL\n INTEGER REPNUM(N)\n INTEGER HOWMANY, REPEAT, IND, NLIST, NNUM\n\n CALL DQSORT(N,ARR)\n LASTVAL = ARR(1)\n HOWMANY = 0\n IND = 2\n NNUM = 1\n NLIST = 1\n REPEAT = 0\n DO WHILE(IND.LE.N)\n IF(ARR(IND).NE.LASTVAL)THEN\n IF (REPEAT.EQ.1)THEN\n REPNUM(NNUM)=HOWMANY+1\n NNUM=NNUM+1 \n REPEAT=0\n HOWMANY=0\n ENDIF\n ELSE\n HOWMANY=HOWMANY+1\n REPEAT=1\n IF(HOWMANY.EQ.1)THEN\n REPLIST(NLIST)=ARR(IND)\n NLIST=NLIST+1\n ENDIF\n ENDIF\n LASTVAL=ARR(IND)\n IND=IND+1\n ENDDO\n IF(REPEAT.EQ.1)THEN\n REPNUM(NNUM)=HOWMANY+1\n ENDIF\n NLIST = NLIST - 1\n END\n\n\n\n \n \n \n", "source_code_before": null, "methods": [ { "name": "DQSORT", "long_name": "DQSORT( N , ARR )", "filename": "futil.f", "nloc": 75, "complexity": 14, "token_count": 530, "parameters": [ "N", "ARR" ], "start_line": 4, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 79, "top_nesting_level": 0 }, { "name": "DFREPS", "long_name": "DFREPS( ARR , N , REPLIST , REPNUM , NLIST )", "filename": "futil.f", "nloc": 41, "complexity": 6, "token_count": 231, "parameters": [ "ARR", "N", "REPLIST", "REPNUM", "NLIST" ], "start_line": 89, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "DFREPS", "long_name": "DFREPS( ARR , N , REPLIST , REPNUM , NLIST )", "filename": "futil.f", "nloc": 41, "complexity": 6, "token_count": 231, "parameters": [ "ARR", "N", "REPLIST", "REPNUM", "NLIST" ], "start_line": 89, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "DQSORT", "long_name": "DQSORT( N , ARR )", "filename": "futil.f", "nloc": 75, "complexity": 14, "token_count": 530, "parameters": [ "N", "ARR" ], "start_line": 4, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 79, "top_nesting_level": 0 } ], "nloc": 124, "complexity": 20, "token_count": 835, "diff_parsed": { "added": [ "C Sorts an array arr(1:N) into ascending numerical order", "C using the QuickSort algorithm. On output arr is replaced with its", "C sorted rearrangement.", " SUBROUTINE DQSORT(N,ARR)", "CF2PY INTENT(IN,OUT,COPY), ARR", "CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)", " INTEGER N,M,NSTACK", " REAL*8 ARR(N)", " PARAMETER (M=7, NSTACK=100)", " INTEGER I, IR, J, JSTACK, K, L, ISTACK(NSTACK)", " REAL*8 A, TEMP", "", " JSTACK = 0", " L = 1", " IR = N", " 1 IF(IR-L.LT.M)THEN", " DO J=L+1,IR", " A = ARR(J)", " DO I = J-1,L,-1", " IF (ARR(I).LE.A) GOTO 2", " ARR(I+1)=ARR(I)", " ENDDO", " I = L-1", " 2 ARR(I+1) = A", " ENDDO", "", " IF(JSTACK.EQ.0)RETURN", " IR=ISTACK(JSTACK)", " L=ISTACK(JSTACK-1)", " JSTACK = JSTACK - 2", "", " ELSE", " K = (L+IR)/2", " TEMP = ARR(K)", " ARR(K) = ARR(L+1)", " ARR(L+1) = TEMP", " IF(ARR(L).GT.ARR(IR))THEN", " TEMP = ARR(L)", " ARR(L) = ARR(IR)", " ARR(IR) = TEMP", " ENDIF", " IF(ARR(L+1).GT.ARR(IR))THEN", " TEMP=ARR(L+1)", " ARR(L+1)=ARR(IR)", " ARR(IR)=TEMP", " ENDIF", " IF(ARR(L).GT.ARR(L+1))THEN", " TEMP=ARR(L)", " ARR(L) = ARR(L+1)", " ARR(L+1) = TEMP", " ENDIF", "", " I=L+1", " J=IR", " A=ARR(L+1)", " 3 CONTINUE", " I=I+1", " IF(ARR(I).LT.A)GOTO 3", " 4 CONTINUE", " J=J-1", " IF(ARR(J).GT.A)GOTO 4", " IF(J.LT.I)GOTO 5", " TEMP = ARR(I)", " ARR(I) = ARR(J)", " ARR(J) = TEMP", " GOTO 3", " 5 ARR(L+1) = ARR(J)", " ARR(J) = A", " JSTACK = JSTACK + 2", " IF(JSTACK.GT.NSTACK)RETURN", " IF(IR-I+1.GE.J-1)THEN", " ISTACK(JSTACK)=IR", " ISTACK(JSTACK-1)=I", " IR=J-1", " ELSE", " ISTACK(JSTACK)=J-1", " ISTACK(JSTACK-1)=L", " L=I", " ENDIF", " ENDIF", " GOTO 1", " END", "", "C Finds repeated elements of ARR and their occurrence incidence", "C reporting the result in REPLIST and REPNUM respectively.", "C NLIST is the number of repeated elements found.", "C Algorithm first sorts the list and then walks down it", "C counting repeats as they are found.", " SUBROUTINE DFREPS(ARR,N,REPLIST,REPNUM,NLIST)", "CF2PY INTENT(IN), ARR", "CF2PY INTENT(OUT), REPLIST", "CF2PY INTENT(OUT), REPNUM", "CF2PY INTENT(OUT), NLIST", "CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)", " REAL*8 REPLIST(N), ARR(N)", " REAL*8 LASTVAL", " INTEGER REPNUM(N)", " INTEGER HOWMANY, REPEAT, IND, NLIST, NNUM", "", " CALL DQSORT(N,ARR)", " LASTVAL = ARR(1)", " HOWMANY = 0", " IND = 2", " NNUM = 1", " NLIST = 1", " REPEAT = 0", " DO WHILE(IND.LE.N)", " IF(ARR(IND).NE.LASTVAL)THEN", " IF (REPEAT.EQ.1)THEN", " REPNUM(NNUM)=HOWMANY+1", " NNUM=NNUM+1", " REPEAT=0", " HOWMANY=0", " ENDIF", " ELSE", " HOWMANY=HOWMANY+1", " REPEAT=1", " IF(HOWMANY.EQ.1)THEN", " REPLIST(NLIST)=ARR(IND)", " NLIST=NLIST+1", " ENDIF", " ENDIF", " LASTVAL=ARR(IND)", " IND=IND+1", " ENDDO", " IF(REPEAT.EQ.1)THEN", " REPNUM(NNUM)=HOWMANY+1", " ENDIF", " NLIST = NLIST - 1", " END", "", "", "", "", "", "" ], "deleted": [] } }, { "old_path": "scipy_base/polynomial.py", "new_path": "scipy_base/polynomial.py", "filename": "polynomial.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -158,7 +158,7 @@ def polyder(p,m=1):\n return val\n \n def polyval(p,x):\n- \"\"\"Evaluate the polymnomial p at x.\n+ \"\"\"Evaluate the polynomial p at x.\n \n Description:\n \n", "added_lines": 1, "deleted_lines": 1, "source_code": "import Numeric\nfrom Numeric import *\nfrom scimath import *\n\nfrom type_check import isscalar\nfrom matrix_base import diag\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\n\n__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n \ndef get_eigval_func():\n try:\n import scipy.linalg\n eigvals = scipy.linalg.eigvals\n except ImportError:\n try:\n import linalg\n eigvals = linalg.eigvals\n except ImportError:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \\\n \"You must have scipy.linalg or LinearAlgebra to \"\\\n \"use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n eig = get_eigval_func()\n seq_of_zeros=eig(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = convolve(a,[1, -seq_of_zeros[k]], mode=2)\n\n \n if a.typecode() in ['F','D']:\n # if complex roots are all complex conjugates, the roots are real.\n roots = asarray(seq_of_zeros,'D')\n pos_roots = sort_complex(compress(roots.imag > 0,roots))\n neg_roots = conjugate(sort_complex(compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n eig = get_eigval_func()\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n \n # find non-zero array entries\n non_zero = nonzero(ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n \n # casting: if incoming array isn't floating point, make it floating point.\n if p.typecode() not in ['f','d','F','D']:\n p = p.astype('d')\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(ones((N-2,),p.typecode()),-1)\n A[0,:] = -p[1:] / p[0]\n roots = eig(A)\n else:\n return array([])\n\n # tack any zeros onto the back of the array \n roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n return roots\n\ndef polyint(p,m=1,k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*Numeric.ones(m)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n y = Numeric.zeros(len(p)+1,'d')\n y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)\n y[-1] = k[0] \n val = polyint(y,m-1,k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n \ndef polyder(p,m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y,m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyval(p,x):\n \"\"\"Evaluate the polynomial p at x.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n \"\"\"\n x = Numeric.asarray(x)\n p = Numeric.asarray(p)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) + a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 + Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) - a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 - Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1,a2):\n \"\"\"Multiplies two polynomials represented as lists.\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n val = Numeric.convolve(a1,a2)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polydiv(a1,a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n q, r = deconvolve(a1,a2)\n while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q, r = map(poly1d,(q,r))\n return q, r\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal.\n \"\"\"\n try:\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = Numeric.ones(N-D+1,Numeric.Float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - Numeric.convolve(den,quot,mode=2)\n return quot, rem\n\nimport re\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr,n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else: \n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n \n \nclass poly1d:\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r,poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __coerce__(self,other):\n return None\n \n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", "source_code_before": "import Numeric\nfrom Numeric import *\nfrom scimath import *\n\nfrom type_check import isscalar\nfrom matrix_base import diag\nfrom shape_base import hstack, atleast_1d\nfrom function_base import trim_zeros, sort_complex\n\n__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n \ndef get_eigval_func():\n try:\n import scipy.linalg\n eigvals = scipy.linalg.eigvals\n except ImportError:\n try:\n import linalg\n eigvals = linalg.eigvals\n except ImportError:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \\\n \"You must have scipy.linalg or LinearAlgebra to \"\\\n \"use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n eig = get_eigval_func()\n seq_of_zeros=eig(seq_of_zeros)\n elif len(sh) ==1:\n pass\n else:\n raise ValueError, \"input must be 1d or square 2d array.\"\n\n if len(seq_of_zeros) == 0:\n return 1.0\n\n a = [1]\n for k in range(len(seq_of_zeros)):\n a = convolve(a,[1, -seq_of_zeros[k]], mode=2)\n\n \n if a.typecode() in ['F','D']:\n # if complex roots are all complex conjugates, the roots are real.\n roots = asarray(seq_of_zeros,'D')\n pos_roots = sort_complex(compress(roots.imag > 0,roots))\n neg_roots = conjugate(sort_complex(compress(roots.imag < 0,roots)))\n if (len(pos_roots) == len(neg_roots) and\n alltrue(neg_roots == pos_roots)):\n a = a.real.copy()\n\n return a\n\ndef roots(p):\n \"\"\" Return the roots of the polynomial coefficients in p.\n\n The values in the rank-1 array p are coefficients of a polynomial.\n If the length of p is n+1 then the polynomial is\n p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]\n \"\"\"\n # If input is scalar, this makes it an array\n eig = get_eigval_func()\n p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n \n # find non-zero array entries\n non_zero = nonzero(ravel(p))\n\n # find the number of trailing zeros -- this is the number of roots at 0.\n trailing_zeros = len(p) - non_zero[-1] - 1\n\n # strip leading and trailing zeros\n p = p[int(non_zero[0]):int(non_zero[-1])+1]\n \n # casting: if incoming array isn't floating point, make it floating point.\n if p.typecode() not in ['f','d','F','D']:\n p = p.astype('d')\n\n N = len(p)\n if N > 1:\n # build companion matrix and find its eigenvalues (the roots)\n A = diag(ones((N-2,),p.typecode()),-1)\n A[0,:] = -p[1:] / p[0]\n roots = eig(A)\n else:\n return array([])\n\n # tack any zeros onto the back of the array \n roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n return roots\n\ndef polyint(p,m=1,k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*Numeric.ones(m)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n y = Numeric.zeros(len(p)+1,'d')\n y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)\n y[-1] = k[0] \n val = polyint(y,m-1,k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n \ndef polyder(p,m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y,m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyval(p,x):\n \"\"\"Evaluate the polymnomial p at x.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n \"\"\"\n x = Numeric.asarray(x)\n p = Numeric.asarray(p)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) + a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 + Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) - a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 - Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1,a2):\n \"\"\"Multiplies two polynomials represented as lists.\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n val = Numeric.convolve(a1,a2)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polydiv(a1,a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n q, r = deconvolve(a1,a2)\n while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q, r = map(poly1d,(q,r))\n return q, r\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal.\n \"\"\"\n try:\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = Numeric.ones(N-D+1,Numeric.Float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - Numeric.convolve(den,quot,mode=2)\n return quot, rem\n\nimport re\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr,n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else: \n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n \n \nclass poly1d:\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r,poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __coerce__(self,other):\n return None\n \n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", "methods": [ { "name": "get_eigval_func", "long_name": "get_eigval_func( )", "filename": "polynomial.py", "nloc": 17, "complexity": 4, "token_count": 52, "parameters": [], "start_line": 13, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "poly", "long_name": "poly( seq_of_zeros )", "filename": "polynomial.py", "nloc": 23, "complexity": 9, "token_count": 195, "parameters": [ "seq_of_zeros" ], "start_line": 31, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "roots", "long_name": "roots( p )", "filename": "polynomial.py", "nloc": 19, "complexity": 4, "token_count": 190, "parameters": [ "p" ], "start_line": 71, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "polyint", "long_name": "polyint( p , m = 1 , k = None )", "filename": "polynomial.py", "nloc": 24, "complexity": 8, "token_count": 192, "parameters": [ "p", "m", "k" ], "start_line": 110, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "polyder", "long_name": "polyder( p , m = 1 )", "filename": "polynomial.py", "nloc": 15, "complexity": 4, "token_count": 99, "parameters": [ "p", "m" ], "start_line": 142, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 7, "complexity": 2, "token_count": 63, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "polyadd", "long_name": "polyadd( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 175, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polysub", "long_name": "polysub( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 193, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polymul", "long_name": "polymul( a1 , a2 )", "filename": "polynomial.py", "nloc": 6, "complexity": 3, "token_count": 46, "parameters": [ "a1", "a2" ], "start_line": 212, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "polydiv", "long_name": "polydiv( a1 , a2 )", "filename": "polynomial.py", "nloc": 8, "complexity": 5, "token_count": 94, "parameters": [ "a1", "a2" ], "start_line": 221, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "deconvolve", "long_name": "deconvolve( signal , divisor )", "filename": "polynomial.py", "nloc": 18, "complexity": 3, "token_count": 115, "parameters": [ "signal", "divisor" ], "start_line": 232, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_raise_power", "long_name": "_raise_power( astr , wrap = 70 )", "filename": "polynomial.py", "nloc": 25, "complexity": 5, "token_count": 194, "parameters": [ "astr", "wrap" ], "start_line": 255, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , c_or_r , r = 0 )", "filename": "polynomial.py", "nloc": 15, "complexity": 6, "token_count": 122, "parameters": [ "self", "c_or_r", "r" ], "start_line": 299, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__array__", "long_name": "__array__( self , t = None )", "filename": "polynomial.py", "nloc": 5, "complexity": 2, "token_count": 34, "parameters": [ "self", "t" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__coerce__", "long_name": "__coerce__( self , other )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "other" ], "start_line": 321, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 324, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 329, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "polynomial.py", "nloc": 41, "complexity": 17, "token_count": 244, "parameters": [ "self" ], "start_line": 332, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "val" ], "start_line": 376, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__mul__", "long_name": "__mul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 379, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rmul__", "long_name": "__rmul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 386, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__add__", "long_name": "__add__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 393, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 400, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__pow__", "long_name": "__pow__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 5, "token_count": 57, "parameters": [ "self", "val" ], "start_line": 407, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__sub__", "long_name": "__sub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 415, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__div__", "long_name": "__div__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 429, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rdiv__", "long_name": "__rdiv__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 436, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , key , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "key", "val" ], "start_line": 443, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , key )", "filename": "polynomial.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self", "key" ], "start_line": 446, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "val" ], "start_line": 456, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , key , val )", "filename": "polynomial.py", "nloc": 11, "complexity": 3, "token_count": 94, "parameters": [ "self", "key", "val" ], "start_line": 464, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "integ", "long_name": "integ( self , m = 1 , k = 0 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "self", "m", "k" ], "start_line": 476, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "deriv", "long_name": "deriv( self , m = 1 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "m" ], "start_line": 479, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "methods_before": [ { "name": "get_eigval_func", "long_name": "get_eigval_func( )", "filename": "polynomial.py", "nloc": 17, "complexity": 4, "token_count": 52, "parameters": [], "start_line": 13, "end_line": 29, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "poly", "long_name": "poly( seq_of_zeros )", "filename": "polynomial.py", "nloc": 23, "complexity": 9, "token_count": 195, "parameters": [ "seq_of_zeros" ], "start_line": 31, "end_line": 69, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 39, "top_nesting_level": 0 }, { "name": "roots", "long_name": "roots( p )", "filename": "polynomial.py", "nloc": 19, "complexity": 4, "token_count": 190, "parameters": [ "p" ], "start_line": 71, "end_line": 108, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 38, "top_nesting_level": 0 }, { "name": "polyint", "long_name": "polyint( p , m = 1 , k = None )", "filename": "polynomial.py", "nloc": 24, "complexity": 8, "token_count": 192, "parameters": [ "p", "m", "k" ], "start_line": 110, "end_line": 140, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 31, "top_nesting_level": 0 }, { "name": "polyder", "long_name": "polyder( p , m = 1 )", "filename": "polynomial.py", "nloc": 15, "complexity": 4, "token_count": 99, "parameters": [ "p", "m" ], "start_line": 142, "end_line": 158, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 7, "complexity": 2, "token_count": 63, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 }, { "name": "polyadd", "long_name": "polyadd( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 175, "end_line": 191, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polysub", "long_name": "polysub( a1 , a2 )", "filename": "polynomial.py", "nloc": 15, "complexity": 5, "token_count": 124, "parameters": [ "a1", "a2" ], "start_line": 193, "end_line": 209, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 0 }, { "name": "polymul", "long_name": "polymul( a1 , a2 )", "filename": "polynomial.py", "nloc": 6, "complexity": 3, "token_count": 46, "parameters": [ "a1", "a2" ], "start_line": 212, "end_line": 219, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "polydiv", "long_name": "polydiv( a1 , a2 )", "filename": "polynomial.py", "nloc": 8, "complexity": 5, "token_count": 94, "parameters": [ "a1", "a2" ], "start_line": 221, "end_line": 230, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "deconvolve", "long_name": "deconvolve( signal , divisor )", "filename": "polynomial.py", "nloc": 18, "complexity": 3, "token_count": 115, "parameters": [ "signal", "divisor" ], "start_line": 232, "end_line": 251, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "_raise_power", "long_name": "_raise_power( astr , wrap = 70 )", "filename": "polynomial.py", "nloc": 25, "complexity": 5, "token_count": 194, "parameters": [ "astr", "wrap" ], "start_line": 255, "end_line": 279, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "__init__", "long_name": "__init__( self , c_or_r , r = 0 )", "filename": "polynomial.py", "nloc": 15, "complexity": 6, "token_count": 122, "parameters": [ "self", "c_or_r", "r" ], "start_line": 299, "end_line": 313, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__array__", "long_name": "__array__( self , t = None )", "filename": "polynomial.py", "nloc": 5, "complexity": 2, "token_count": 34, "parameters": [ "self", "t" ], "start_line": 315, "end_line": 319, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 }, { "name": "__coerce__", "long_name": "__coerce__( self , other )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self", "other" ], "start_line": 321, "end_line": 322, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__repr__", "long_name": "__repr__( self )", "filename": "polynomial.py", "nloc": 4, "complexity": 1, "token_count": 26, "parameters": [ "self" ], "start_line": 324, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "__len__", "long_name": "__len__( self )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 9, "parameters": [ "self" ], "start_line": 329, "end_line": 330, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__str__", "long_name": "__str__( self )", "filename": "polynomial.py", "nloc": 41, "complexity": 17, "token_count": 244, "parameters": [ "self" ], "start_line": 332, "end_line": 373, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 16, "parameters": [ "self", "val" ], "start_line": 376, "end_line": 377, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__mul__", "long_name": "__mul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 379, "end_line": 384, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rmul__", "long_name": "__rmul__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 386, "end_line": 391, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__add__", "long_name": "__add__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 393, "end_line": 398, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__radd__", "long_name": "__radd__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 400, "end_line": 405, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__pow__", "long_name": "__pow__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 5, "token_count": 57, "parameters": [ "self", "val" ], "start_line": 407, "end_line": 413, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__sub__", "long_name": "__sub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 415, "end_line": 420, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rsub__", "long_name": "__rsub__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 44, "parameters": [ "self", "other" ], "start_line": 422, "end_line": 427, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__div__", "long_name": "__div__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 429, "end_line": 434, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__rdiv__", "long_name": "__rdiv__( self , other )", "filename": "polynomial.py", "nloc": 6, "complexity": 2, "token_count": 46, "parameters": [ "self", "other" ], "start_line": 436, "end_line": 441, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 1 }, { "name": "__setattr__", "long_name": "__setattr__( self , key , val )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 13, "parameters": [ "self", "key", "val" ], "start_line": 443, "end_line": 444, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "__getattr__", "long_name": "__getattr__( self , key )", "filename": "polynomial.py", "nloc": 9, "complexity": 4, "token_count": 58, "parameters": [ "self", "key" ], "start_line": 446, "end_line": 454, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "__getitem__", "long_name": "__getitem__( self , val )", "filename": "polynomial.py", "nloc": 7, "complexity": 3, "token_count": 37, "parameters": [ "self", "val" ], "start_line": 456, "end_line": 462, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 1 }, { "name": "__setitem__", "long_name": "__setitem__( self , key , val )", "filename": "polynomial.py", "nloc": 11, "complexity": 3, "token_count": 94, "parameters": [ "self", "key", "val" ], "start_line": 464, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 11, "top_nesting_level": 1 }, { "name": "integ", "long_name": "integ( self , m = 1 , k = 0 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 31, "parameters": [ "self", "m", "k" ], "start_line": 476, "end_line": 477, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 }, { "name": "deriv", "long_name": "deriv( self , m = 1 )", "filename": "polynomial.py", "nloc": 2, "complexity": 1, "token_count": 23, "parameters": [ "self", "m" ], "start_line": 479, "end_line": 480, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 2, "top_nesting_level": 1 } ], "changed_methods": [ { "name": "polyval", "long_name": "polyval( p , x )", "filename": "polynomial.py", "nloc": 7, "complexity": 2, "token_count": 63, "parameters": [ "p", "x" ], "start_line": 160, "end_line": 173, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 14, "top_nesting_level": 0 } ], "nloc": 379, "complexity": 120, "token_count": 2719, "diff_parsed": { "added": [ " \"\"\"Evaluate the polynomial p at x." ], "deleted": [ " \"\"\"Evaluate the polymnomial p at x." ] } }, { "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": "@@ -29,6 +29,12 @@ def configuration(parent_package=''):\n ext = Extension(dot_join(package,'_compiled_base'),sources,libraries=[])\n config['ext_modules'].append(ext)\n \n+ # add futil module\n+ sources = ['futil.f']\n+ sources = [os.path.join(local_path,x) for x in sources]\n+ ext = Extension(dot_join(package,'futil'),sources)\n+ config['ext_modules'].append(ext)\n+\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n", "added_lines": 6, "deleted_lines": 0, "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 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 ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\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,libraries=[])\n config['ext_modules'].append(ext)\n\n # add futil module\n sources = ['futil.f']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'futil'),sources)\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n os.path.join(local_path,'mconf_lite.h'))\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 ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\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,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n os.path.join(local_path,'mconf_lite.h'))\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": 27, "complexity": 5, "token_count": 246, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 23, "complexity": 4, "token_count": 201, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 27, "complexity": 5, "token_count": 246, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "nloc": 46, "complexity": 5, "token_count": 336, "diff_parsed": { "added": [ " # add futil module", " sources = ['futil.f']", " sources = [os.path.join(local_path,x) for x in sources]", " ext = Extension(dot_join(package,'futil'),sources)", " config['ext_modules'].append(ext)", "" ], "deleted": [] } } ] }, { "hash": "c4f7a4f611196bdbdd0301355049c2fb619f6228", "msg": "Added unit test for find_repeats", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-20T02:21:54+00:00", "author_timezone": 0, "committer_date": "2003-09-20T02:21:54+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c16960ea4bbba55bec719b019e3e1014984e457b" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 0, "insertions": 7, "lines": 7, "files": 1, "dmm_unit_size": 1.0, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "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": "@@ -197,6 +197,13 @@ def check_trailing_skip(self):\n \n # Utility\n \n+class test_find_repeats(unittest.TestCase):\n+ def check_basic(self):\n+ a = array([1,2,3,4,1,2,3,4,1,2,5])\n+ res,nums = find_repeats(a)\n+ assert_array_equal(res,[1,2,3,4])\n+ assert_array_equal(nums,[3,3,2])\n+\n def compare_results(res,desired):\n for i in range(len(desired)):\n assert_array_equal(res[i],desired[i])\n", "added_lines": 7, "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()\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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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# Utility\n\nclass test_find_repeats(unittest.TestCase):\n def check_basic(self):\n a = array([1,2,3,4,1,2,3,4,1,2,5])\n res,nums = find_repeats(a)\n assert_array_equal(res,[1,2,3,4])\n assert_array_equal(nums,[3,3,2])\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_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\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()\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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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# 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_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\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": 13, "end_line": 19, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 36, "end_line": 39, "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": 9, "complexity": 1, "token_count": 102, "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_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 53, "end_line": 62, "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": 65, "end_line": 72, "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": 75, "end_line": 82, "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": 85, "end_line": 92, "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": 95, "end_line": 107, "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": 110, "end_line": 124, "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": 127, "end_line": 148, "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": 151, "end_line": 158, "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": 160, "end_line": 169, "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": 172, "end_line": 180, "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": 185, "end_line": 188, "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": 189, "end_line": 192, "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": 193, "end_line": 196, "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": 5, "complexity": 1, "token_count": 67, "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": "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": 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": "test_function_base.py", "nloc": 18, "complexity": 2, "token_count": 195, "parameters": [ "level" ], "start_line": 214, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "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": 238, "end_line": 242, "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": 13, "end_line": 19, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 36, "end_line": 39, "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": 9, "complexity": 1, "token_count": 102, "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_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 53, "end_line": 62, "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": 65, "end_line": 72, "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": 75, "end_line": 82, "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": 85, "end_line": 92, "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": 95, "end_line": 107, "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": 110, "end_line": 124, "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": 127, "end_line": 148, "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": 151, "end_line": 158, "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": 160, "end_line": 169, "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": 172, "end_line": 180, "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": 185, "end_line": 188, "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": 189, "end_line": 192, "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": 193, "end_line": 196, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 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": "test_function_base.py", "nloc": 18, "complexity": 2, "token_count": 195, "parameters": [ "level" ], "start_line": 207, "end_line": 229, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "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": 231, "end_line": 235, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 201, "end_line": 205, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 216, "complexity": 29, "token_count": 2593, "diff_parsed": { "added": [ "class test_find_repeats(unittest.TestCase):", " def check_basic(self):", " a = array([1,2,3,4,1,2,3,4,1,2,5])", " res,nums = find_repeats(a)", " assert_array_equal(res,[1,2,3,4])", " assert_array_equal(nums,[3,3,2])", "" ], "deleted": [] } } ] }, { "hash": "0c09351d13e8af553a7462013a225522221fad88", "msg": "Moved futil from scipy_base to stats to keep fortran code out of scipy_base.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-20T18:20:56+00:00", "author_timezone": 0, "committer_date": "2003-09-20T18:20:56+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "c4f7a4f611196bdbdd0301355049c2fb619f6228" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 150, "insertions": 1, "lines": 151, "files": 3, "dmm_unit_size": 0.975609756097561, "dmm_unit_complexity": 0.943089430894309, "dmm_unit_interfacing": 0.3333333333333333, "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": "@@ -5,24 +5,17 @@\n from type_check import ScalarType\n from fastumath import PINF as inf\n import _compiled_base\n-import futil\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','find_repeats']\n+ 'nanargmin','nanmin','sum']\n \n round = Numeric.around\n any = Numeric.sometrue\n all = Numeric.alltrue\n \n-def find_repeats(arr):\n- \"\"\"Find repeats in arr and return (repeats, repeat_count)\n- \"\"\" \n- v1,v2, n = futil.dfreps(arr)\n- return v1[:n],v2[:n]\n-\n # Need this to change array type for low precision values\n def sum(x,axis=0): # could change default axis here\n x = asarray(x)\n", "added_lines": 1, "deleted_lines": 8, "source_code": "\nimport types\nimport Numeric\nfrom Numeric import *\nfrom type_check import ScalarType\nfrom fastumath import PINF as inf\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']\n\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\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 extract(arr,mask):\n \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(mask)))\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\n \n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()\n", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import *\nfrom type_check import ScalarType\nfrom fastumath import PINF as inf\nimport _compiled_base\nimport futil\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','find_repeats']\n\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\n\ndef find_repeats(arr):\n \"\"\"Find repeats in arr and return (repeats, repeat_count)\n \"\"\" \n v1,v2, n = futil.dfreps(arr)\n return v1[:n],v2[:n]\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 extract(arr,mask):\n \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(mask)))\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\n \n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 20, "end_line": 24, "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": 27, "end_line": 40, "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": 42, "end_line": 58, "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": 60, "end_line": 65, "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": 67, "end_line": 73, "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": 75, "end_line": 121, "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": 124, "end_line": 132, "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": 134, "end_line": 142, "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": 146, "end_line": 154, "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": 156, "end_line": 164, "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": 166, "end_line": 174, "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": 176, "end_line": 184, "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": 186, "end_line": 198, "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": 201, "end_line": 214, "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": 216, "end_line": 231, "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": 237, "end_line": 241, "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": 233, "end_line": 244, "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": 246, "end_line": 265, "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": 267, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 275, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 280, "end_line": 284, "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": 286, "end_line": 291, "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": 293, "end_line": 298, "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": 300, "end_line": 305, "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": 308, "end_line": 313, "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": 315, "end_line": 320, "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": 322, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 341, "end_line": 343, "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": 345, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "find_repeats", "long_name": "find_repeats( arr )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "arr" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "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": 27, "end_line": 31, "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": 34, "end_line": 47, "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": 49, "end_line": 65, "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": 67, "end_line": 72, "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": 74, "end_line": 80, "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": 82, "end_line": 128, "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": 131, "end_line": 139, "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": 141, "end_line": 149, "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": 153, "end_line": 161, "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": 163, "end_line": 171, "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": 173, "end_line": 181, "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": 183, "end_line": 191, "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": 193, "end_line": 205, "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": 208, "end_line": 221, "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": 223, "end_line": 238, "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": 244, "end_line": 248, "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": 240, "end_line": 251, "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": 253, "end_line": 272, "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": 274, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 282, "end_line": 285, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 287, "end_line": 291, "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": 293, "end_line": 298, "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": 300, "end_line": 305, "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": 307, "end_line": 312, "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": 315, "end_line": 320, "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": 322, "end_line": 327, "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": 329, "end_line": 340, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 348, "end_line": 350, "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": 352, "end_line": 354, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "find_repeats", "long_name": "find_repeats( arr )", "filename": "function_base.py", "nloc": 3, "complexity": 1, "token_count": 30, "parameters": [ "arr" ], "start_line": 20, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 212, "complexity": 62, "token_count": 1750, "diff_parsed": { "added": [ " 'nanargmin','nanmin','sum']" ], "deleted": [ "import futil", " 'nanargmin','nanmin','sum','find_repeats']", "def find_repeats(arr):", " \"\"\"Find repeats in arr and return (repeats, repeat_count)", " \"\"\"", " v1,v2, n = futil.dfreps(arr)", " return v1[:n],v2[:n]", "" ] } }, { "old_path": "scipy_base/futil.f", "new_path": null, "filename": "futil.f", "extension": "f", "change_type": "DELETE", "diff": "@@ -1,136 +0,0 @@\n-C Sorts an array arr(1:N) into ascending numerical order \n-C using the QuickSort algorithm. On output arr is replaced with its\n-C sorted rearrangement.\n- SUBROUTINE DQSORT(N,ARR)\n-CF2PY INTENT(IN,OUT,COPY), ARR\n-CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n- INTEGER N,M,NSTACK\n- REAL*8 ARR(N)\n- PARAMETER (M=7, NSTACK=100)\n- INTEGER I, IR, J, JSTACK, K, L, ISTACK(NSTACK)\n- REAL*8 A, TEMP\n-\n- JSTACK = 0\n- L = 1\n- IR = N\n- 1 IF(IR-L.LT.M)THEN\n- DO J=L+1,IR\n- A = ARR(J)\n- DO I = J-1,L,-1\n- IF (ARR(I).LE.A) GOTO 2\n- ARR(I+1)=ARR(I)\n- ENDDO\n- I = L-1\n- 2 ARR(I+1) = A\n- ENDDO\n- \n- IF(JSTACK.EQ.0)RETURN\n- IR=ISTACK(JSTACK)\n- L=ISTACK(JSTACK-1)\n- JSTACK = JSTACK - 2\n- \n- ELSE\n- K = (L+IR)/2\n- TEMP = ARR(K)\n- ARR(K) = ARR(L+1)\n- ARR(L+1) = TEMP\n- IF(ARR(L).GT.ARR(IR))THEN\n- TEMP = ARR(L)\n- ARR(L) = ARR(IR)\n- ARR(IR) = TEMP\n- ENDIF\n- IF(ARR(L+1).GT.ARR(IR))THEN\n- TEMP=ARR(L+1)\n- ARR(L+1)=ARR(IR)\n- ARR(IR)=TEMP\n- ENDIF\n- IF(ARR(L).GT.ARR(L+1))THEN\n- TEMP=ARR(L)\n- ARR(L) = ARR(L+1)\n- ARR(L+1) = TEMP\n- ENDIF\n-\n- I=L+1\n- J=IR\n- A=ARR(L+1)\n- 3 CONTINUE\n- I=I+1\n- IF(ARR(I).LT.A)GOTO 3\n- 4 CONTINUE\n- J=J-1\n- IF(ARR(J).GT.A)GOTO 4\n- IF(J.LT.I)GOTO 5\n- TEMP = ARR(I)\n- ARR(I) = ARR(J)\n- ARR(J) = TEMP\n- GOTO 3\n- 5 ARR(L+1) = ARR(J)\n- ARR(J) = A\n- JSTACK = JSTACK + 2\n- IF(JSTACK.GT.NSTACK)RETURN\n- IF(IR-I+1.GE.J-1)THEN\n- ISTACK(JSTACK)=IR\n- ISTACK(JSTACK-1)=I\n- IR=J-1\n- ELSE\n- ISTACK(JSTACK)=J-1\n- ISTACK(JSTACK-1)=L\n- L=I\n- ENDIF\n- ENDIF\n- GOTO 1\n- END\n-\n-C Finds repeated elements of ARR and their occurrence incidence\n-C reporting the result in REPLIST and REPNUM respectively.\n-C NLIST is the number of repeated elements found.\n-C Algorithm first sorts the list and then walks down it\n-C counting repeats as they are found.\n- SUBROUTINE DFREPS(ARR,N,REPLIST,REPNUM,NLIST)\n-CF2PY INTENT(IN), ARR\n-CF2PY INTENT(OUT), REPLIST\n-CF2PY INTENT(OUT), REPNUM\n-CF2PY INTENT(OUT), NLIST\n-CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n- REAL*8 REPLIST(N), ARR(N)\n- REAL*8 LASTVAL\n- INTEGER REPNUM(N)\n- INTEGER HOWMANY, REPEAT, IND, NLIST, NNUM\n-\n- CALL DQSORT(N,ARR)\n- LASTVAL = ARR(1)\n- HOWMANY = 0\n- IND = 2\n- NNUM = 1\n- NLIST = 1\n- REPEAT = 0\n- DO WHILE(IND.LE.N)\n- IF(ARR(IND).NE.LASTVAL)THEN\n- IF (REPEAT.EQ.1)THEN\n- REPNUM(NNUM)=HOWMANY+1\n- NNUM=NNUM+1 \n- REPEAT=0\n- HOWMANY=0\n- ENDIF\n- ELSE\n- HOWMANY=HOWMANY+1\n- REPEAT=1\n- IF(HOWMANY.EQ.1)THEN\n- REPLIST(NLIST)=ARR(IND)\n- NLIST=NLIST+1\n- ENDIF\n- ENDIF\n- LASTVAL=ARR(IND)\n- IND=IND+1\n- ENDDO\n- IF(REPEAT.EQ.1)THEN\n- REPNUM(NNUM)=HOWMANY+1\n- ENDIF\n- NLIST = NLIST - 1\n- END\n-\n-\n-\n- \n- \n- \n", "added_lines": 0, "deleted_lines": 136, "source_code": null, "source_code_before": "C Sorts an array arr(1:N) into ascending numerical order \nC using the QuickSort algorithm. On output arr is replaced with its\nC sorted rearrangement.\n SUBROUTINE DQSORT(N,ARR)\nCF2PY INTENT(IN,OUT,COPY), ARR\nCF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n INTEGER N,M,NSTACK\n REAL*8 ARR(N)\n PARAMETER (M=7, NSTACK=100)\n INTEGER I, IR, J, JSTACK, K, L, ISTACK(NSTACK)\n REAL*8 A, TEMP\n\n JSTACK = 0\n L = 1\n IR = N\n 1 IF(IR-L.LT.M)THEN\n DO J=L+1,IR\n A = ARR(J)\n DO I = J-1,L,-1\n IF (ARR(I).LE.A) GOTO 2\n ARR(I+1)=ARR(I)\n ENDDO\n I = L-1\n 2 ARR(I+1) = A\n ENDDO\n \n IF(JSTACK.EQ.0)RETURN\n IR=ISTACK(JSTACK)\n L=ISTACK(JSTACK-1)\n JSTACK = JSTACK - 2\n \n ELSE\n K = (L+IR)/2\n TEMP = ARR(K)\n ARR(K) = ARR(L+1)\n ARR(L+1) = TEMP\n IF(ARR(L).GT.ARR(IR))THEN\n TEMP = ARR(L)\n ARR(L) = ARR(IR)\n ARR(IR) = TEMP\n ENDIF\n IF(ARR(L+1).GT.ARR(IR))THEN\n TEMP=ARR(L+1)\n ARR(L+1)=ARR(IR)\n ARR(IR)=TEMP\n ENDIF\n IF(ARR(L).GT.ARR(L+1))THEN\n TEMP=ARR(L)\n ARR(L) = ARR(L+1)\n ARR(L+1) = TEMP\n ENDIF\n\n I=L+1\n J=IR\n A=ARR(L+1)\n 3 CONTINUE\n I=I+1\n IF(ARR(I).LT.A)GOTO 3\n 4 CONTINUE\n J=J-1\n IF(ARR(J).GT.A)GOTO 4\n IF(J.LT.I)GOTO 5\n TEMP = ARR(I)\n ARR(I) = ARR(J)\n ARR(J) = TEMP\n GOTO 3\n 5 ARR(L+1) = ARR(J)\n ARR(J) = A\n JSTACK = JSTACK + 2\n IF(JSTACK.GT.NSTACK)RETURN\n IF(IR-I+1.GE.J-1)THEN\n ISTACK(JSTACK)=IR\n ISTACK(JSTACK-1)=I\n IR=J-1\n ELSE\n ISTACK(JSTACK)=J-1\n ISTACK(JSTACK-1)=L\n L=I\n ENDIF\n ENDIF\n GOTO 1\n END\n\nC Finds repeated elements of ARR and their occurrence incidence\nC reporting the result in REPLIST and REPNUM respectively.\nC NLIST is the number of repeated elements found.\nC Algorithm first sorts the list and then walks down it\nC counting repeats as they are found.\n SUBROUTINE DFREPS(ARR,N,REPLIST,REPNUM,NLIST)\nCF2PY INTENT(IN), ARR\nCF2PY INTENT(OUT), REPLIST\nCF2PY INTENT(OUT), REPNUM\nCF2PY INTENT(OUT), NLIST\nCF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)\n REAL*8 REPLIST(N), ARR(N)\n REAL*8 LASTVAL\n INTEGER REPNUM(N)\n INTEGER HOWMANY, REPEAT, IND, NLIST, NNUM\n\n CALL DQSORT(N,ARR)\n LASTVAL = ARR(1)\n HOWMANY = 0\n IND = 2\n NNUM = 1\n NLIST = 1\n REPEAT = 0\n DO WHILE(IND.LE.N)\n IF(ARR(IND).NE.LASTVAL)THEN\n IF (REPEAT.EQ.1)THEN\n REPNUM(NNUM)=HOWMANY+1\n NNUM=NNUM+1 \n REPEAT=0\n HOWMANY=0\n ENDIF\n ELSE\n HOWMANY=HOWMANY+1\n REPEAT=1\n IF(HOWMANY.EQ.1)THEN\n REPLIST(NLIST)=ARR(IND)\n NLIST=NLIST+1\n ENDIF\n ENDIF\n LASTVAL=ARR(IND)\n IND=IND+1\n ENDDO\n IF(REPEAT.EQ.1)THEN\n REPNUM(NNUM)=HOWMANY+1\n ENDIF\n NLIST = NLIST - 1\n END\n\n\n\n \n \n \n", "methods": [], "methods_before": [ { "name": "DQSORT", "long_name": "DQSORT( N , ARR )", "filename": "futil.f", "nloc": 75, "complexity": 14, "token_count": 530, "parameters": [ "N", "ARR" ], "start_line": 4, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 79, "top_nesting_level": 0 }, { "name": "DFREPS", "long_name": "DFREPS( ARR , N , REPLIST , REPNUM , NLIST )", "filename": "futil.f", "nloc": 41, "complexity": 6, "token_count": 231, "parameters": [ "ARR", "N", "REPLIST", "REPNUM", "NLIST" ], "start_line": 89, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "DFREPS", "long_name": "DFREPS( ARR , N , REPLIST , REPNUM , NLIST )", "filename": "futil.f", "nloc": 41, "complexity": 6, "token_count": 231, "parameters": [ "ARR", "N", "REPLIST", "REPNUM", "NLIST" ], "start_line": 89, "end_line": 130, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 42, "top_nesting_level": 0 }, { "name": "DQSORT", "long_name": "DQSORT( N , ARR )", "filename": "futil.f", "nloc": 75, "complexity": 14, "token_count": 530, "parameters": [ "N", "ARR" ], "start_line": 4, "end_line": 82, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 79, "top_nesting_level": 0 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "C Sorts an array arr(1:N) into ascending numerical order", "C using the QuickSort algorithm. On output arr is replaced with its", "C sorted rearrangement.", " SUBROUTINE DQSORT(N,ARR)", "CF2PY INTENT(IN,OUT,COPY), ARR", "CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)", " INTEGER N,M,NSTACK", " REAL*8 ARR(N)", " PARAMETER (M=7, NSTACK=100)", " INTEGER I, IR, J, JSTACK, K, L, ISTACK(NSTACK)", " REAL*8 A, TEMP", "", " JSTACK = 0", " L = 1", " IR = N", " 1 IF(IR-L.LT.M)THEN", " DO J=L+1,IR", " A = ARR(J)", " DO I = J-1,L,-1", " IF (ARR(I).LE.A) GOTO 2", " ARR(I+1)=ARR(I)", " ENDDO", " I = L-1", " 2 ARR(I+1) = A", " ENDDO", "", " IF(JSTACK.EQ.0)RETURN", " IR=ISTACK(JSTACK)", " L=ISTACK(JSTACK-1)", " JSTACK = JSTACK - 2", "", " ELSE", " K = (L+IR)/2", " TEMP = ARR(K)", " ARR(K) = ARR(L+1)", " ARR(L+1) = TEMP", " IF(ARR(L).GT.ARR(IR))THEN", " TEMP = ARR(L)", " ARR(L) = ARR(IR)", " ARR(IR) = TEMP", " ENDIF", " IF(ARR(L+1).GT.ARR(IR))THEN", " TEMP=ARR(L+1)", " ARR(L+1)=ARR(IR)", " ARR(IR)=TEMP", " ENDIF", " IF(ARR(L).GT.ARR(L+1))THEN", " TEMP=ARR(L)", " ARR(L) = ARR(L+1)", " ARR(L+1) = TEMP", " ENDIF", "", " I=L+1", " J=IR", " A=ARR(L+1)", " 3 CONTINUE", " I=I+1", " IF(ARR(I).LT.A)GOTO 3", " 4 CONTINUE", " J=J-1", " IF(ARR(J).GT.A)GOTO 4", " IF(J.LT.I)GOTO 5", " TEMP = ARR(I)", " ARR(I) = ARR(J)", " ARR(J) = TEMP", " GOTO 3", " 5 ARR(L+1) = ARR(J)", " ARR(J) = A", " JSTACK = JSTACK + 2", " IF(JSTACK.GT.NSTACK)RETURN", " IF(IR-I+1.GE.J-1)THEN", " ISTACK(JSTACK)=IR", " ISTACK(JSTACK-1)=I", " IR=J-1", " ELSE", " ISTACK(JSTACK)=J-1", " ISTACK(JSTACK-1)=L", " L=I", " ENDIF", " ENDIF", " GOTO 1", " END", "", "C Finds repeated elements of ARR and their occurrence incidence", "C reporting the result in REPLIST and REPNUM respectively.", "C NLIST is the number of repeated elements found.", "C Algorithm first sorts the list and then walks down it", "C counting repeats as they are found.", " SUBROUTINE DFREPS(ARR,N,REPLIST,REPNUM,NLIST)", "CF2PY INTENT(IN), ARR", "CF2PY INTENT(OUT), REPLIST", "CF2PY INTENT(OUT), REPNUM", "CF2PY INTENT(OUT), NLIST", "CF2PY INTENT(HIDE), DEPEND(ARR), N=len(ARR)", " REAL*8 REPLIST(N), ARR(N)", " REAL*8 LASTVAL", " INTEGER REPNUM(N)", " INTEGER HOWMANY, REPEAT, IND, NLIST, NNUM", "", " CALL DQSORT(N,ARR)", " LASTVAL = ARR(1)", " HOWMANY = 0", " IND = 2", " NNUM = 1", " NLIST = 1", " REPEAT = 0", " DO WHILE(IND.LE.N)", " IF(ARR(IND).NE.LASTVAL)THEN", " IF (REPEAT.EQ.1)THEN", " REPNUM(NNUM)=HOWMANY+1", " NNUM=NNUM+1", " REPEAT=0", " HOWMANY=0", " ENDIF", " ELSE", " HOWMANY=HOWMANY+1", " REPEAT=1", " IF(HOWMANY.EQ.1)THEN", " REPLIST(NLIST)=ARR(IND)", " NLIST=NLIST+1", " ENDIF", " ENDIF", " LASTVAL=ARR(IND)", " IND=IND+1", " ENDDO", " IF(REPEAT.EQ.1)THEN", " REPNUM(NNUM)=HOWMANY+1", " ENDIF", " NLIST = NLIST - 1", " END", "", "", "", "", "", "" ] } }, { "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": "@@ -29,12 +29,6 @@ def configuration(parent_package=''):\n ext = Extension(dot_join(package,'_compiled_base'),sources,libraries=[])\n config['ext_modules'].append(ext)\n \n- # add futil module\n- sources = ['futil.f']\n- sources = [os.path.join(local_path,x) for x in sources]\n- ext = Extension(dot_join(package,'futil'),sources)\n- config['ext_modules'].append(ext)\n-\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n", "added_lines": 0, "deleted_lines": 6, "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 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 ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\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,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n os.path.join(local_path,'mconf_lite.h'))\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 ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\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,libraries=[])\n config['ext_modules'].append(ext)\n\n # add futil module\n sources = ['futil.f']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'futil'),sources)\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n os.path.join(local_path,'mconf_lite.h'))\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": 23, "complexity": 4, "token_count": 201, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 27, "complexity": 5, "token_count": 246, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 27, "complexity": 5, "token_count": 246, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "nloc": 42, "complexity": 4, "token_count": 291, "diff_parsed": { "added": [], "deleted": [ " # add futil module", " sources = ['futil.f']", " sources = [os.path.join(local_path,x) for x in sources]", " ext = Extension(dot_join(package,'futil'),sources)", " config['ext_modules'].append(ext)", "" ] } } ] }, { "hash": "19d33f72fd0e05ba7156b8874b269be8e605bb29", "msg": "scipy_test imports scipy_base from installation tree, so reloading scipy_base is required to get scipy_base from the build tree", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-20T19:09:54+00:00", "author_timezone": 0, "committer_date": "2003-09-20T19:09:54+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "0c09351d13e8af553a7462013a225522221fad88" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 0, "insertions": 6, "lines": 6, "files": 6, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "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": "@@ -6,6 +6,7 @@\n import sys\n from scipy_test.testing import set_package_path\n set_package_path()\n+import scipy_base;reload(scipy_base)\n from scipy_base import *\n del sys.path[0]\n \n", "added_lines": 1, "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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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# Utility\n\nclass test_find_repeats(unittest.TestCase):\n def check_basic(self):\n a = array([1,2,3,4,1,2,3,4,1,2,5])\n res,nums = find_repeats(a)\n assert_array_equal(res,[1,2,3,4])\n assert_array_equal(nums,[3,3,2])\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_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\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()\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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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# Utility\n\nclass test_find_repeats(unittest.TestCase):\n def check_basic(self):\n a = array([1,2,3,4,1,2,3,4,1,2,5])\n res,nums = find_repeats(a)\n assert_array_equal(res,[1,2,3,4])\n assert_array_equal(nums,[3,3,2])\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_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\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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 22, "end_line": 25, "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": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 28, "end_line": 35, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 37, "end_line": 40, "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": 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": 5, "complexity": 1, "token_count": 67, "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": "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": 208, "end_line": 210, "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": 18, "complexity": 2, "token_count": 195, "parameters": [ "level" ], "start_line": 215, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "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": 239, "end_line": 243, "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": 13, "end_line": 19, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 21, "end_line": 24, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 1 }, { "name": "check_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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 36, "end_line": 39, "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": 9, "complexity": 1, "token_count": 102, "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_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 10, "complexity": 1, "token_count": 105, "parameters": [ "self" ], "start_line": 53, "end_line": 62, "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": 65, "end_line": 72, "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": 75, "end_line": 82, "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": 85, "end_line": 92, "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": 95, "end_line": 107, "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": 110, "end_line": 124, "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": 127, "end_line": 148, "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": 151, "end_line": 158, "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": 160, "end_line": 169, "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": 172, "end_line": 180, "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": 185, "end_line": 188, "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": 189, "end_line": 192, "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": 193, "end_line": 196, "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": 5, "complexity": 1, "token_count": 67, "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": "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": 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": "test_function_base.py", "nloc": 18, "complexity": 2, "token_count": 195, "parameters": [ "level" ], "start_line": 214, "end_line": 236, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "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": 238, "end_line": 242, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 217, "complexity": 29, "token_count": 2600, "diff_parsed": { "added": [ "import scipy_base;reload(scipy_base)" ], "deleted": [] } }, { "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": "@@ -5,6 +5,7 @@\n import sys\n from scipy_test.testing import set_package_path\n set_package_path()\n+import scipy_base;reload(scipy_base)\n from scipy_base import *\n del sys.path[0]\n \n", "added_lines": 1, "deleted_lines": 0, "source_code": "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", "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()\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": 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 } ], "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": 12, "end_line": 22, "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": 24, "end_line": 34, "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": 37, "end_line": 43, "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": 45, "end_line": 55, "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": 59, "end_line": 66, "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": 68, "end_line": 72, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 69, "complexity": 7, "token_count": 793, "diff_parsed": { "added": [ "import scipy_base;reload(scipy_base)" ], "deleted": [] } }, { "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": "@@ -9,6 +9,7 @@\n import sys\n from scipy_test.testing import set_package_path\n set_package_path()\n+import scipy_base;reload(scipy_base)\n from scipy_base import *\n del sys.path[0]\n \n", "added_lines": 1, "deleted_lines": 0, "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 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", "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()\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 }, { "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 } ], "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": 19, "end_line": 20, "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": 23, "end_line": 24, "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": 29, "end_line": 36, "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": 38, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 36, "complexity": 5, "token_count": 179, "diff_parsed": { "added": [ "import scipy_base;reload(scipy_base)" ], "deleted": [] } }, { "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": "@@ -9,6 +9,7 @@\n import sys\n from scipy_test.testing import set_package_path\n set_package_path()\n+import scipy_base;reload(scipy_base)\n from scipy_base import *\n del sys.path[0]\n \n", "added_lines": 1, "deleted_lines": 0, "source_code": "\"\"\" 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", "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()\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": 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 } ], "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": 20, "end_line": 23, "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": 26, "end_line": 34, "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": 35, "end_line": 43, "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": 44, "end_line": 51, "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": 52, "end_line": 59, "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": 62, "end_line": 74, "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": 76, "end_line": 88, "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": 91, "end_line": 101, "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": 104, "end_line": 114, "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": 117, "end_line": 141, "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": 146, "end_line": 156, "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": 158, "end_line": 162, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 148, "complexity": 22, "token_count": 1444, "diff_parsed": { "added": [ "import scipy_base;reload(scipy_base)" ], "deleted": [] } }, { "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": "@@ -5,6 +5,7 @@\n import sys\n from scipy_test.testing import set_package_path\n set_package_path()\n+import scipy_base;reload(scipy_base)\n from scipy_base import *\n del sys.path[0]\n \n", "added_lines": 1, "deleted_lines": 0, "source_code": "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", "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()\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": 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 } ], "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": 13, "end_line": 19, "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": 20, "end_line": 72, "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": 73, "end_line": 77, "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": 78, "end_line": 84, "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": 85, "end_line": 91, "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": 94, "end_line": 99, "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": 101, "end_line": 106, "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": 107, "end_line": 113, "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": 120, "end_line": 124, "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": 126, "end_line": 132, "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": 135, "end_line": 139, "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": 140, "end_line": 144, "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": 145, "end_line": 149, "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": 150, "end_line": 155, "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": 156, "end_line": 163, "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": 166, "end_line": 170, "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": 171, "end_line": 175, "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": 176, "end_line": 180, "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": 181, "end_line": 186, "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": 187, "end_line": 192, "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": 195, "end_line": 199, "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": 200, "end_line": 204, "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": 205, "end_line": 209, "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": 210, "end_line": 215, "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": 218, "end_line": 222, "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": 223, "end_line": 227, "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": 228, "end_line": 232, "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": 235, "end_line": 239, "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": 240, "end_line": 244, "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": 245, "end_line": 249, "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": 250, "end_line": 254, "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": 257, "end_line": 261, "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": 262, "end_line": 266, "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": 267, "end_line": 271, "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": 272, "end_line": 276, "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": 284, "end_line": 290, "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": 291, "end_line": 295, "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": 296, "end_line": 301, "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": 306, "end_line": 312, "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": 313, "end_line": 318, "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": 323, "end_line": 330, "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": 331, "end_line": 339, "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": 342, "end_line": 348, "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": 352, "end_line": 354, "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": 359, "end_line": 376, "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": 378, "end_line": 382, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 346, "complexity": 53, "token_count": 3913, "diff_parsed": { "added": [ "import scipy_base;reload(scipy_base)" ], "deleted": [] } }, { "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": "@@ -6,6 +6,7 @@\n import sys\n from scipy_test.testing import set_package_path\n set_package_path()\n+import scipy_base;reload(scipy_base)\n from scipy_base import *\n del sys.path[0]\n \n", "added_lines": 1, "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_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", "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()\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": 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 } ], "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": 13, "end_line": 19, "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": 22, "end_line": 24, "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": 26, "end_line": 28, "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": 31, "end_line": 33, "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": 35, "end_line": 37, "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": 40, "end_line": 43, "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": 44, "end_line": 47, "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": 50, "end_line": 53, "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": 54, "end_line": 57, "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": 60, "end_line": 64, "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": 67, "end_line": 71, "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": 74, "end_line": 77, "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": 78, "end_line": 79, "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": 80, "end_line": 81, "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": 82, "end_line": 83, "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": 86, "end_line": 87, "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": 88, "end_line": 89, "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": 90, "end_line": 91, "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": 94, "end_line": 97, "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": 98, "end_line": 99, "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": 100, "end_line": 101, "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": 102, "end_line": 103, "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": 106, "end_line": 107, "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": 108, "end_line": 109, "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": 110, "end_line": 111, "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": 114, "end_line": 117, "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": 118, "end_line": 119, "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": 120, "end_line": 121, "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": 122, "end_line": 123, "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": 124, "end_line": 125, "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": 126, "end_line": 127, "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": 133, "end_line": 137, "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": 140, "end_line": 144, "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": 147, "end_line": 151, "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": 152, "end_line": 154, "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": 155, "end_line": 157, "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": 158, "end_line": 163, "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": 164, "end_line": 168, "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": 177, "end_line": 185, "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": 190, "end_line": 209, "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": 211, "end_line": 215, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 184, "complexity": 45, "token_count": 1706, "diff_parsed": { "added": [ "import scipy_base;reload(scipy_base)" ], "deleted": [] } } ] }, { "hash": "100d58f80cdc5ba6bf64343dd0004a41fba6d8a9", "msg": "Moving general_function from scipy.special to scipy_base", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-20T19:20:57+00:00", "author_timezone": 0, "committer_date": "2003-09-20T19:20:57+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "19d33f72fd0e05ba7156b8874b269be8e605bb29" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 0, "insertions": 646, "lines": 646, "files": 5, "dmm_unit_size": 0.25679012345679014, "dmm_unit_complexity": 0.20493827160493827, "dmm_unit_interfacing": 0.38765432098765434, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -94,6 +94,10 @@\n polydiv -- Divide polynomials\n polyval -- Evaluate polynomial at given argument\n \n+General functions\n+=================\n+general_function -- Generalized Function class\n+\n Import tricks\n =============\n ppimport -- Postpone module import until trying to use it\n@@ -130,6 +134,7 @@\n \n from polynomial import *\n from scimath import *\n+from general_function import *\n \n Inf = inf = fastumath.PINF\n try:\n", "added_lines": 5, "deleted_lines": 0, "source_code": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nGeneral functions\n=================\ngeneral_function -- Generalized Function class\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\n\"\"\"\n\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 general_function 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", "source_code_before": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\n\"\"\"\n\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 *\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": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 147, "end_line": 151, "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": 153, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 142, "end_line": 146, "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": 148, "end_line": 155, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 140, "complexity": 2, "token_count": 178, "diff_parsed": { "added": [ "General functions", "=================", "general_function -- Generalized Function class", "", "from general_function import *" ], "deleted": [] } }, { "old_path": null, "new_path": "scipy_base/arraymapmodule.c", "filename": "arraymapmodule.c", "extension": "c", "change_type": "ADD", "diff": "@@ -0,0 +1,496 @@\n+/* Arraymap module\n+ * Copyright 1999 Travis E. Oliphant\n+ */\n+\n+#include \"Python.h\"\n+#include \"Numeric/arrayobject.h\"\n+\n+/* Decrement the reference count of all objects in **arrays. */\n+static 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 */\n+static 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+\n+static 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+\n+static 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 */\n+static 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+\n+static 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+\n+static 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 > 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 > maxrank) maxrank = ain->nd;", " inputarrays[i] = ain;", " }", "", " maxdims = (int*)malloc(2*sizeof(int)*maxrank);", " if (NULL == maxdims) {", " PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");", " cleanup_arrays(inputarrays,nin);", " return -1;", " }", "", "", " /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */", " /* We want to replace the header information without copying the data.", " Keeping the reference count correct can be tricky.", " We want to make a new array object with a different header and decrease the", " reference count of the old one without deallocating the data section */", " for (i=0; i < nin; i++) {", " ain = inputarrays[i];", "", " /* Initialize all dimensions to 1 */", " /* Change array shape */", " for (k=0; k < maxrank; k++)", " maxdims[k] = 1;", " for (k=maxrank-ain->nd; k< maxrank; k++)", " maxdims[k] = ain->dimensions[k-maxrank+ain->nd];", "", " tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);", " if (NULL == tmparray) {", " free(maxdims);", " cleanup_arrays(inputarrays,nin);", " return -1;", " }", " memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);", " tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */", " inputarrays[i] = tmparray; /* tmparray is new array */", " }", "", " /* Find dimension length for the output arrays (maximum length for each", " dimension) */", " for (k=0; k < maxrank; k++) {", " maxdims[k] = 1;", " for (i=0; i < nin; i++)", " if (inputarrays[i]->dimensions[k] > maxdims[k])", "\tmaxdims[k] = inputarrays[i]->dimensions[k];", " }", "", " /* Now set all lengths for input array dimensions to maxdims", " and make strides equal to zero for arrays whose", " real length is 1 for a particular dimension", " */", "", " for (i=0; idimensions[k]) {", "\tain->strides[k] = 0;", "\tain->dimensions[k] = maxdims[k];", " }", " else if (ain->dimensions[k] != maxdims[k]) {", "\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");", "\tcleanup_arrays(inputarrays,nin);", "\tfree(maxdims);", "\treturn -1;", " }", " }", " }", "", " free(maxdims);", " return 0;", "", "}", "", "static int type_from_object(PyObject *obj)", "{", " if (PyArray_Check(obj))", " return ((PyArrayObject *)obj)->descr->type_num;", " if (PyComplex_Check(obj)) return PyArray_CDOUBLE;", " if (PyFloat_Check(obj)) return PyArray_DOUBLE;", " if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;", " PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");", " return -1;", "}", "", "static int type_from_char(char typechar)", "{", " switch(typechar) {", " case 'c': return PyArray_CHAR;", " case 'b': return PyArray_UBYTE;", " case '1': return PyArray_SBYTE;", " case 's': return PyArray_SHORT;", " case 'i': return PyArray_INT;", "#ifdef PyArray_UNSIGNED_TYPES", " case 'w': return PyArray_USHORT;", " case 'u': return PyArray_UINT;", "#endif", " case 'l': return PyArray_LONG;", " case 'f': return PyArray_FLOAT;", " case 'd': return PyArray_DOUBLE;", " case 'F': return PyArray_CFLOAT;", " case 'D': return PyArray_CDOUBLE;", " default:", " PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");", " return -1;", " }", "}", "", "", "", "/* This sets up the output arrays by calling the function with arguments", " the first element of each input arrays. If otypes is NULL, the", " returned value type is used to establish the type of the output", " arrays, otherwise the characters in otypes determine the", " output types */", "static int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)", "{", " PyObject *arglist, *result;", " PyObject *tmpobject;", " PyArrayObject *tmparr;", " int i, nout;", " int nd, *dimensions, type_num;", "", " nd = inarr[0]->nd;", " dimensions = inarr[0]->dimensions;", "", " if ((numtypes == 0) || (otypes == NULL)) {", " /* Call function to get number of outputs */", "", " /* Build argument list */", " if ((arglist = PyTuple_New(nin)) == NULL) {", " return -1;", " }", " /* Construct input argument by creating a tuple with an element", " from each input array (cast to an appropriate Python Object) */", " for (i=0; i < nin; i++) {", " tmparr = inarr[i];", " /* Get first data point */", " tmpobject = tmparr->descr->getitem((void *)tmparr->data);", " if (NULL == tmpobject) {", "\tPy_DECREF(arglist);", "\treturn -1;", " }", " PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */", " }", " /* Call Python Function */", " if ((result=PyEval_CallObject(func, arglist))==NULL) {", " Py_DECREF(arglist);", " return -1;", " }", "", " Py_DECREF(arglist);", "", " /* If result is a tuple, create output_arrays according", " to output. */", " if (PyTuple_Check(result)) {", " nout = PyTuple_GET_SIZE(result);", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL == *outarr) {", "\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");", "\tPy_DECREF(result);", "\treturn -1;", " }", " /* Create nout output arrays */", " for (i=0; i < nout; i++) {", "\t/* Determine type */", "\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {", "\t cleanup_arrays(*outarr,i);", "\t Py_DECREF(result);", "\t free(*outarr);", "\t return -1;", "\t}", "\t/* Create output array */", "\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", "\tif (NULL == (*outarr)[i]) {", "\t cleanup_arrays(*outarr,i);", "\t Py_DECREF(result);", "\t free(*outarr);", "\t return -1;", "\t}", " }", " }", " else { /* Only a single output result */", " nout = 1;", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL==*outarr) {", "\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");", "\tPy_DECREF(result);", "\treturn -1;", " }", " if ((type_num = type_from_object(result))==-1) {", "\tPy_DECREF(result);", "\tfree(*outarr);", "\treturn -1;", " }", " (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", " if (NULL == (*outarr)[0]) {", "\tPy_DECREF(result);", "\tfree(*outarr);", "\treturn -1;", " }", " }", " Py_DECREF(result);", " }", "", " else { /* Character output types entered */", " nout = numtypes;", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL==*outarr) {", " PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");", " return -1;", " }", " /* Create Output arrays */", " for (i=0; i < nout; i++) {", " /* Get type */", " if ((type_num = type_from_char(otypes[i]))==-1) {", "\tcleanup_arrays(*outarr,i);", "\tfree(*outarr);", "\treturn -1;", " }", " /* Create array */", " (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", " if (NULL == (*outarr)[i]) {", "\tcleanup_arrays(*outarr,i);", "\tfree(*outarr);", "\treturn -1;", " }", " }", " }", " return nout;", "}", "", "", "/* Corresponding dimensions are assumed to match, check before calling. */", "/* No rank-0 arrays (make them rank-1 arrays) */", "", "/* This replicates the standard Ufunc broadcasting rule that if the", " dimension length is one, incrementing does not occur for that dimension.", "", " This is currently done by setting the stride in that dimension to", " zero during input array setup.", "", " The purpose of this function is to perform a for loop over arbitrary", " discontiguous N-D arrays, call the Python function for each set of", " corresponding elements and place the results in the output_array.", "*/", "#define INCREMENT(ret_ind, nd, max_ind) \\", "{ \\", " int k; \\", " k = (nd) - 1; \\", " if (++(ret_ind)[k] >= (max_ind)[k]) { \\", " while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\", " (ret_ind)[k--] = 0; \\", " if (k >= 0) (ret_ind)[k]++; \\", " else (ret_ind)[0] = (max_ind)[0]; \\", " } \\", "}", "", "#define CALCINDEX(indx, nd_index, strides, ndim) \\", "{ \\", " int i; \\", " \\", " indx = 0; \\", " for (i=0; i < (ndim); i++) \\", " indx += (nd_index)[i]*(strides)[i]; \\", "}", "", "static int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)", "{", " int i, loop_index;", " int *nd_index, indx_in, indx_out;", " PyArrayObject *in, *out, *tmparr;", " PyObject *result, *tmpobj, *arglist;", "", " in = inarr[0]; /* For any shape information needed */", " out = outarr[0];", " /* Allocate the N-D index initalized to zero. */", " nd_index = (int *)calloc(in->nd,sizeof(int));", " if (NULL == nd_index) {", " PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");", " return -1;", " }", " /* Build argument list */", " if ((arglist = PyTuple_New(nin)) == NULL) {", " free(nd_index);", " return -1;", " }", "", " loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */", "", " while(loop_index--) {", " /* Create input argument list with current element from the input", " arrays", " */", " for (i=0; i < nin; i++) {", " tmparr = inarr[i];", " /* Find linear index into this input array */", " CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);", " /* Get object at this index */", " tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));", " if (NULL == tmpobj) {", "\tPy_DECREF(arglist);", "\tfree(nd_index);", "\treturn -1;", " }", " /* This steals reference of tmpobj */", " PyTuple_SET_ITEM(arglist, i, tmpobj);", " }", " /* Call Python Function for this set of inputs */", " if ((result=PyEval_CallObject(func, arglist))==NULL) {", " Py_DECREF(arglist);", " free(nd_index);", " return -1;", " }", "", " /* Find index into (all) output arrays */", " CALCINDEX(indx_out,nd_index,out->strides,out->nd);", "", " /* Copy the results to the output arrays */", " if (1==nout) {", " if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {", "\tfree(nd_index);", "\tPy_DECREF(arglist);", "\tPy_DECREF(result);", "\treturn -1;", " }", " }", " else if (PyTuple_Check(result)) {", " for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {", "\t free(nd_index);", "\t Py_DECREF(arglist);", "\t Py_DECREF(result);", " return -1;", "\t}", " }", " }", " else {", " PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");", " free(nd_index);", " Py_DECREF(arglist);", " Py_DECREF(result);", " return -1;", " }", "", " /* Increment the index counter */", " INCREMENT(nd_index,in->nd,in->dimensions);", " Py_DECREF(result);", "", " }", " Py_DECREF(arglist);", " free(nd_index);", " return 0;", "}", "", "static PyObject *build_output(PyArrayObject **outarr,int nout)", "{", " int i;", " PyObject *out;", "", " if (1==nout) return PyArray_Return(outarr[0]);", " if ((out=PyTuple_New(nout))==NULL) return NULL;", " for (i=0; i b:\n+ return a-b\n+ else\n+ return a+b\n+\n+ gfunc = general_function(myfunc)\n+\n+ >>> gfunc([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+\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": 97, "deleted_lines": 0, "source_code": "#\n# Author: Travis Oliphant\n#\n\nfrom Numeric import *\nimport types\nfrom arraymap import arraymap\nfrom shape_base import squeeze,atleast_1d\nfrom type_check import isscalar\n\n__all__ = ['general_function']\n\nclass general_function:\n \"\"\"\n general_function(somefunction) Generalized Function class.\n\n Description:\n \n Define a generalized 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 gfunc = general_function(myfunc)\n\n >>> gfunc([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", "source_code_before": null, "methods": [ { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "general_function.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 43, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "general_function.py", "nloc": 9, "complexity": 4, "token_count": 59, "parameters": [ "self", "args" ], "start_line": 59, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , args )", "filename": "general_function.py", "nloc": 14, "complexity": 4, "token_count": 102, "parameters": [ "self", "args" ], "start_line": 69, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 91, "end_line": 93, "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": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 95, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "general_function.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 43, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , args )", "filename": "general_function.py", "nloc": 14, "complexity": 4, "token_count": 102, "parameters": [ "self", "args" ], "start_line": 69, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 95, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "general_function.py", "nloc": 9, "complexity": 4, "token_count": 59, "parameters": [ "self", "args" ], "start_line": 59, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": 80, "complexity": 16, "token_count": 334, "diff_parsed": { "added": [ "#", "# Author: Travis Oliphant", "#", "", "from Numeric import *", "import types", "from arraymap import arraymap", "from shape_base import squeeze,atleast_1d", "from type_check import isscalar", "", "__all__ = ['general_function']", "", "class general_function:", " \"\"\"", " general_function(somefunction) Generalized Function class.", "", " Description:", "", " Define a generalized function which takes nested sequence", " objects or Numeric arrays as inputs and returns a", " Numeric array as output, evaluating the function over successive", " tuples of the input arrays like the python map function except it uses", " the broadcasting rules of Numeric Python.", "", " Input:", "", " somefunction -- a Python function or method", "", " Example:", "", " def myfunc(a,b):", " if a > b:", " return a-b", " else", " return a+b", "", " gfunc = general_function(myfunc)", "", " >>> gfunc([1,2,3,4],2)", " array([3,4,1,2])", "", " \"\"\"", " def __init__(self,pyfunc,otypes=None,doc=None):", " if not callable(pyfunc) or type(pyfunc) is types.ClassType:", " raise TypeError, \"Object is not a callable Python object.\"", " self.thefunc = pyfunc", " if doc is None:", " self.__doc__ = pyfunc.__doc__", " else:", " self.__doc__ = doc", " if otypes is None:", " self.otypes=''", " else:", " if isinstance(otypes,types.StringType):", " self.otypes=otypes", " else:", " raise ValueError, \"Output types must be a string.\"", "", " def __call__(self,*args):", " for arg in args:", " try:", " n = len(arg)", " if (n==0):", " return self.zerocall(args)", " except (AttributeError, TypeError):", " pass", " return squeeze(arraymap(self.thefunc,args,self.otypes))", "", " def zerocall(self,args):", " # one of the args was a zeros array", " # return zeros for each output", " # first --- find number of outputs", " newargs = []", " args = atleast_1d(*args)", " for arg in args:", " if arg.typecode() != 'O':", " newargs.append(1.1)", " else:", " newargs.append(arg[0])", " newargs = tuple(newargs)", " res = self.thefunc(*newargs)", " if isscalar(res):", " return zeros((0,),'d')", " else:", " return (zeros((0,),'d'),)*len(res)", "", "#-----------------------------------------------------------------------------", "# 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)" ], "deleted": [] } }, { "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": "@@ -29,6 +29,12 @@ def configuration(parent_package=''):\n ext = Extension(dot_join(package,'_compiled_base'),sources,libraries=[])\n config['ext_modules'].append(ext)\n \n+ # scipy_base.arraymap module\n+ sources = ['arraymapmodule.c']\n+ sources = [os.path.join(local_path,x) for x in sources]\n+ ext = Extension(dot_join(package,'arraymap'),sources,libraries=[])\n+ config['ext_modules'].append(ext)\n+\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n", "added_lines": 6, "deleted_lines": 0, "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 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 ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\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,libraries=[])\n config['ext_modules'].append(ext)\n\n # scipy_base.arraymap module\n sources = ['arraymapmodule.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension(dot_join(package,'arraymap'),sources,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n os.path.join(local_path,'mconf_lite.h'))\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 ext = Extension(dot_join(package,'fastumath'),sources,libraries=[],\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,libraries=[])\n config['ext_modules'].append(ext)\n\n # Test to see if big or little-endian machine and get correct default\n # mconf.h module.\n if sys.byteorder == \"little\":\n print \"### Little Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_LE.h'),\n os.path.join(local_path,'mconf_lite.h'))\n else:\n print \"### Big Endian detected ####\"\n shutil.copy2(os.path.join(local_path,'mconf_lite_BE.h'),\n os.path.join(local_path,'mconf_lite.h'))\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": 27, "complexity": 5, "token_count": 251, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "methods_before": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 23, "complexity": 4, "token_count": 201, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 42, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 34, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "configuration", "long_name": "configuration( parent_package = '' )", "filename": "setup_scipy_base.py", "nloc": 27, "complexity": 5, "token_count": 251, "parameters": [ "parent_package" ], "start_line": 9, "end_line": 48, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 40, "top_nesting_level": 0 } ], "nloc": 46, "complexity": 5, "token_count": 341, "diff_parsed": { "added": [ " # scipy_base.arraymap module", " sources = ['arraymapmodule.c']", " sources = [os.path.join(local_path,x) for x in sources]", " ext = Extension(dot_join(package,'arraymap'),sources,libraries=[])", " config['ext_modules'].append(ext)", "" ], "deleted": [] } }, { "old_path": null, "new_path": "scipy_base/tests/test_general_function.py", "filename": "test_general_function.py", "extension": "py", "change_type": "ADD", "diff": "@@ -0,0 +1,42 @@\n+import sys\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+from scipy_test.testing import set_package_path\n+set_package_path()\n+import scipy_base;reload(scipy_base)\n+from scipy_base import *\n+del sys.path[0]\n+\n+class test_general_function(unittest.TestCase):\n+\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 = general_function(addsubtract)\n+ r = f([0,3,6,9],[1,3,5,7])\n+ assert_array_equal(r,[1,6,1,2])\n+\n+####### Testing ##############\n+\n+def test_suite(level=1):\n+ suites = []\n+ if level > 0:\n+ suites.append( unittest.makeSuite(test_general_function,'check_') )\n+ if level > 5:\n+\tpass\n+ total_suite = unittest.TestSuite(suites)\n+ return total_suite\n+\n+def test(level=10,verbosity=2):\n+ all_tests = test_suite(level=level)\n+ runner = unittest.TextTestRunner(verbosity=verbosity)\n+ runner.run(all_tests)\n+ return runner\n+\n+if __name__ == \"__main__\":\n+ test()\n", "added_lines": 42, "deleted_lines": 0, "source_code": "import sys\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\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_general_function(unittest.TestCase):\n\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 = general_function(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n\n####### Testing ##############\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_general_function,'check_') )\n if level > 5:\n\tpass\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbosity=2):\n all_tests = test_suite(level=level)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "source_code_before": null, "methods": [ { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_general_function.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 15, "end_line": 19, "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_general_function.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 14, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_general_function.py", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "level" ], "start_line": 26, "end_line": 33, "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_general_function.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "level", "verbosity" ], "start_line": 35, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "methods_before": [], "changed_methods": [ { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_general_function.py", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "level" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_general_function.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 14, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_general_function.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 15, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "test", "long_name": "test( level = 10 , verbosity = 2 )", "filename": "test_general_function.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "level", "verbosity" ], "start_line": 35, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": 34, "complexity": 7, "token_count": 220, "diff_parsed": { "added": [ "import sys", "import unittest", "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", "set_package_path()", "import scipy_base;reload(scipy_base)", "from scipy_base import *", "del sys.path[0]", "", "class test_general_function(unittest.TestCase):", "", " def check_simple(self):", " def addsubtract(a,b):", " if a > b:", " return a - b", " else:", " return a + b", " f = general_function(addsubtract)", " r = f([0,3,6,9],[1,3,5,7])", " assert_array_equal(r,[1,6,1,2])", "", "####### Testing ##############", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_general_function,'check_') )", " if level > 5:", "\tpass", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbosity=2):", " all_tests = test_suite(level=level)", " runner = unittest.TextTestRunner(verbosity=verbosity)", " runner.run(all_tests)", " return runner", "", "if __name__ == \"__main__\":", " test()" ], "deleted": [] } } ] }, { "hash": "ba4e597baba7c3dd57431414d0bee0db9d0f3af9", "msg": "Moved arraymap from cephes to scipy_base. Renamed from general_function to vectorize", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-20T19:30:27+00:00", "author_timezone": 0, "committer_date": "2003-09-20T19:30:27+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "100d58f80cdc5ba6bf64343dd0004a41fba6d8a9" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 7, "insertions": 560, "lines": 567, "files": 4, "dmm_unit_size": 0.1880108991825613, "dmm_unit_complexity": 0.1226158038147139, "dmm_unit_interfacing": 0.3242506811989101, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -55,6 +55,11 @@\n sort_complex -- Sort a complex-array (based on real, then imaginary)\n trim_zeros -- trim the leading and trailing zeros from 1D array.\n \n+vectorize -- a class that wraps a Python function taking scalar\n+ arguments into a generalized function which\n+ can handle arrays of arguments using the broadcast\n+ rules of Numeric Python.\n+\n Shape manipulation\n ===================\n squeeze -- Return a with length-one dimensions removed.\n", "added_lines": 5, "deleted_lines": 0, "source_code": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nvectorize -- a class that wraps a Python function taking scalar\n arguments into a generalized function which\n can handle arrays of arguments using the broadcast\n rules of Numeric Python.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nGeneral functions\n=================\ngeneral_function -- Generalized Function class\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\n\"\"\"\n\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 general_function 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", "source_code_before": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nGeneral functions\n=================\ngeneral_function -- Generalized Function class\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\n\"\"\"\n\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 general_function 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": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 152, "end_line": 156, "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": 158, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 147, "end_line": 151, "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": 153, "end_line": 160, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 145, "complexity": 2, "token_count": 178, "diff_parsed": { "added": [ "vectorize -- a class that wraps a Python function taking scalar", " arguments into a generalized function which", " can handle arrays of arguments using the broadcast", " rules of Numeric Python.", "" ], "deleted": [] } }, { "old_path": "scipy_base/_compiled_base.c", "new_path": "scipy_base/_compiled_base.c", "filename": "_compiled_base.c", "extension": "c", "change_type": "MODIFY", "diff": "@@ -202,9 +202,470 @@ static PyObject *base_insert(PyObject *self, PyObject *args, PyObject *kwdict)\n }\n \n \n+/* Decrement the reference count of all objects in **arrays. */\n+static 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 */\n+static 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+\n+static 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+\n+static 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 */\n+static 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+\n+static 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+\n+static 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 > 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/* Initialization function for the module (*must* be called initArray) */\n\nstatic struct PyMethodDef methods[] = {\n {\"_unique\",\t (PyCFunction)base_unique, METH_VARARGS | METH_KEYWORDS, doc_base_unique},\n {\"_insert\",\t (PyCFunction)base_insert, METH_VARARGS | METH_KEYWORDS, doc_base_insert},\n {NULL, NULL} /* sentinel */\n};\n\nDL_EXPORT(void) init_compiled_base(void) {\n PyObject *m, *d, *s;\n \n /* Create the module and add the functions */\n m = Py_InitModule(\"_compiled_base\", methods); \n\n /* Import the array and ufunc objects */\n import_array();\n\n /* Add some symbolic constants to the module */\n d = PyModule_GetDict(m);\n\n s = PyString_FromString(\"0.2\");\n PyDict_SetItemString(d, \"__version__\", s);\n Py_DECREF(s);\n\n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module _compiled_base\");\n}\n\n", "methods": [ { "name": "base_unique", "long_name": "base_unique( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 55, "complexity": 11, "token_count": 381, "parameters": [ "self", "args", "kwdict" ], "start_line": 8, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "base_insert", "long_name": "base_insert( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 89, "complexity": 21, "token_count": 709, "parameters": [ "self", "args", "kwdict" ], "start_line": 81, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 }, { "name": "cleanup_arrays", "long_name": "cleanup_arrays( PyArrayObject ** arrays , int number)", "filename": "_compiled_base.c", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "arrays", "number" ], "start_line": 206, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "setup_input_arrays", "long_name": "setup_input_arrays( PyTupleObject * inputs , PyArrayObject ** inputarrays , int nin)", "filename": "_compiled_base.c", "nloc": 69, "complexity": 17, "token_count": 550, "parameters": [ "inputs", "inputarrays", "nin" ], "start_line": 222, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "type_from_object", "long_name": "type_from_object( PyObject * obj)", "filename": "_compiled_base.c", "nloc": 10, "complexity": 6, "token_count": 74, "parameters": [ "obj" ], "start_line": 318, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "type_from_char", "long_name": "type_from_char( char typechar)", "filename": "_compiled_base.c", "nloc": 20, "complexity": 14, "token_count": 98, "parameters": [ "typechar" ], "start_line": 329, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "setup_output_arrays", "long_name": "setup_output_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** * outarr , char * otypes , int numtypes)", "filename": "_compiled_base.c", "nloc": 96, "complexity": 19, "token_count": 669, "parameters": [ "func", "inarr", "nin", "outarr", "otypes", "numtypes" ], "start_line": 359, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 }, { "name": "loop_over_arrays", "long_name": "loop_over_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 68, "complexity": 12, "token_count": 483, "parameters": [ "func", "inarr", "nin", "outarr", "nout" ], "start_line": 511, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 87, "top_nesting_level": 0 }, { "name": "build_output", "long_name": "build_output( PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 9, "complexity": 4, "token_count": 83, "parameters": [ "outarr", "nout" ], "start_line": 599, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "map_PyFunc", "long_name": "map_PyFunc( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 44, "complexity": 8, "token_count": 300, "parameters": [ "self", "args" ], "start_line": 612, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "init_compiled_base", "long_name": "init_compiled_base()", "filename": "_compiled_base.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 674, "end_line": 693, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "methods_before": [ { "name": "base_unique", "long_name": "base_unique( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 55, "complexity": 11, "token_count": 381, "parameters": [ "self", "args", "kwdict" ], "start_line": 8, "end_line": 76, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 69, "top_nesting_level": 0 }, { "name": "base_insert", "long_name": "base_insert( PyObject * self , PyObject * args , PyObject * kwdict)", "filename": "_compiled_base.c", "nloc": 89, "complexity": 21, "token_count": 709, "parameters": [ "self", "args", "kwdict" ], "start_line": 81, "end_line": 202, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 122, "top_nesting_level": 0 }, { "name": "init_compiled_base", "long_name": "init_compiled_base()", "filename": "_compiled_base.c", "nloc": 11, "complexity": 2, "token_count": 67, "parameters": [], "start_line": 213, "end_line": 232, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "build_output", "long_name": "build_output( PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 9, "complexity": 4, "token_count": 83, "parameters": [ "outarr", "nout" ], "start_line": 599, "end_line": 608, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "type_from_object", "long_name": "type_from_object( PyObject * obj)", "filename": "_compiled_base.c", "nloc": 10, "complexity": 6, "token_count": 74, "parameters": [ "obj" ], "start_line": 318, "end_line": 327, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 10, "top_nesting_level": 0 }, { "name": "setup_input_arrays", "long_name": "setup_input_arrays( PyTupleObject * inputs , PyArrayObject ** inputarrays , int nin)", "filename": "_compiled_base.c", "nloc": 69, "complexity": 17, "token_count": 550, "parameters": [ "inputs", "inputarrays", "nin" ], "start_line": 222, "end_line": 316, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 95, "top_nesting_level": 0 }, { "name": "type_from_char", "long_name": "type_from_char( char typechar)", "filename": "_compiled_base.c", "nloc": 20, "complexity": 14, "token_count": 98, "parameters": [ "typechar" ], "start_line": 329, "end_line": 350, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 22, "top_nesting_level": 0 }, { "name": "cleanup_arrays", "long_name": "cleanup_arrays( PyArrayObject ** arrays , int number)", "filename": "_compiled_base.c", "nloc": 7, "complexity": 2, "token_count": 41, "parameters": [ "arrays", "number" ], "start_line": 206, "end_line": 212, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "loop_over_arrays", "long_name": "loop_over_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** outarr , int nout)", "filename": "_compiled_base.c", "nloc": 68, "complexity": 12, "token_count": 483, "parameters": [ "func", "inarr", "nin", "outarr", "nout" ], "start_line": 511, "end_line": 597, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 87, "top_nesting_level": 0 }, { "name": "map_PyFunc", "long_name": "map_PyFunc( PyObject * self , PyObject * args)", "filename": "_compiled_base.c", "nloc": 44, "complexity": 8, "token_count": 300, "parameters": [ "self", "args" ], "start_line": 612, "end_line": 662, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 51, "top_nesting_level": 0 }, { "name": "setup_output_arrays", "long_name": "setup_output_arrays( PyObject * func , PyArrayObject ** inarr , int nin , PyArrayObject ** * outarr , char * otypes , int numtypes)", "filename": "_compiled_base.c", "nloc": 96, "complexity": 19, "token_count": 669, "parameters": [ "func", "inarr", "nin", "outarr", "otypes", "numtypes" ], "start_line": 359, "end_line": 474, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 116, "top_nesting_level": 0 } ], "nloc": 489, "complexity": 116, "token_count": 3567, "diff_parsed": { "added": [ "/* Decrement the reference count of all objects in **arrays. */", "static void cleanup_arrays(PyArrayObject **arrays, int number)", "{", " int k;", " for (k=0; k < number; k++)", " Py_XDECREF((PyObject *)arrays[k]);", " return;", "}", "", "/* All rank-0 arrays are converted to rank-1 arrays */", "/* The number of dimensions of each array with rank less than", " the rank of the array with the most dimensions is increased by", " prepending with a dimenson length of one so that all arrays have", " the same rank. */", "/* Dimensions are checked and unmatched dimensions triggers an error */", "/* Strides for dimensions whose real length is one is set to zero but the dimension", " length is set to the maximum dimensions for the collection of inputs */", "static int setup_input_arrays(PyTupleObject *inputs, PyArrayObject **inputarrays, int nin)", "{", " int i, k;", " int maxrank=1;", " int *maxdims;", " PyObject *inputobj;", " PyArrayObject *ain, *tmparray;", "", " /* Convert nested sequences to arrays or just increase reference count", " if already an array */", " for (i=0; i < nin; i++) {", " ain = NULL;", " inputobj = PyTuple_GET_ITEM(inputs,i);", " ain = (PyArrayObject *)PyArray_FromObject(inputobj,PyArray_ObjectType(inputobj,0),0,0);", " if (NULL == ain) {", " cleanup_arrays(inputarrays,i);", " return -1;", " }", " if (PyArray_SIZE(ain)==0) {", " cleanup_arrays(inputarrays,i);", " PyErr_SetString(PyExc_ValueError,\"arraymap: Input arrays of zero-dimensions not supported.\");", " return -1;", " }", " if (ain->nd > maxrank) maxrank = ain->nd;", " inputarrays[i] = ain;", " }", "", " maxdims = (int*)malloc(2*sizeof(int)*maxrank);", " if (NULL == maxdims) {", " PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");", " cleanup_arrays(inputarrays,nin);", " return -1;", " }", "", "", " /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */", " /* We want to replace the header information without copying the data.", " Keeping the reference count correct can be tricky.", " We want to make a new array object with a different header and decrease the", " reference count of the old one without deallocating the data section */", " for (i=0; i < nin; i++) {", " ain = inputarrays[i];", "", " /* Initialize all dimensions to 1 */", " /* Change array shape */", " for (k=0; k < maxrank; k++)", " maxdims[k] = 1;", " for (k=maxrank-ain->nd; k< maxrank; k++)", " maxdims[k] = ain->dimensions[k-maxrank+ain->nd];", "", " tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);", " if (NULL == tmparray) {", " free(maxdims);", " cleanup_arrays(inputarrays,nin);", " return -1;", " }", " memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);", " tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */", " inputarrays[i] = tmparray; /* tmparray is new array */", " }", "", " /* Find dimension length for the output arrays (maximum length for each", " dimension) */", " for (k=0; k < maxrank; k++) {", " maxdims[k] = 1;", " for (i=0; i < nin; i++)", " if (inputarrays[i]->dimensions[k] > maxdims[k])", "\tmaxdims[k] = inputarrays[i]->dimensions[k];", " }", "", " /* Now set all lengths for input array dimensions to maxdims", " and make strides equal to zero for arrays whose", " real length is 1 for a particular dimension", " */", "", " for (i=0; idimensions[k]) {", "\tain->strides[k] = 0;", "\tain->dimensions[k] = maxdims[k];", " }", " else if (ain->dimensions[k] != maxdims[k]) {", "\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");", "\tcleanup_arrays(inputarrays,nin);", "\tfree(maxdims);", "\treturn -1;", " }", " }", " }", "", " free(maxdims);", " return 0;", "", "}", "", "static int type_from_object(PyObject *obj)", "{", " if (PyArray_Check(obj))", " return ((PyArrayObject *)obj)->descr->type_num;", " if (PyComplex_Check(obj)) return PyArray_CDOUBLE;", " if (PyFloat_Check(obj)) return PyArray_DOUBLE;", " if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;", " PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");", " return -1;", "}", "", "static int type_from_char(char typechar)", "{", " switch(typechar) {", " case 'c': return PyArray_CHAR;", " case 'b': return PyArray_UBYTE;", " case '1': return PyArray_SBYTE;", " case 's': return PyArray_SHORT;", " case 'i': return PyArray_INT;", "#ifdef PyArray_UNSIGNED_TYPES", " case 'w': return PyArray_USHORT;", " case 'u': return PyArray_UINT;", "#endif", " case 'l': return PyArray_LONG;", " case 'f': return PyArray_FLOAT;", " case 'd': return PyArray_DOUBLE;", " case 'F': return PyArray_CFLOAT;", " case 'D': return PyArray_CDOUBLE;", " default:", " PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");", " return -1;", " }", "}", "", "", "", "/* This sets up the output arrays by calling the function with arguments", " the first element of each input arrays. If otypes is NULL, the", " returned value type is used to establish the type of the output", " arrays, otherwise the characters in otypes determine the", " output types */", "static int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)", "{", " PyObject *arglist, *result;", " PyObject *tmpobject;", " PyArrayObject *tmparr;", " int i, nout;", " int nd, *dimensions, type_num;", "", " nd = inarr[0]->nd;", " dimensions = inarr[0]->dimensions;", "", " if ((numtypes == 0) || (otypes == NULL)) {", " /* Call function to get number of outputs */", "", " /* Build argument list */", " if ((arglist = PyTuple_New(nin)) == NULL) {", " return -1;", " }", " /* Construct input argument by creating a tuple with an element", " from each input array (cast to an appropriate Python Object) */", " for (i=0; i < nin; i++) {", " tmparr = inarr[i];", " /* Get first data point */", " tmpobject = tmparr->descr->getitem((void *)tmparr->data);", " if (NULL == tmpobject) {", "\tPy_DECREF(arglist);", "\treturn -1;", " }", " PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */", " }", " /* Call Python Function */", " if ((result=PyEval_CallObject(func, arglist))==NULL) {", " Py_DECREF(arglist);", " return -1;", " }", "", " Py_DECREF(arglist);", "", " /* If result is a tuple, create output_arrays according", " to output. */", " if (PyTuple_Check(result)) {", " nout = PyTuple_GET_SIZE(result);", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL == *outarr) {", "\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");", "\tPy_DECREF(result);", "\treturn -1;", " }", " /* Create nout output arrays */", " for (i=0; i < nout; i++) {", "\t/* Determine type */", "\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {", "\t cleanup_arrays(*outarr,i);", "\t Py_DECREF(result);", "\t free(*outarr);", "\t return -1;", "\t}", "\t/* Create output array */", "\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", "\tif (NULL == (*outarr)[i]) {", "\t cleanup_arrays(*outarr,i);", "\t Py_DECREF(result);", "\t free(*outarr);", "\t return -1;", "\t}", " }", " }", " else { /* Only a single output result */", " nout = 1;", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL==*outarr) {", "\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");", "\tPy_DECREF(result);", "\treturn -1;", " }", " if ((type_num = type_from_object(result))==-1) {", "\tPy_DECREF(result);", "\tfree(*outarr);", "\treturn -1;", " }", " (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", " if (NULL == (*outarr)[0]) {", "\tPy_DECREF(result);", "\tfree(*outarr);", "\treturn -1;", " }", " }", " Py_DECREF(result);", " }", "", " else { /* Character output types entered */", " nout = numtypes;", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL==*outarr) {", " PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");", " return -1;", " }", " /* Create Output arrays */", " for (i=0; i < nout; i++) {", " /* Get type */", " if ((type_num = type_from_char(otypes[i]))==-1) {", "\tcleanup_arrays(*outarr,i);", "\tfree(*outarr);", "\treturn -1;", " }", " /* Create array */", " (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", " if (NULL == (*outarr)[i]) {", "\tcleanup_arrays(*outarr,i);", "\tfree(*outarr);", "\treturn -1;", " }", " }", " }", " return nout;", "}", "", "", "/* Corresponding dimensions are assumed to match, check before calling. */", "/* No rank-0 arrays (make them rank-1 arrays) */", "", "/* This replicates the standard Ufunc broadcasting rule that if the", " dimension length is one, incrementing does not occur for that dimension.", "", " This is currently done by setting the stride in that dimension to", " zero during input array setup.", "", " The purpose of this function is to perform a for loop over arbitrary", " discontiguous N-D arrays, call the Python function for each set of", " corresponding elements and place the results in the output_array.", "*/", "#define INCREMENT(ret_ind, nd, max_ind) \\", "{ \\", " int k; \\", " k = (nd) - 1; \\", " if (++(ret_ind)[k] >= (max_ind)[k]) { \\", " while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\", " (ret_ind)[k--] = 0; \\", " if (k >= 0) (ret_ind)[k]++; \\", " else (ret_ind)[0] = (max_ind)[0]; \\", " } \\", "}", "", "#define CALCINDEX(indx, nd_index, strides, ndim) \\", "{ \\", " int i; \\", " \\", " indx = 0; \\", " for (i=0; i < (ndim); i++) \\", " indx += (nd_index)[i]*(strides)[i]; \\", "}", "", "static int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)", "{", " int i, loop_index;", " int *nd_index, indx_in, indx_out;", " PyArrayObject *in, *out, *tmparr;", " PyObject *result, *tmpobj, *arglist;", "", " in = inarr[0]; /* For any shape information needed */", " out = outarr[0];", " /* Allocate the N-D index initalized to zero. */", " nd_index = (int *)calloc(in->nd,sizeof(int));", " if (NULL == nd_index) {", " PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");", " return -1;", " }", " /* Build argument list */", " if ((arglist = PyTuple_New(nin)) == NULL) {", " free(nd_index);", " return -1;", " }", "", " loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */", "", " while(loop_index--) {", " /* Create input argument list with current element from the input", " arrays", " */", " for (i=0; i < nin; i++) {", " tmparr = inarr[i];", " /* Find linear index into this input array */", " CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);", " /* Get object at this index */", " tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));", " if (NULL == tmpobj) {", "\tPy_DECREF(arglist);", "\tfree(nd_index);", "\treturn -1;", " }", " /* This steals reference of tmpobj */", " PyTuple_SET_ITEM(arglist, i, tmpobj);", " }", " /* Call Python Function for this set of inputs */", " if ((result=PyEval_CallObject(func, arglist))==NULL) {", " Py_DECREF(arglist);", " free(nd_index);", " return -1;", " }", "", " /* Find index into (all) output arrays */", " CALCINDEX(indx_out,nd_index,out->strides,out->nd);", "", " /* Copy the results to the output arrays */", " if (1==nout) {", " if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {", "\tfree(nd_index);", "\tPy_DECREF(arglist);", "\tPy_DECREF(result);", "\treturn -1;", " }", " }", " else if (PyTuple_Check(result)) {", " for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {", "\t free(nd_index);", "\t Py_DECREF(arglist);", "\t Py_DECREF(result);", " return -1;", "\t}", " }", " }", " else {", " PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");", " free(nd_index);", " Py_DECREF(arglist);", " Py_DECREF(result);", " return -1;", " }", "", " /* Increment the index counter */", " INCREMENT(nd_index,in->nd,in->dimensions);", " Py_DECREF(result);", "", " }", " Py_DECREF(arglist);", " free(nd_index);", " return 0;", "}", "", "static PyObject *build_output(PyArrayObject **outarr,int nout)", "{", " int i;", " PyObject *out;", "", " if (1==nout) return PyArray_Return(outarr[0]);", " if ((out=PyTuple_New(nout))==NULL) return NULL;", " for (i=0; i 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 \n \n #-----------------------------------------------------------------------------\n", "added_lines": 79, "deleted_lines": 1, "source_code": "\nimport types\nimport Numeric\nfrom Numeric import *\nfrom type_check import ScalarType\nfrom shape_base import squeeze\nfrom fastumath import PINF as inf\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']\n\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\n\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 extract(arr,mask):\n \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(mask)))\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 \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", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import *\nfrom type_check import ScalarType\nfrom fastumath import PINF as inf\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']\n\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\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 extract(arr,mask):\n \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(mask)))\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\n \n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()\n", "methods": [ { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 22, "end_line": 26, "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": 29, "end_line": 42, "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": 44, "end_line": 60, "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": 62, "end_line": 67, "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": 69, "end_line": 75, "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": 77, "end_line": 123, "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": 126, "end_line": 134, "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": 136, "end_line": 144, "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": 148, "end_line": 156, "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": 158, "end_line": 166, "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": 168, "end_line": 176, "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": 178, "end_line": 186, "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": 188, "end_line": 200, "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": 203, "end_line": 216, "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": 218, "end_line": 233, "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": 239, "end_line": 243, "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": 235, "end_line": 246, "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": 248, "end_line": 267, "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": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 277, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 282, "end_line": 286, "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": 288, "end_line": 293, "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": 295, "end_line": 300, "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": 302, "end_line": 307, "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": 310, "end_line": 315, "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": 317, "end_line": 322, "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": 324, "end_line": 335, "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": 368, "end_line": 382, "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": 384, "end_line": 392, "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": 394, "end_line": 410, "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": 419, "end_line": 421, "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": 423, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 20, "end_line": 24, "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": 27, "end_line": 40, "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": 42, "end_line": 58, "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": 60, "end_line": 65, "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": 67, "end_line": 73, "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": 75, "end_line": 121, "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": 124, "end_line": 132, "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": 134, "end_line": 142, "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": 146, "end_line": 154, "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": 156, "end_line": 164, "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": 166, "end_line": 174, "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": 176, "end_line": 184, "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": 186, "end_line": 198, "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": 201, "end_line": 214, "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": 216, "end_line": 231, "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": 237, "end_line": 241, "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": 233, "end_line": 244, "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": 246, "end_line": 265, "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": 267, "end_line": 273, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 275, "end_line": 278, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 280, "end_line": 284, "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": 286, "end_line": 291, "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": 293, "end_line": 298, "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": 300, "end_line": 305, "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": 308, "end_line": 313, "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": 315, "end_line": 320, "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": 322, "end_line": 333, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "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": 341, "end_line": 343, "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": 345, "end_line": 347, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "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": 368, "end_line": 382, "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": 384, "end_line": 392, "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": 394, "end_line": 410, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 } ], "nloc": 282, "complexity": 76, "token_count": 2020, "diff_parsed": { "added": [ "from shape_base import squeeze", " 'nanargmin','nanmin','sum','vectorize']", "", "from _compiled_base import arraymap", "class vectorize:", " \"\"\"", " vectorize(somefunction) Genearlized Function class.", "", " Description:", "", " Define a vectorized function which takes nested sequence", " objects or Numeric arrays as inputs and returns a", " Numeric array as output, evaluating the function over successive", " tuples of the input arrays like the python map function except it uses", " the broadcasting rules of Numeric Python.", "", " Input:", "", " somefunction -- a Python function or method", "", " Example:", "", " def myfunc(a,b):", " if a > b:", " return a-b", " else", " return a+b", "", " vfunc = vectorize(myfunc)", "", " >>> vfunc([1,2,3,4],2)", " array([3,4,1,2])", "", " \"\"\"", " def __init__(self,pyfunc,otypes=None,doc=None):", " if not callable(pyfunc) or type(pyfunc) is types.ClassType:", " raise TypeError, \"Object is not a callable Python object.\"", " self.thefunc = pyfunc", " if doc is None:", " self.__doc__ = pyfunc.__doc__", " else:", " self.__doc__ = doc", " if otypes is None:", " self.otypes=''", " else:", " if isinstance(otypes,types.StringType):", " self.otypes=otypes", " else:", " raise ValueError, \"Output types must be a string.\"", "", " def __call__(self,*args):", " for arg in args:", " try:", " n = len(arg)", " if (n==0):", " return self.zerocall(args)", " except (AttributeError, TypeError):", " pass", " return squeeze(arraymap(self.thefunc,args,self.otypes))", "", " def zerocall(self,args):", " # one of the args was a zeros array", " # return zeros for each output", " # first --- find number of outputs", " newargs = []", " args = atleast_1d(*args)", " for arg in args:", " if arg.typecode() != 'O':", " newargs.append(1.1)", " else:", " newargs.append(arg[0])", " newargs = tuple(newargs)", " res = self.thefunc(*newargs)", " if isscalar(res):", " return zeros((0,),'d')", " else:", " return (zeros((0,),'d'),)*len(res)", "", "" ], "deleted": [ " 'nanargmin','nanmin','sum']" ] } }, { "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": "@@ -198,18 +198,25 @@ def check_trailing_skip(self):\n \n # Utility\n \n-class test_find_repeats(unittest.TestCase):\n- def check_basic(self):\n- a = array([1,2,3,4,1,2,3,4,1,2,5])\n- res,nums = find_repeats(a)\n- assert_array_equal(res,[1,2,3,4])\n- assert_array_equal(nums,[3,3,2])\n+class 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 \n 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@@ -232,6 +239,8 @@ def test_suite(level=1):\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+\n \n total_suite = unittest.TestSuite(suites)\n return total_suite\n", "added_lines": 15, "deleted_lines": 6, "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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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# Utility\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\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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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# Utility\n\nclass test_find_repeats(unittest.TestCase):\n def check_basic(self):\n a = array([1,2,3,4,1,2,3,4,1,2,5])\n res,nums = find_repeats(a)\n assert_array_equal(res,[1,2,3,4])\n assert_array_equal(nums,[3,3,2])\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_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\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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 22, "end_line": 25, "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": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 28, "end_line": 35, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 37, "end_line": 40, "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": 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_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": 203, "end_line": 207, "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": 202, "end_line": 210, "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": 213, "end_line": 215, "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": 19, "complexity": 2, "token_count": 208, "parameters": [ "level" ], "start_line": 222, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 248, "end_line": 252, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 22, "end_line": 25, "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": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 28, "end_line": 35, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 37, "end_line": 40, "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": 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": 5, "complexity": 1, "token_count": 67, "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": "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": 208, "end_line": 210, "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": 18, "complexity": 2, "token_count": 195, "parameters": [ "level" ], "start_line": 215, "end_line": 237, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 23, "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": 239, "end_line": 243, "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": 19, "complexity": 2, "token_count": 208, "parameters": [ "level" ], "start_line": 222, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "top_nesting_level": 0 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 202, "end_line": 210, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "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": 203, "end_line": 207, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "check_basic", "long_name": "check_basic( self )", "filename": "test_function_base.py", "nloc": 5, "complexity": 1, "token_count": 67, "parameters": [ "self" ], "start_line": 202, "end_line": 206, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 1 } ], "nloc": 222, "complexity": 31, "token_count": 2618, "diff_parsed": { "added": [ "class test_vectorize(unittest.TestCase):", " def check_simple(self):", " def addsubtract(a,b):", " if a > b:", " return a - b", " else:", " return a + b", " f = vectorize(addsubtract)", " r = f([0,3,6,9],[1,3,5,7])", " assert_array_equal(r,[1,6,1,2])", "", "", "", " suites.append( unittest.makeSuite(test_vectorize,'check_') )", "" ], "deleted": [ "class test_find_repeats(unittest.TestCase):", " def check_basic(self):", " a = array([1,2,3,4,1,2,3,4,1,2,5])", " res,nums = find_repeats(a)", " assert_array_equal(res,[1,2,3,4])", " assert_array_equal(nums,[3,3,2])" ] } } ] }, { "hash": "25c9847d736a48adf9b72d0ef061267627f07c9c", "msg": "Removed redundant general_function and tests", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-20T19:35:50+00:00", "author_timezone": 0, "committer_date": "2003-09-20T19:35:50+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "ba4e597baba7c3dd57431414d0bee0db9d0f3af9" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 139, "insertions": 0, "lines": 139, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.22388059701492538, "dmm_unit_interfacing": 0.22388059701492538, "modified_files": [ { "old_path": "scipy_base/general_function.py", "new_path": null, "filename": "general_function.py", "extension": "py", "change_type": "DELETE", "diff": "@@ -1,97 +0,0 @@\n-#\n-# Author: Travis Oliphant\n-#\n-\n-from Numeric import *\n-import types\n-from arraymap import arraymap\n-from shape_base import squeeze,atleast_1d\n-from type_check import isscalar\n-\n-__all__ = ['general_function']\n-\n-class general_function:\n- \"\"\"\n- general_function(somefunction) Generalized Function class.\n-\n- Description:\n- \n- Define a generalized 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- gfunc = general_function(myfunc)\n-\n- >>> gfunc([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-\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": 97, "source_code": null, "source_code_before": "#\n# Author: Travis Oliphant\n#\n\nfrom Numeric import *\nimport types\nfrom arraymap import arraymap\nfrom shape_base import squeeze,atleast_1d\nfrom type_check import isscalar\n\n__all__ = ['general_function']\n\nclass general_function:\n \"\"\"\n general_function(somefunction) Generalized Function class.\n\n Description:\n \n Define a generalized 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 gfunc = general_function(myfunc)\n\n >>> gfunc([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", "methods": [], "methods_before": [ { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "general_function.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 43, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "general_function.py", "nloc": 9, "complexity": 4, "token_count": 59, "parameters": [ "self", "args" ], "start_line": 59, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , args )", "filename": "general_function.py", "nloc": 14, "complexity": 4, "token_count": 102, "parameters": [ "self", "args" ], "start_line": 69, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 91, "end_line": 93, "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": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 95, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "name": "__init__", "long_name": "__init__( self , pyfunc , otypes = None , doc = None )", "filename": "general_function.py", "nloc": 15, "complexity": 6, "token_count": 92, "parameters": [ "self", "pyfunc", "otypes", "doc" ], "start_line": 43, "end_line": 57, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 15, "top_nesting_level": 1 }, { "name": "zerocall", "long_name": "zerocall( self , args )", "filename": "general_function.py", "nloc": 14, "complexity": 4, "token_count": 102, "parameters": [ "self", "args" ], "start_line": 69, "end_line": 85, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 17, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 95, "end_line": 97, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "general_function.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 91, "end_line": 93, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "__call__", "long_name": "__call__( self , * args )", "filename": "general_function.py", "nloc": 9, "complexity": 4, "token_count": 59, "parameters": [ "self", "args" ], "start_line": 59, "end_line": 67, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "#", "# Author: Travis Oliphant", "#", "", "from Numeric import *", "import types", "from arraymap import arraymap", "from shape_base import squeeze,atleast_1d", "from type_check import isscalar", "", "__all__ = ['general_function']", "", "class general_function:", " \"\"\"", " general_function(somefunction) Generalized Function class.", "", " Description:", "", " Define a generalized function which takes nested sequence", " objects or Numeric arrays as inputs and returns a", " Numeric array as output, evaluating the function over successive", " tuples of the input arrays like the python map function except it uses", " the broadcasting rules of Numeric Python.", "", " Input:", "", " somefunction -- a Python function or method", "", " Example:", "", " def myfunc(a,b):", " if a > b:", " return a-b", " else", " return a+b", "", " gfunc = general_function(myfunc)", "", " >>> gfunc([1,2,3,4],2)", " array([3,4,1,2])", "", " \"\"\"", " def __init__(self,pyfunc,otypes=None,doc=None):", " if not callable(pyfunc) or type(pyfunc) is types.ClassType:", " raise TypeError, \"Object is not a callable Python object.\"", " self.thefunc = pyfunc", " if doc is None:", " self.__doc__ = pyfunc.__doc__", " else:", " self.__doc__ = doc", " if otypes is None:", " self.otypes=''", " else:", " if isinstance(otypes,types.StringType):", " self.otypes=otypes", " else:", " raise ValueError, \"Output types must be a string.\"", "", " def __call__(self,*args):", " for arg in args:", " try:", " n = len(arg)", " if (n==0):", " return self.zerocall(args)", " except (AttributeError, TypeError):", " pass", " return squeeze(arraymap(self.thefunc,args,self.otypes))", "", " def zerocall(self,args):", " # one of the args was a zeros array", " # return zeros for each output", " # first --- find number of outputs", " newargs = []", " args = atleast_1d(*args)", " for arg in args:", " if arg.typecode() != 'O':", " newargs.append(1.1)", " else:", " newargs.append(arg[0])", " newargs = tuple(newargs)", " res = self.thefunc(*newargs)", " if isscalar(res):", " return zeros((0,),'d')", " else:", " return (zeros((0,),'d'),)*len(res)", "", "#-----------------------------------------------------------------------------", "# 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/tests/test_general_function.py", "new_path": null, "filename": "test_general_function.py", "extension": "py", "change_type": "DELETE", "diff": "@@ -1,42 +0,0 @@\n-import sys\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-from scipy_test.testing import set_package_path\n-set_package_path()\n-import scipy_base;reload(scipy_base)\n-from scipy_base import *\n-del sys.path[0]\n-\n-class test_general_function(unittest.TestCase):\n-\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 = general_function(addsubtract)\n- r = f([0,3,6,9],[1,3,5,7])\n- assert_array_equal(r,[1,6,1,2])\n-\n-####### Testing ##############\n-\n-def test_suite(level=1):\n- suites = []\n- if level > 0:\n- suites.append( unittest.makeSuite(test_general_function,'check_') )\n- if level > 5:\n-\tpass\n- total_suite = unittest.TestSuite(suites)\n- return total_suite\n-\n-def test(level=10,verbosity=2):\n- all_tests = test_suite(level=level)\n- runner = unittest.TextTestRunner(verbosity=verbosity)\n- runner.run(all_tests)\n- return runner\n-\n-if __name__ == \"__main__\":\n- test()\n", "added_lines": 0, "deleted_lines": 42, "source_code": null, "source_code_before": "import sys\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\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_general_function(unittest.TestCase):\n\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 = general_function(addsubtract)\n r = f([0,3,6,9],[1,3,5,7])\n assert_array_equal(r,[1,6,1,2])\n\n####### Testing ##############\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_general_function,'check_') )\n if level > 5:\n\tpass\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10,verbosity=2):\n all_tests = test_suite(level=level)\n runner = unittest.TextTestRunner(verbosity=verbosity)\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", "methods": [], "methods_before": [ { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_general_function.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 15, "end_line": 19, "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_general_function.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 14, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "test_general_function.py", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "level" ], "start_line": 26, "end_line": 33, "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_general_function.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "level", "verbosity" ], "start_line": 35, "end_line": 39, "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_general_function.py", "nloc": 8, "complexity": 3, "token_count": 45, "parameters": [ "level" ], "start_line": 26, "end_line": 33, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "check_simple", "long_name": "check_simple( self )", "filename": "test_general_function.py", "nloc": 5, "complexity": 1, "token_count": 51, "parameters": [ "self" ], "start_line": 14, "end_line": 22, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 9, "top_nesting_level": 1 }, { "name": "check_simple.addsubtract", "long_name": "check_simple.addsubtract( a , b )", "filename": "test_general_function.py", "nloc": 5, "complexity": 2, "token_count": 22, "parameters": [ "a", "b" ], "start_line": 15, "end_line": 19, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 2 }, { "name": "test", "long_name": "test( level = 10 , verbosity = 2 )", "filename": "test_general_function.py", "nloc": 5, "complexity": 1, "token_count": 37, "parameters": [ "level", "verbosity" ], "start_line": 35, "end_line": 39, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 5, "top_nesting_level": 0 } ], "nloc": null, "complexity": null, "token_count": null, "diff_parsed": { "added": [], "deleted": [ "import sys", "import unittest", "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", "set_package_path()", "import scipy_base;reload(scipy_base)", "from scipy_base import *", "del sys.path[0]", "", "class test_general_function(unittest.TestCase):", "", " def check_simple(self):", " def addsubtract(a,b):", " if a > b:", " return a - b", " else:", " return a + b", " f = general_function(addsubtract)", " r = f([0,3,6,9],[1,3,5,7])", " assert_array_equal(r,[1,6,1,2])", "", "####### Testing ##############", "", "def test_suite(level=1):", " suites = []", " if level > 0:", " suites.append( unittest.makeSuite(test_general_function,'check_') )", " if level > 5:", "\tpass", " total_suite = unittest.TestSuite(suites)", " return total_suite", "", "def test(level=10,verbosity=2):", " all_tests = test_suite(level=level)", " runner = unittest.TextTestRunner(verbosity=verbosity)", " runner.run(all_tests)", " return runner", "", "if __name__ == \"__main__\":", " test()" ] } } ] }, { "hash": "8a8731bc8d323c377c13f98f53686062770b1a2f", "msg": "Undoing general_function move (Travis won this race;-)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-20T19:48:59+00:00", "author_timezone": 0, "committer_date": "2003-09-20T19:48:59+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "25c9847d736a48adf9b72d0ef061267627f07c9c" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 504, "insertions": 1, "lines": 505, "files": 3, "dmm_unit_size": 0.8905325443786982, "dmm_unit_complexity": 0.908284023668639, "dmm_unit_interfacing": 0.6893491124260355, "modified_files": [ { "old_path": "scipy_base/__init__.py", "new_path": "scipy_base/__init__.py", "filename": "__init__.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -101,7 +101,7 @@\n \n General functions\n =================\n-general_function -- Generalized Function class\n+vectorize -- Generalized Function class\n \n Import tricks\n =============\n@@ -139,7 +139,6 @@\n \n from polynomial import *\n from scimath import *\n-from general_function import *\n \n Inf = inf = fastumath.PINF\n try:\n", "added_lines": 1, "deleted_lines": 2, "source_code": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nvectorize -- a class that wraps a Python function taking scalar\n arguments into a generalized function which\n can handle arrays of arguments using the broadcast\n rules of Numeric Python.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nGeneral functions\n=================\nvectorize -- Generalized Function class\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\n\"\"\"\n\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 *\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", "source_code_before": "\"\"\" Basic functions used by several sub-packages and useful to have in the\nmain name-space\n\nType handling\n==============\niscomplexobj -- Test for complex object, scalar result\nisrealobj -- Test for real object, scalar result\niscomplex -- Test for complex elements, array result\nisreal -- Test for real elements, array result\nimag -- Imaginary part\nreal -- Real part\nreal_if_close -- Turns complex number with tiny imaginary part to real\nisneginf -- Tests for negative infinity ---|\nisposinf -- Tests for positive infinity |\nisnan -- Tests for nans |---- array results\nisinf -- Tests for infinity |\nisfinite -- Tests for finite numbers ---| \nisscalar -- True if argument is a scalar\nnan_to_num -- Replaces NaN's with 0 and infinities with large numbers\ntypename -- Return english name for given typecode character\ncast -- Dictionary of functions to force cast to each type\ncommon_type -- Determine the 'minimum common type code' for a group\n of arrays\n\nIndex tricks\n==================\nmgrid -- Method which allows easy construction of N-d 'mesh-grids'\nr_ -- Append and construct arrays -- turns slice objects into\n ranges and concatenates them, for 2d arrays appends\n rows.\nc_ -- Append and construct arrays -- for 2d arrays appends\n columns.\n\nindex_exp -- Konrad Hinsen's index_expression class instance which\n can be useful for building complicated slicing syntax.\n\nUseful functions\n==================\nselect -- Extension of where to multiple conditions and choices\nextract -- Extract 1d array from flattened array according to mask\ninsert -- Insert 1d array of values into Nd array according to mask\nlinspace -- Evenly spaced samples in linear space\nlogspace -- Evenly spaced samples in logarithmic space\nfix -- Round x to nearest integer towards zero\nmod -- Modulo mod(x,y) = x % y except keeps sign of y\namax -- Array maximum along axis\namin -- Array minimum along axis\nptp -- Array max-min along axis\ncumsum -- Cumulative sum along axis\nprod -- Product of elements along axis\ncumprod -- Cumluative product along axis\ndiff -- Discrete differences along axis\nangle -- Returns angle of complex argument\nunwrap -- Unwrap phase along given axis (1-d algorithm)\nsort_complex -- Sort a complex-array (based on real, then imaginary)\ntrim_zeros -- trim the leading and trailing zeros from 1D array.\n\nvectorize -- a class that wraps a Python function taking scalar\n arguments into a generalized function which\n can handle arrays of arguments using the broadcast\n rules of Numeric Python.\n\nShape manipulation\n===================\nsqueeze -- Return a with length-one dimensions removed.\natleast_1d -- Force arrays to be > 1D\natleast_2d -- Force arrays to be > 2D\natleast_3d -- Force arrays to be > 3D\nvstack -- Stack arrays vertically (row on row)\nhstack -- Stack arrays horizontally (column on column)\ncolumn_stack -- Stack 1D arrays as columns into 2D array\ndstack -- Stack arrays depthwise (along third dimension)\nsplit -- Divide array into a list of sub-arrays\nhsplit -- Split into columns\nvsplit -- Split into rows\ndsplit -- Split along third dimension\n\nMatrix (2d array) manipluations\n===============================\nfliplr -- 2D array with columns flipped\nflipud -- 2D array with rows flipped\nrot90 -- Rotate a 2D array a multiple of 90 degrees\neye -- Return a 2D array with ones down a given diagonal\ndiag -- Construct a 2D array from a vector, or return a given\n diagonal from a 2D array. \nmat -- Construct a Matrix\n\nPolynomials\n============\npoly1d -- A one-dimensional polynomial class\n\npoly -- Return polynomial coefficients from roots\nroots -- Find roots of polynomial given coefficients\npolyint -- Integrate polynomial\npolyder -- Differentiate polynomial\npolyadd -- Add polynomials\npolysub -- Substract polynomials\npolymul -- Multiply polynomials\npolydiv -- Divide polynomials\npolyval -- Evaluate polynomial at given argument\n\nGeneral functions\n=================\ngeneral_function -- Generalized Function class\n\nImport tricks\n=============\nppimport -- Postpone module import until trying to use it\nppimport_attr -- Postpone module import until trying to use its\n attribute\n\"\"\"\n\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 general_function 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": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 151, "end_line": 155, "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": 157, "end_line": 164, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "methods_before": [ { "name": "test", "long_name": "test( level = 10 )", "filename": "__init__.py", "nloc": 5, "complexity": 1, "token_count": 26, "parameters": [ "level" ], "start_line": 152, "end_line": 156, "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": 158, "end_line": 165, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 } ], "changed_methods": [], "nloc": 144, "complexity": 2, "token_count": 174, "diff_parsed": { "added": [ "vectorize -- Generalized Function class" ], "deleted": [ "general_function -- Generalized Function class", "from general_function import *" ] } }, { "old_path": "scipy_base/arraymapmodule.c", "new_path": null, "filename": "arraymapmodule.c", "extension": "c", "change_type": "DELETE", "diff": "@@ -1,496 +0,0 @@\n-/* Arraymap module\n- * Copyright 1999 Travis E. Oliphant\n- */\n-\n-#include \"Python.h\"\n-#include \"Numeric/arrayobject.h\"\n-\n-/* Decrement the reference count of all objects in **arrays. */\n-static 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 */\n-static 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-\n-static 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-\n-static 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 */\n-static 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-\n-static 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-\n-static 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 > 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 > maxrank) maxrank = ain->nd;", " inputarrays[i] = ain;", " }", "", " maxdims = (int*)malloc(2*sizeof(int)*maxrank);", " if (NULL == maxdims) {", " PyErr_SetString(PyExc_MemoryError, \"arraymap: can't allocate memory for input arrays\");", " cleanup_arrays(inputarrays,nin);", " return -1;", " }", "", "", " /* Reshape all arrays so they have the same rank (pre-pend with length 1 dimensions) */", " /* We want to replace the header information without copying the data.", " Keeping the reference count correct can be tricky.", " We want to make a new array object with a different header and decrease the", " reference count of the old one without deallocating the data section */", " for (i=0; i < nin; i++) {", " ain = inputarrays[i];", "", " /* Initialize all dimensions to 1 */", " /* Change array shape */", " for (k=0; k < maxrank; k++)", " maxdims[k] = 1;", " for (k=maxrank-ain->nd; k< maxrank; k++)", " maxdims[k] = ain->dimensions[k-maxrank+ain->nd];", "", " tmparray = (PyArrayObject *)PyArray_FromDimsAndData(maxrank,maxdims,ain->descr->type,ain->data);", " if (NULL == tmparray) {", " free(maxdims);", " cleanup_arrays(inputarrays,nin);", " return -1;", " }", " memmove(tmparray->strides,ain->strides,sizeof(int)*tmparray->nd);", " tmparray->base = (PyObject *)ain; /* When tmparray is deallocated ain will be too */", " inputarrays[i] = tmparray; /* tmparray is new array */", " }", "", " /* Find dimension length for the output arrays (maximum length for each", " dimension) */", " for (k=0; k < maxrank; k++) {", " maxdims[k] = 1;", " for (i=0; i < nin; i++)", " if (inputarrays[i]->dimensions[k] > maxdims[k])", "\tmaxdims[k] = inputarrays[i]->dimensions[k];", " }", "", " /* Now set all lengths for input array dimensions to maxdims", " and make strides equal to zero for arrays whose", " real length is 1 for a particular dimension", " */", "", " for (i=0; idimensions[k]) {", "\tain->strides[k] = 0;", "\tain->dimensions[k] = maxdims[k];", " }", " else if (ain->dimensions[k] != maxdims[k]) {", "\tPyErr_SetString(PyExc_ValueError,\"arraymap: Frames are not aligned (mismatched dimensions).\");", "\tcleanup_arrays(inputarrays,nin);", "\tfree(maxdims);", "\treturn -1;", " }", " }", " }", "", " free(maxdims);", " return 0;", "", "}", "", "static int type_from_object(PyObject *obj)", "{", " if (PyArray_Check(obj))", " return ((PyArrayObject *)obj)->descr->type_num;", " if (PyComplex_Check(obj)) return PyArray_CDOUBLE;", " if (PyFloat_Check(obj)) return PyArray_DOUBLE;", " if (PyInt_Check(obj) || PyLong_Check(obj)) return PyArray_LONG;", " PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for output array.\");", " return -1;", "}", "", "static int type_from_char(char typechar)", "{", " switch(typechar) {", " case 'c': return PyArray_CHAR;", " case 'b': return PyArray_UBYTE;", " case '1': return PyArray_SBYTE;", " case 's': return PyArray_SHORT;", " case 'i': return PyArray_INT;", "#ifdef PyArray_UNSIGNED_TYPES", " case 'w': return PyArray_USHORT;", " case 'u': return PyArray_UINT;", "#endif", " case 'l': return PyArray_LONG;", " case 'f': return PyArray_FLOAT;", " case 'd': return PyArray_DOUBLE;", " case 'F': return PyArray_CFLOAT;", " case 'D': return PyArray_CDOUBLE;", " default:", " PyErr_SetString(PyExc_ValueError, \"arraymap: Invalid type for array\");", " return -1;", " }", "}", "", "", "", "/* This sets up the output arrays by calling the function with arguments", " the first element of each input arrays. If otypes is NULL, the", " returned value type is used to establish the type of the output", " arrays, otherwise the characters in otypes determine the", " output types */", "static int setup_output_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject ***outarr, char *otypes, int numtypes)", "{", " PyObject *arglist, *result;", " PyObject *tmpobject;", " PyArrayObject *tmparr;", " int i, nout;", " int nd, *dimensions, type_num;", "", " nd = inarr[0]->nd;", " dimensions = inarr[0]->dimensions;", "", " if ((numtypes == 0) || (otypes == NULL)) {", " /* Call function to get number of outputs */", "", " /* Build argument list */", " if ((arglist = PyTuple_New(nin)) == NULL) {", " return -1;", " }", " /* Construct input argument by creating a tuple with an element", " from each input array (cast to an appropriate Python Object) */", " for (i=0; i < nin; i++) {", " tmparr = inarr[i];", " /* Get first data point */", " tmpobject = tmparr->descr->getitem((void *)tmparr->data);", " if (NULL == tmpobject) {", "\tPy_DECREF(arglist);", "\treturn -1;", " }", " PyTuple_SET_ITEM(arglist, i, tmpobject); /* arg1 owns reference to tmpobj now */", " }", " /* Call Python Function */", " if ((result=PyEval_CallObject(func, arglist))==NULL) {", " Py_DECREF(arglist);", " return -1;", " }", "", " Py_DECREF(arglist);", "", " /* If result is a tuple, create output_arrays according", " to output. */", " if (PyTuple_Check(result)) {", " nout = PyTuple_GET_SIZE(result);", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL == *outarr) {", "\tPyErr_SetString(PyExc_MemoryError, \"arraymap: Cannot allocate memory for output arrays.\");", "\tPy_DECREF(result);", "\treturn -1;", " }", " /* Create nout output arrays */", " for (i=0; i < nout; i++) {", "\t/* Determine type */", "\tif ((type_num=type_from_object(PyTuple_GET_ITEM(result, i)))==-1) {", "\t cleanup_arrays(*outarr,i);", "\t Py_DECREF(result);", "\t free(*outarr);", "\t return -1;", "\t}", "\t/* Create output array */", "\t(*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", "\tif (NULL == (*outarr)[i]) {", "\t cleanup_arrays(*outarr,i);", "\t Py_DECREF(result);", "\t free(*outarr);", "\t return -1;", "\t}", " }", " }", " else { /* Only a single output result */", " nout = 1;", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL==*outarr) {", "\tPyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");", "\tPy_DECREF(result);", "\treturn -1;", " }", " if ((type_num = type_from_object(result))==-1) {", "\tPy_DECREF(result);", "\tfree(*outarr);", "\treturn -1;", " }", " (*outarr)[0] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", " if (NULL == (*outarr)[0]) {", "\tPy_DECREF(result);", "\tfree(*outarr);", "\treturn -1;", " }", " }", " Py_DECREF(result);", " }", "", " else { /* Character output types entered */", " nout = numtypes;", " *outarr = (PyArrayObject **)malloc(nout*sizeof(PyArrayObject *));", " if (NULL==*outarr) {", " PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for output arrays.\");", " return -1;", " }", " /* Create Output arrays */", " for (i=0; i < nout; i++) {", " /* Get type */", " if ((type_num = type_from_char(otypes[i]))==-1) {", "\tcleanup_arrays(*outarr,i);", "\tfree(*outarr);", "\treturn -1;", " }", " /* Create array */", " (*outarr)[i] = (PyArrayObject *)PyArray_FromDims(nd,dimensions,type_num);", " if (NULL == (*outarr)[i]) {", "\tcleanup_arrays(*outarr,i);", "\tfree(*outarr);", "\treturn -1;", " }", " }", " }", " return nout;", "}", "", "", "/* Corresponding dimensions are assumed to match, check before calling. */", "/* No rank-0 arrays (make them rank-1 arrays) */", "", "/* This replicates the standard Ufunc broadcasting rule that if the", " dimension length is one, incrementing does not occur for that dimension.", "", " This is currently done by setting the stride in that dimension to", " zero during input array setup.", "", " The purpose of this function is to perform a for loop over arbitrary", " discontiguous N-D arrays, call the Python function for each set of", " corresponding elements and place the results in the output_array.", "*/", "#define INCREMENT(ret_ind, nd, max_ind) \\", "{ \\", " int k; \\", " k = (nd) - 1; \\", " if (++(ret_ind)[k] >= (max_ind)[k]) { \\", " while (k >= 0 && ((ret_ind)[k] >= (max_ind)[k]-1)) \\", " (ret_ind)[k--] = 0; \\", " if (k >= 0) (ret_ind)[k]++; \\", " else (ret_ind)[0] = (max_ind)[0]; \\", " } \\", "}", "", "#define CALCINDEX(indx, nd_index, strides, ndim) \\", "{ \\", " int i; \\", " \\", " indx = 0; \\", " for (i=0; i < (ndim); i++) \\", " indx += (nd_index)[i]*(strides)[i]; \\", "}", "", "static int loop_over_arrays(PyObject *func, PyArrayObject **inarr, int nin, PyArrayObject **outarr, int nout)", "{", " int i, loop_index;", " int *nd_index, indx_in, indx_out;", " PyArrayObject *in, *out, *tmparr;", " PyObject *result, *tmpobj, *arglist;", "", " in = inarr[0]; /* For any shape information needed */", " out = outarr[0];", " /* Allocate the N-D index initalized to zero. */", " nd_index = (int *)calloc(in->nd,sizeof(int));", " if (NULL == nd_index) {", " PyErr_SetString(PyExc_MemoryError,\"arraymap: Cannot allocate memory for arrays.\");", " return -1;", " }", " /* Build argument list */", " if ((arglist = PyTuple_New(nin)) == NULL) {", " free(nd_index);", " return -1;", " }", "", " loop_index = PyArray_Size((PyObject *)in); /* Total number of Python function calls */", "", " while(loop_index--) {", " /* Create input argument list with current element from the input", " arrays", " */", " for (i=0; i < nin; i++) {", " tmparr = inarr[i];", " /* Find linear index into this input array */", " CALCINDEX(indx_in,nd_index,tmparr->strides,in->nd);", " /* Get object at this index */", " tmpobj = tmparr->descr->getitem((void *)(tmparr->data+indx_in));", " if (NULL == tmpobj) {", "\tPy_DECREF(arglist);", "\tfree(nd_index);", "\treturn -1;", " }", " /* This steals reference of tmpobj */", " PyTuple_SET_ITEM(arglist, i, tmpobj);", " }", " /* Call Python Function for this set of inputs */", " if ((result=PyEval_CallObject(func, arglist))==NULL) {", " Py_DECREF(arglist);", " free(nd_index);", " return -1;", " }", "", " /* Find index into (all) output arrays */", " CALCINDEX(indx_out,nd_index,out->strides,out->nd);", "", " /* Copy the results to the output arrays */", " if (1==nout) {", " if ((outarr[0]->descr->setitem(result,(outarr[0]->data+indx_out)))==-1) {", "\tfree(nd_index);", "\tPy_DECREF(arglist);", "\tPy_DECREF(result);", "\treturn -1;", " }", " }", " else if (PyTuple_Check(result)) {", " for (i=0; idescr->setitem(PyTuple_GET_ITEM(result,i),(outarr[i]->data+indx_out)))==-1) {", "\t free(nd_index);", "\t Py_DECREF(arglist);", "\t Py_DECREF(result);", " return -1;", "\t}", " }", " }", " else {", " PyErr_SetString(PyExc_ValueError,\"arraymap: Function output of incorrect type.\");", " free(nd_index);", " Py_DECREF(arglist);", " Py_DECREF(result);", " return -1;", " }", "", " /* Increment the index counter */", " INCREMENT(nd_index,in->nd,in->dimensions);", " Py_DECREF(result);", "", " }", " Py_DECREF(arglist);", " free(nd_index);", " return 0;", "}", "", "static PyObject *build_output(PyArrayObject **outarr,int nout)", "{", " int i;", " PyObject *out;", "", " if (1==nout) return PyArray_Return(outarr[0]);", " if ((out=PyTuple_New(nout))==NULL) return NULL;", " for (i=0; i 1:\n return diff(x[slice1]-x[slice2], n-1, axis=axis)\n else:\n return x[slice1]-x[slice2]\n\n \ndef angle(z,deg=0):\n \"\"\"Return the angle of complex argument z.\"\"\"\n if deg:\n fact = 180/pi\n else:\n fact = 1.0\n z = asarray(z)\n if z.typecode() in ['D','F']:\n zimag = z.imag\n zreal = z.real\n else:\n zimag = 0\n zreal = z\n return arctan2(zimag,zreal) * fact\n\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwraps radian phase p by changing absolute jumps greater than\n discont to their 2*pi complement along the given axis.\n \"\"\"\n p = asarray(p)\n nd = len(p.shape)\n dd = diff(p,axis=axis)\n slice1 = [slice(None,None)]*nd # full slices\n slice1[axis] = slice(1,None)\n ddmod = mod(dd+pi,2*pi)-pi\n 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 \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", "source_code_before": "\nimport types\nimport Numeric\nfrom Numeric import *\nfrom type_check import ScalarType\nfrom shape_base import squeeze\nfrom fastumath import PINF as inf\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']\n\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\n\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 extract(arr,mask):\n \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.\n \"\"\"\n return Numeric.take(ravel(arr), nonzero(ravel(mask)))\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 \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": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 22, "end_line": 26, "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": 29, "end_line": 42, "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": 44, "end_line": 60, "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": 62, "end_line": 67, "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": 69, "end_line": 75, "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": 77, "end_line": 123, "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": 126, "end_line": 134, "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": 136, "end_line": 144, "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": 148, "end_line": 156, "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": 158, "end_line": 166, "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": 168, "end_line": 176, "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": 178, "end_line": 186, "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": 188, "end_line": 200, "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": 203, "end_line": 216, "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": 218, "end_line": 233, "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": 239, "end_line": 243, "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": 235, "end_line": 246, "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": 248, "end_line": 267, "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": 269, "end_line": 275, "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": 277, "end_line": 287, "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": 289, "end_line": 294, "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": 296, "end_line": 300, "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": 302, "end_line": 307, "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": 309, "end_line": 314, "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": 316, "end_line": 321, "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": 324, "end_line": 329, "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": 331, "end_line": 336, "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": 338, "end_line": 349, "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": 382, "end_line": 396, "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": 398, "end_line": 406, "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": 408, "end_line": 424, "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": 433, "end_line": 435, "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": 437, "end_line": 439, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "methods_before": [ { "name": "sum", "long_name": "sum( x , axis = 0 )", "filename": "function_base.py", "nloc": 5, "complexity": 2, "token_count": 49, "parameters": [ "x", "axis" ], "start_line": 22, "end_line": 26, "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": 29, "end_line": 42, "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": 44, "end_line": 60, "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": 62, "end_line": 67, "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": 69, "end_line": 75, "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": 77, "end_line": 123, "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": 126, "end_line": 134, "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": 136, "end_line": 144, "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": 148, "end_line": 156, "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": 158, "end_line": 166, "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": 168, "end_line": 176, "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": 178, "end_line": 186, "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": 188, "end_line": 200, "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": 203, "end_line": 216, "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": 218, "end_line": 233, "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": 239, "end_line": 243, "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": 235, "end_line": 246, "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": 248, "end_line": 267, "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": 269, "end_line": 275, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 7, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 277, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "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": 282, "end_line": 286, "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": 288, "end_line": 293, "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": 295, "end_line": 300, "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": 302, "end_line": 307, "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": 310, "end_line": 315, "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": 317, "end_line": 322, "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": 324, "end_line": 335, "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": 368, "end_line": 382, "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": 384, "end_line": 392, "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": 394, "end_line": 410, "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": 419, "end_line": 421, "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": 423, "end_line": 425, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "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": 277, "end_line": 287, "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": 289, "end_line": 294, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 6, "top_nesting_level": 0 }, { "name": "extract", "long_name": "extract( arr , mask )", "filename": "function_base.py", "nloc": 2, "complexity": 1, "token_count": 26, "parameters": [ "arr", "mask" ], "start_line": 277, "end_line": 280, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 4, "top_nesting_level": 0 } ], "nloc": 287, "complexity": 79, "token_count": 2074, "diff_parsed": { "added": [ "def where(condition,x=None,y=None):", " \"\"\"If x and y are both None, then return the (1-d equivalent) indices", " where condition is true. Otherwise, return an array shaped like", " condition with elements of x and y in the places where condition is", " true or false respectively.", " if (x is None) and (y is None):", " # Needs work for multidimensional arrays", " return nonzero(ravel(condition))", " else:", " return choose(not_equal(condition, 0), (y,x))", "", "def extract(condition, arr):", " \"\"\"Elements of ravel(condition) where ravel(condition) is true (1-d)", "", " Equivalent of compress(ravel(condition), ravel(arr))", " \"\"\"", " return Numeric.take(ravel(arr), nonzero(ravel(condition)))" ], "deleted": [ "def extract(arr,mask):", " \"\"\"1D array of those elements of ravel(arr) where ravel(mask) is true.", " return Numeric.take(ravel(arr), nonzero(ravel(mask)))" ] } } ] }, { "hash": "26349190a612f0eed68657f6726a995387d5be56", "msg": "Added test functions for extract and insert.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-22T19:25:46+00:00", "author_timezone": 0, "committer_date": "2003-09-22T19:25:46+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "529150a0af53fbe4ea4ae20f9f3fc04fe5a67814" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 2, "insertions": 20, "lines": 22, "files": 1, "dmm_unit_size": 0.9411764705882353, "dmm_unit_complexity": 1.0, "dmm_unit_interfacing": 1.0, "modified_files": [ { "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": "@@ -195,9 +195,26 @@ 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-# Utility\n \n+\n+class 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+ \n class test_vectorize(unittest.TestCase):\n def check_simple(self):\n def addsubtract(a,b):\n@@ -240,6 +257,7 @@ def test_suite(level=1):\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", "added_lines": 20, "deleted_lines": 2, "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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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", "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_array_equal(any(y1),[1,1,0])\n assert_array_equal(any(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_array_equal(all(y1),[0,0,1])\n assert_array_equal(all(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# Utility\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\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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 22, "end_line": 25, "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": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 28, "end_line": 35, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 37, "end_line": 40, "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": 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": "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": 230, "end_line": 232, "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": 239, "end_line": 264, "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": 266, "end_line": 270, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 22, "end_line": 25, "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": 8, "complexity": 1, "token_count": 72, "parameters": [ "self" ], "start_line": 28, "end_line": 35, "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": 4, "complexity": 1, "token_count": 66, "parameters": [ "self" ], "start_line": 37, "end_line": 40, "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": 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_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": 203, "end_line": 207, "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": 202, "end_line": 210, "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": 213, "end_line": 215, "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": 19, "complexity": 2, "token_count": 208, "parameters": [ "level" ], "start_line": 222, "end_line": 246, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 25, "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": 248, "end_line": 252, "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": 239, "end_line": 264, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 26, "top_nesting_level": 0 }, { "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_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 } ], "nloc": 240, "complexity": 34, "token_count": 2821, "diff_parsed": { "added": [ "", "class test_extins(unittest.TestCase):", " def check_basic(self):", " a = array([1,3,2,1,2,3,3])", " b = extract(a>1,a)", " assert_array_equal(b,[3,2,2,3,3])", " def check_insert(self):", " a = array([1,4,3,2,5,8,7])", " insert(a,[0,1,0,1,0,1,0],[2,4,6])", " assert_array_equal(a,[1,2,3,4,5,6,7])", " def check_both(self):", " a = rand(10)", " mask = a > 0.5", " ac = a.copy()", " c = extract(mask, a)", " insert(a,mask,0)", " insert(a,mask,c)", " assert_array_equal(a,ac)", "", " suites.append( unittest.makeSuite(test_extins,'check_'))" ], "deleted": [ "", "# Utility" ] } } ] }, { "hash": "a081902f0cef6b53c3443de294a53c14726483ed", "msg": "Added bmat (build matrix) constructor for easy creation of block matrices. Added better docs for special.errprint. Changed default of errprint to 0", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-23T18:24:17+00:00", "author_timezone": 0, "committer_date": "2003-09-23T18:24:17+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "26349190a612f0eed68657f6726a995387d5be56" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 1, "insertions": 64, "lines": 65, "files": 2, "dmm_unit_size": 0.0, "dmm_unit_complexity": 0.43902439024390244, "dmm_unit_interfacing": 0.07317073170731707, "modified_files": [ { "old_path": "scipy_base/index_tricks.py", "new_path": "scipy_base/index_tricks.py", "filename": "index_tricks.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -4,6 +4,7 @@\n \n from type_check import ScalarType\n import function_base\n+import matrix_base\n \n class nd_grid:\n \"\"\" Construct a \"meshgrid\" in N-dimensions.\n@@ -106,12 +107,16 @@ def __len__(self):\n mgrid = nd_grid()\n ogrid = nd_grid(1)\n \n+import sys\n class 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 matrix_base.bmat(key,frame.f_globals,frame.f_locals)\n if type(key) is not types.TupleType:\n key = (key,)\n objs = []\n", "added_lines": 5, "deleted_lines": 0, "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 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", "source_code_before": "import types\nimport Numeric\n__all__ = ['mgrid','ogrid','r_','c_','index_exp']\n\nfrom type_check import ScalarType\nimport function_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\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 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": 289, "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 } ], "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": 46, "end_line": 47, "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": 48, "end_line": 98, "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": 100, "end_line": 101, "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": 103, "end_line": 104, "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": 112, "end_line": 113, "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": 32, "complexity": 11, "token_count": 255, "parameters": [ "self", "key" ], "start_line": 114, "end_line": 145, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 32, "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": 147, "end_line": 148, "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": 150, "end_line": 151, "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": 182, "end_line": 186, "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": 188, "end_line": 189, "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": 191, "end_line": 194, "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": 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": "index_tricks.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": "__getitem__", "long_name": "__getitem__( self , key )", "filename": "index_tricks.py", "nloc": 35, "complexity": 12, "token_count": 289, "parameters": [ "self", "key" ], "start_line": 116, "end_line": 150, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 35, "top_nesting_level": 1 } ], "nloc": 171, "complexity": 42, "token_count": 1032, "diff_parsed": { "added": [ "import matrix_base", "import sys", " if isinstance(key,types.StringType):", " frame = sys._getframe().f_back", " return matrix_base.bmat(key,frame.f_globals,frame.f_locals)" ], "deleted": [] } }, { "old_path": "scipy_base/matrix_base.py", "new_path": "scipy_base/matrix_base.py", "filename": "matrix_base.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -2,9 +2,10 @@\n \n \"\"\"\n \n-__all__ = ['diag','eye','fliplr','flipud','rot90']\n+__all__ = ['diag','eye','fliplr','flipud','rot90','bmat']\n \n from Numeric import *\n+import Matrix\n \n def fliplr(m):\n \"\"\" returns a 2-D matrix m with the rows preserved and columns flipped \n@@ -75,6 +76,63 @@ def diag(v, k=0):\n raise ValueError, \"Input must be 1- or 2-D.\"\n \n \n+def _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+\n+import sys\n+def 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", "added_lines": 59, "deleted_lines": 1, "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#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','rot90']\n\nfrom Numeric import *\n\ndef fliplr(m):\n \"\"\" returns a 2-D matrix m with the rows preserved and columns flipped \n in the left/right direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[:, ::-1]\n\ndef flipud(m):\n \"\"\" returns a 2-D matrix with the columns preserved and rows flipped in\n the up/down direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[::-1]\n \n# reshape(x, m, n) is not used, instead use reshape(x, (m, n))\n\ndef rot90(m, k=1):\n \"\"\" returns the matrix found by rotating m by k*90 degrees in the \n counterclockwise direction.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n k = k % 4\n if k == 0: return m\n elif k == 1: return transpose(fliplr(m))\n elif k == 2: return fliplr(flipud(m))\n else: return fliplr(transpose(m)) # k==3\n \ndef eye(N, M=None, k=0, typecode='d'):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n and everything else is zeros.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n\ndef diag(v, k=0):\n \"\"\" returns the k-th diagonal if v is a matrix or returns a matrix \n with v as the k-th diagonal if v is a vector.\n \"\"\"\n v = asarray(v)\n s = v.shape\n if len(s)==1:\n n = s[0]+abs(k)\n if k > 0:\n v = concatenate((zeros(k, v.typecode()),v))\n elif k < 0:\n v = concatenate((v,zeros(-k, v.typecode())))\n return eye(n, k=k)*v\n elif len(s)==2:\n v = add.reduce(eye(s[0], s[1], k=k)*v)\n if k > 0: return v[k:]\n elif k < 0: return v[:k]\n else: return v\n else:\n raise ValueError, \"Input must be 1- or 2-D.\"\n\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "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 }, { "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 } ], "methods_before": [ { "name": "fliplr", "long_name": "fliplr( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 35, "parameters": [ "m" ], "start_line": 9, "end_line": 16, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "flipud", "long_name": "flipud( m )", "filename": "matrix_base.py", "nloc": 5, "complexity": 2, "token_count": 33, "parameters": [ "m" ], "start_line": 18, "end_line": 25, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 8, "top_nesting_level": 0 }, { "name": "rot90", "long_name": "rot90( m , k = 1 )", "filename": "matrix_base.py", "nloc": 9, "complexity": 5, "token_count": 78, "parameters": [ "m", "k" ], "start_line": 29, "end_line": 40, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 12, "top_nesting_level": 0 }, { "name": "eye", "long_name": "eye( N , M = None , k = 0 , typecode = 'd' )", "filename": "matrix_base.py", "nloc": 10, "complexity": 4, "token_count": 81, "parameters": [ "N", "M", "k", "typecode" ], "start_line": 42, "end_line": 54, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 13, "top_nesting_level": 0 }, { "name": "diag", "long_name": "diag( v , k = 0 )", "filename": "matrix_base.py", "nloc": 17, "complexity": 7, "token_count": 165, "parameters": [ "v", "k" ], "start_line": 56, "end_line": 75, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 20, "top_nesting_level": 0 }, { "name": "test", "long_name": "test( level = 10 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 23, "parameters": [ "level" ], "start_line": 82, "end_line": 84, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 }, { "name": "test_suite", "long_name": "test_suite( level = 1 )", "filename": "matrix_base.py", "nloc": 3, "complexity": 1, "token_count": 24, "parameters": [ "level" ], "start_line": 86, "end_line": 88, "fan_in": 0, "fan_out": 0, "general_fan_out": 0, "length": 3, "top_nesting_level": 0 } ], "changed_methods": [ { "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": "_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 } ], "nloc": 97, "complexity": 34, "token_count": 745, "diff_parsed": { "added": [ "__all__ = ['diag','eye','fliplr','flipud','rot90','bmat']", "import Matrix", "def _from_string(str,gdict,ldict):", " rows = str.split(';')", " rowtup = []", " for row in rows:", " trow = row.split(',')", " coltup = []", " for col in trow:", " col = col.strip()", " try:", " thismat = gdict[col]", " except KeyError:", " try:", " thismat = ldict[col]", " except KeyError:", " raise KeyError, \"%s not found\" % (col,)", "", " coltup.append(thismat)", " rowtup.append(concatenate(coltup,axis=-1))", " return concatenate(rowtup,axis=0)", "", "import sys", "def bmat(obj,gdict=None,ldict=None):", " \"\"\"Build a matrix object from string, nested sequence, or array.", "", " Ex: F = bmat('A, B; C, D')", " F = bmat([[A,B],[C,D]])", " F = bmat(r_[c_[A,B],c_[C,D]])", "", " all produce the same Matrix Object [ A B ]", " [ C D ]", "", " if A, B, C, and D are appropriately shaped 2-d arrays.", " \"\"\"", " if isinstance(obj, types.StringType):", " if gdict is None:", " # get previous frame", " frame = sys._getframe().f_back", " glob_dict = frame.f_globals", " loc_dict = frame.f_locals", " else:", " glob_dict = gdict", " loc_dict = ldict", "", " return Matrix.Matrix(_from_string(obj, glob_dict, loc_dict))", "", " if isinstance(obj, (types.TupleType, types.ListType)):", " # [[A,B],[C,D]]", " arr_rows = []", " for row in obj:", " if isinstance(row, ArrayType): # not 2-d", " return Matrix.Matrix(concatenate(obj,axis=-1))", " else:", " arr_rows.append(concatenate(row,axis=-1))", " return Matrix.Matrix(concatenate(arr_rows,axis=0))", " if isinstance(obj, ArrayType):", " return Matrix.Matrix(obj)", "" ], "deleted": [ "__all__ = ['diag','eye','fliplr','flipud','rot90']" ] } } ] }, { "hash": "362e645bb521c3a68e2b398df561b15aded99491", "msg": "Fixed some warnings from wxPython about not getting integers.", "author": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "committer": { "name": "Travis Oliphant", "email": "oliphant@enthought.com" }, "author_date": "2003-09-23T23:50:36+00:00", "author_timezone": 0, "committer_date": "2003-09-23T23:50:36+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "a081902f0cef6b53c3443de294a53c14726483ed" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/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/index_tricks.py", "new_path": "scipy_base/index_tricks.py", "filename": "index_tricks.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -116,7 +116,7 @@ def __init__(self, axis=0):\n def __getitem__(self,key):\n if isinstance(key,types.StringType):\n frame = sys._getframe().f_back\n- return matrix_base.bmat(key,frame.f_globals,frame.f_locals)\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", "added_lines": 1, "deleted_lines": 1, "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#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_test.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n", "source_code_before": "import 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 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 }, { "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 } ], "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": 289, "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": "__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 } ], "nloc": 171, "complexity": 42, "token_count": 1035, "diff_parsed": { "added": [ " return array(matrix_base.bmat(key,frame.f_globals,frame.f_locals))" ], "deleted": [ " return matrix_base.bmat(key,frame.f_globals,frame.f_locals)" ] } } ] }, { "hash": "ea8b5c7c7f8757f524c4ba2d7a6e6db0be5f6930", "msg": "Changed assert to show why check_add_function_ordered test fails (using Python 2.3)", "author": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "committer": { "name": "Pearu Peterson", "email": "pearu.peterson@gmail.com" }, "author_date": "2003-09-24T10:38:27+00:00", "author_timezone": 0, "committer_date": "2003-09-24T10:38:27+00:00", "committer_timezone": 0, "branches": [ "main" ], "in_main_branch": true, "merge": false, "parents": [ "362e645bb521c3a68e2b398df561b15aded99491" ], "project_name": "repo_copy", "project_path": "/tmp/tmp_bzt7mo3/repo_copy", "deletions": 1, "insertions": 1, "lines": 2, "files": 1, "dmm_unit_size": null, "dmm_unit_complexity": null, "dmm_unit_interfacing": null, "modified_files": [ { "old_path": "weave/tests/test_catalog.py", "new_path": "weave/tests/test_catalog.py", "filename": "test_catalog.py", "extension": "py", "change_type": "MODIFY", "diff": "@@ -326,7 +326,7 @@ def check_add_function_ordered(self):\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])\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", "added_lines": 1, "deleted_lines": 1, "source_code": "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", "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])\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": 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 } ], "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": 300, "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": "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 } ], "nloc": 278, "complexity": 51, "token_count": 2015, "diff_parsed": { "added": [ " assert(funcs1[:2] == [string.lower,string.upper]),`funcs1`" ], "deleted": [ " assert(funcs1[:2] == [string.lower,string.upper])" ] } } ] } ]