diff --git "a/partition_7.json" "b/partition_7.json" new file mode 100644--- /dev/null +++ "b/partition_7.json" @@ -0,0 +1,58089 @@ +[ + { + "hash": "0fed82b1ace83f2da4b71d019e8e7814bf4ec50a", + "msg": "Introduced ScipyTestCase with timing hooks", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2002-03-05T16:12:39+00:00", + "author_timezone": 0, + "committer_date": "2002-03-05T16:12:39+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "cf5035a497ee83adb91090bf4f4d3c6faf969b9f" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 1, + "insertions": 19, + "lines": 20, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "scipy_test/scipy_test.py", + "new_path": "scipy_test/scipy_test.py", + "filename": "scipy_test.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,4 +1,22 @@\n-import os\n+\n+import os,sys,time\n+import unittest\n+\n+class ScipyTestCase (unittest.TestCase):\n+\n+ def measure(self,code_str,times=1):\n+ frame = sys._getframe(1)\n+ locs,globs = frame.f_locals,frame.f_globals\n+ code = compile(code_str,\n+ 'ScipyTestCase runner for '+self.__class__.__name__,\n+ 'exec')\n+ i = 0\n+ elapsed = time.time()\n+ while i 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 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, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\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.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 files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\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 cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError, 'failure during compile' \n object_files.append(object)\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 f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_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 # 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 self.create_static_lib(obj,library_name,temp_dir)\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.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: Is 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 #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\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 return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(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):\n fortran_compiler_base.__init__(self)\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 = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\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 self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\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 def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\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\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\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 = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\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 def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = ['g2c']\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 switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\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\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if 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 ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_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/f50/linux/\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, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\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 '\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\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\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 for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\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):\n fortran_compiler_base.__init__(self)\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.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\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\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 # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\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)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_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 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\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\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 *\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\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 \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\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 fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\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 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, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\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.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 files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\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 cmd = compiler + ' ' + switches + \\\n module_switch + \\\n ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError, 'failure during compile' \n object_files.append(object)\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 f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_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 # 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 self.create_static_lib(obj,library_name,temp_dir)\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.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: Is 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 #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\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 return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(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):\n fortran_compiler_base.__init__(self)\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 = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\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 self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\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 def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\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\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\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 = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\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 def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = ['g2c']\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 switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\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\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if 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 ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_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/f50/linux/\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, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\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 '\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\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\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 for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\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):\n fortran_compiler_base.__init__(self)\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.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\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\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 # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\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)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_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 gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", + "methods": [ + { + "name": "run_command", + "long_name": "run_command( command )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "command" + ], + "start_line": 59, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "show_compilers", + "long_name": "show_compilers( )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 3, + "token_count": 23, + "parameters": [], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_flib.py", + "nloc": 17, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 138, + "end_line": 140, + "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": 142, + "end_line": 145, + "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": 149, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 155, + "end_line": 175, + "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": 177, + "end_line": 182, + "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": 184, + "end_line": 189, + "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": 193, + "end_line": 210, + "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": 214, + "end_line": 223, + "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": 227, + "end_line": 238, + "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": 25, + "complexity": 10, + "token_count": 181, + "parameters": [ + "self", + "fortran_libraries" + ], + "start_line": 240, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "verbose", + "dry_run", + "force" + ], + "start_line": 287, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "to_object", + "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 16, + "complexity": 3, + "token_count": 89, + "parameters": [ + "self", + "dirty_files", + "module_dirs", + "temp_dir" + ], + "start_line": 312, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 329, + "end_line": 334, + "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": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f_compile", + "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 4, + "token_count": 132, + "parameters": [ + "self", + "compiler", + "switches", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 341, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 365, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f77_compile", + "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 370, + "end_line": 373, + "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 )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 376, + "end_line": 377, + "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 )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "object_files", + "library_name", + "output_dir", + "debug" + ], + "start_line": 379, + "end_line": 390, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "build_library", + "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self", + "library_name", + "source_list", + "module_dirs", + "temp_dir" + ], + "start_line": 392, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dummy_fortran_files", + "long_name": "dummy_fortran_files( self )", + "filename": "build_flib.py", + "nloc": 8, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 422, + "end_line": 429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 431, + "end_line": 432, + "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": 10, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 454, + "end_line": 455, + "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": 456, + "end_line": 457, + "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": 458, + "end_line": 459, + "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": 460, + "end_line": 461, + "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": 462, + "end_line": 467, + "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": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 469, + "end_line": 470, + "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 )", + "filename": "build_flib.py", + "nloc": 31, + "complexity": 5, + "token_count": 177, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 478, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 518, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "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": 525, + "end_line": 526, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 539, + "end_line": 561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 563, + "end_line": 568, + "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": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 570, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 585, + "end_line": 586, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_extra_link_args", + "long_name": "get_extra_link_args( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 587, + "end_line": 588, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 596, + "end_line": 614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 616, + "end_line": 618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "find_lib_dir", + "long_name": "find_lib_dir( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 619, + "end_line": 621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 622, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_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": 624, + "end_line": 625, + "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 )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 633, + "end_line": 657, + "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": 21, + "complexity": 10, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 659, + "end_line": 682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "find_lib_directories", + "long_name": "find_lib_directories( self )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 684, + "end_line": 694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 2, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 696, + "end_line": 699, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 701, + "end_line": 702, + "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 )", + "filename": "build_flib.py", + "nloc": 22, + "complexity": 5, + "token_count": 140, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 711, + "end_line": 739, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "get_opt", + "long_name": "get_opt( self )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 7, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 741, + "end_line": 755, + "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": 758, + "end_line": 759, + "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 )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 767, + "end_line": 770, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 778, + "end_line": 797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 799, + "end_line": 801, + "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": 803, + "end_line": 804, + "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 )", + "filename": "build_flib.py", + "nloc": 20, + "complexity": 5, + "token_count": 128, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 812, + "end_line": 836, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 840, + "end_line": 841, + "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 )", + "filename": "build_flib.py", + "nloc": 14, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 848, + "end_line": 870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 872, + "end_line": 874, + "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": 876, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "match_extension", + "long_name": "match_extension( files , ext )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "files", + "ext" + ], + "start_line": 881, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_f77_files", + "long_name": "get_f77_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 885, + "end_line": 886, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_f90_files", + "long_name": "get_f90_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 888, + "end_line": 889, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_fortran_files", + "long_name": "get_fortran_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 891, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "find_fortran_compiler", + "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 5, + "token_count": 59, + "parameters": [ + "vendor", + "fc", + "f90c" + ], + "start_line": 894, + "end_line": 904, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "run_command", + "long_name": "run_command( command )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "command" + ], + "start_line": 59, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "show_compilers", + "long_name": "show_compilers( )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 3, + "token_count": 23, + "parameters": [], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_flib.py", + "nloc": 17, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 138, + "end_line": 140, + "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": 142, + "end_line": 145, + "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": 149, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 155, + "end_line": 175, + "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": 177, + "end_line": 182, + "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": 184, + "end_line": 189, + "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": 193, + "end_line": 210, + "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": 214, + "end_line": 223, + "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": 227, + "end_line": 238, + "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": 25, + "complexity": 10, + "token_count": 181, + "parameters": [ + "self", + "fortran_libraries" + ], + "start_line": 240, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "verbose", + "dry_run", + "force" + ], + "start_line": 287, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "to_object", + "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 16, + "complexity": 3, + "token_count": 89, + "parameters": [ + "self", + "dirty_files", + "module_dirs", + "temp_dir" + ], + "start_line": 312, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 329, + "end_line": 334, + "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": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f_compile", + "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 4, + "token_count": 128, + "parameters": [ + "self", + "compiler", + "switches", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 341, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 365, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f77_compile", + "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 370, + "end_line": 373, + "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 )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 376, + "end_line": 377, + "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 )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "object_files", + "library_name", + "output_dir", + "debug" + ], + "start_line": 379, + "end_line": 390, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "build_library", + "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self", + "library_name", + "source_list", + "module_dirs", + "temp_dir" + ], + "start_line": 392, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dummy_fortran_files", + "long_name": "dummy_fortran_files( self )", + "filename": "build_flib.py", + "nloc": 8, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 422, + "end_line": 429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 431, + "end_line": 432, + "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": 10, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 454, + "end_line": 455, + "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": 456, + "end_line": 457, + "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": 458, + "end_line": 459, + "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": 460, + "end_line": 461, + "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": 462, + "end_line": 467, + "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": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 469, + "end_line": 470, + "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 )", + "filename": "build_flib.py", + "nloc": 31, + "complexity": 5, + "token_count": 177, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 478, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 518, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "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": 525, + "end_line": 526, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 539, + "end_line": 561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 563, + "end_line": 568, + "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": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 570, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 585, + "end_line": 586, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_extra_link_args", + "long_name": "get_extra_link_args( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 587, + "end_line": 588, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 596, + "end_line": 614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 616, + "end_line": 618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "find_lib_dir", + "long_name": "find_lib_dir( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 619, + "end_line": 621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 622, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_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": 624, + "end_line": 625, + "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 )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 633, + "end_line": 657, + "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": 21, + "complexity": 10, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 659, + "end_line": 682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "find_lib_directories", + "long_name": "find_lib_directories( self )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 684, + "end_line": 694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 2, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 696, + "end_line": 699, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 701, + "end_line": 702, + "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 )", + "filename": "build_flib.py", + "nloc": 22, + "complexity": 5, + "token_count": 140, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 711, + "end_line": 739, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "get_opt", + "long_name": "get_opt( self )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 7, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 741, + "end_line": 755, + "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": 758, + "end_line": 759, + "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 )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 767, + "end_line": 770, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 778, + "end_line": 797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 799, + "end_line": 801, + "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": 803, + "end_line": 804, + "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 )", + "filename": "build_flib.py", + "nloc": 20, + "complexity": 5, + "token_count": 128, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 812, + "end_line": 836, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 840, + "end_line": 841, + "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 )", + "filename": "build_flib.py", + "nloc": 14, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 848, + "end_line": 870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 872, + "end_line": 874, + "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": 876, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "match_extension", + "long_name": "match_extension( files , ext )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "files", + "ext" + ], + "start_line": 881, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_f77_files", + "long_name": "get_f77_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 885, + "end_line": 886, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_f90_files", + "long_name": "get_f90_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 888, + "end_line": 889, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_fortran_files", + "long_name": "get_fortran_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 891, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "find_fortran_compiler", + "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 5, + "token_count": 59, + "parameters": [ + "vendor", + "fc", + "f90c" + ], + "start_line": 894, + "end_line": 904, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "f_compile", + "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 4, + "token_count": 132, + "parameters": [ + "self", + "compiler", + "switches", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 341, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + } + ], + "nloc": 657, + "complexity": 170, + "token_count": 3838, + "diff_parsed": { + "added": [ + " switches = switches + ' ' + string.join(pp_opts,' ')", + " cmd = compiler + ' ' + switches + ' '+\\" + ], + "deleted": [ + " switches = switches + string.join(pp_opts,' ')", + " cmd = compiler + ' ' + switches + \\" + ] + } + } + ] + }, + { + "hash": "f977db592df256485e8bbf5871bc103d7381375a", + "msg": "Impl. debian specific (but general) atlas finding hooks", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2002-03-23T08:13:04+00:00", + "author_timezone": 0, + "committer_date": "2002-03-23T08:13:04+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "b1da40a43f700c57b3cae6c73cf7073031096e68" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 9, + "insertions": 26, + "lines": 35, + "files": 2, + "dmm_unit_size": 0.7647058823529411, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "scipy_distutils/command/run_f2py.py", + "new_path": "scipy_distutils/command/run_f2py.py", + "filename": "run_f2py.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -11,7 +11,7 @@\n from scipy_distutils.core import Command\n from scipy_distutils.system_info import F2pyNotFoundError\n \n-import re,os,string\n+import re,os,sys,string\n \n module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]+)',re.I).match\n user_module_name_re = re.compile(r'\\s*python\\s*module\\s*(?P[\\w_]*?__user__[\\w_]*)',re.I).match\n@@ -76,10 +76,10 @@ def f2py_sources (self, sources, ext):\n If 'sources' contains not .pyf files, then create a temporary\n one from the Fortran files in 'sources'.\n \"\"\"\n- import string\n try:\n import f2py2e\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", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "\"\"\"distutils.command.run_f2py\n\nImplements the Distutils 'run_f2py' command.\n\"\"\"\n\n# created 2002/01/09, Pearu Peterson \n\n__revision__ = \"$Id$\"\n\nfrom distutils.dep_util import newer\nfrom scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\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_]*?__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 a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains not .pyf files, then create a temporary\n one from the Fortran files in 'sources'.\n \"\"\"\n try:\n import f2py2e\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 # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions 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 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('%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,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_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 pyf_fortran_target_file = os.path.join(target_dir,ext_name+fortran_target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(\"f2py-ing a new %s\" % (pyf_target))\n self.announce(\"f2py-opts: %s\" % \\\n string.join(f2py_opts2,' '))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\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\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn('Only one .pyf file can be used per Extension but got %s.'\\\n % (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 f2py_options = ext.f2py_options + self.f2py_options\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-opts: %s\" % string.join(f2py_options,' '))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {'sources':[],\n 'define_macros':[],\n 'undef_macros':[],\n 'include_dirs':[],\n }\n fortran_libraries.append((name,flib))\n \n flib['sources'].extend(f_files)\n flib['define_macros'].extend(ext.define_macros)\n flib['undef_macros'].extend(ext.undef_macros)\n flib['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 scipy_distutils.core import Command\nfrom scipy_distutils.system_info import F2pyNotFoundError\n\nimport re,os,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_]*?__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 a modified 'sources' list with f2py source files replaced\n by the generated C (or C++) and Fortran files.\n If 'sources' contains not .pyf files, then create a temporary\n one from the Fortran files in 'sources'.\n \"\"\"\n import string\n try:\n import f2py2e\n except ImportError:\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 # In addition, /src/fortranobject.{c,h} are needed\n # for building f2py generated extension modules.\n # It is assumed that one pyf file contains defintions 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 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('%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,base+fortran_target_ext)\n f2py_sources.append(source)\n f2py_targets[source] = target_file\n f2py_fortran_targets[source] = fortran_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 pyf_fortran_target_file = os.path.join(target_dir,ext_name+fortran_target_ext)\n f2py_opts2 = ['-m',ext_name,'-h',pyf_target,'--overwrite-signature']\n for source in fortran_sources:\n if newer(source,pyf_target) or self.force:\n self.announce(\"f2py-ing a new %s\" % (pyf_target))\n self.announce(\"f2py-opts: %s\" % \\\n string.join(f2py_opts2,' '))\n f2py2e.run_main(fortran_sources + f2py_opts2)\n break\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\n new_sources.extend(fortran_sources)\n\n if len(f2py_sources) > 1:\n self.warn('Only one .pyf file can be used per Extension but got %s.'\\\n % (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 f2py_options = ext.f2py_options + self.f2py_options\n\n for source in f2py_sources:\n target = f2py_targets[source]\n fortran_target = f2py_fortran_targets[source]\n if newer(source,target) or self.force:\n self.announce(\"f2py-ing %s to %s\" % (source, target))\n self.announce(\"f2py-opts: %s\" % string.join(f2py_options,' '))\n f2py2e.run_main(f2py_options + [source])\n new_sources.append(target)\n if os.path.exists(fortran_target):\n new_sources.append(fortran_target)\n return new_sources\n\n # f2py_sources ()\n\n def fortran_sources_to_flib(self, ext):\n \"\"\"\n Extract fortran files from ext.sources and append them to\n fortran_libraries item having the same name as ext.\n \"\"\"\n sources = []\n f_files = []\n\n for file in ext.sources:\n if fortran_ext_re(file):\n f_files.append(file)\n else:\n sources.append(file)\n if not f_files:\n return\n\n ext.sources = sources\n\n if self.distribution.fortran_libraries is None:\n self.distribution.fortran_libraries = []\n fortran_libraries = self.distribution.fortran_libraries\n\n ext_name = string.split(ext.name,'.')[-1]\n name = ext_name\n flib = None\n for n,d in fortran_libraries:\n if n == name:\n flib = d\n break\n if flib is None:\n flib = {'sources':[],\n 'define_macros':[],\n 'undef_macros':[],\n 'include_dirs':[],\n }\n fortran_libraries.append((name,flib))\n \n flib['sources'].extend(f_files)\n flib['define_macros'].extend(ext.define_macros)\n flib['undef_macros'].extend(ext.undef_macros)\n flib['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": 35, + "end_line": 40, + "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": 44, + "end_line": 54, + "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": 58, + "end_line": 67, + "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": 81, + "complexity": 21, + "token_count": 593, + "parameters": [ + "self", + "sources", + "ext" + ], + "start_line": 70, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 1 + }, + { + "name": "fortran_sources_to_flib", + "long_name": "fortran_sources_to_flib( self , ext )", + "filename": "run_f2py.py", + "nloc": 32, + "complexity": 8, + "token_count": 196, + "parameters": [ + "self", + "ext" + ], + "start_line": 187, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "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": 35, + "end_line": 40, + "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": 44, + "end_line": 54, + "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": 58, + "end_line": 67, + "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": 81, + "complexity": 21, + "token_count": 591, + "parameters": [ + "self", + "sources", + "ext" + ], + "start_line": 70, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 1 + }, + { + "name": "fortran_sources_to_flib", + "long_name": "fortran_sources_to_flib( self , ext )", + "filename": "run_f2py.py", + "nloc": 32, + "complexity": 8, + "token_count": 196, + "parameters": [ + "self", + "ext" + ], + "start_line": 187, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "f2py_sources", + "long_name": "f2py_sources( self , sources , ext )", + "filename": "run_f2py.py", + "nloc": 81, + "complexity": 21, + "token_count": 593, + "parameters": [ + "self", + "sources", + "ext" + ], + "start_line": 70, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 114, + "top_nesting_level": 1 + } + ], + "nloc": 157, + "complexity": 36, + "token_count": 1059, + "diff_parsed": { + "added": [ + "import re,os,sys,string", + " print sys.exc_value" + ], + "deleted": [ + "import re,os,string", + " import string" + ] + } + }, + { + "old_path": "scipy_distutils/system_info.py", + "new_path": "scipy_distutils/system_info.py", + "filename": "system_info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -114,10 +114,14 @@ def get_info(self):\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n- for p in self.local_prefixes + prefixes:\n- if self.verbose:\n- print ' Looking in',p,'...'\n- self.calc_info(p)\n+ for n in ['calc_info','calc_info_debian']:\n+ calc_info = getattr(self,n,None)\n+ if calc_info is None: continue\n+ for p in self.local_prefixes + prefixes:\n+ if self.verbose:\n+ print ' Looking in',p,'...'\n+ calc_info(p)\n+ if self.has_info(): break\n if self.has_info(): break\n if self.verbose:\n if not self.has_info():\n@@ -132,9 +136,9 @@ def get_info(self):\n print\n return res\n \n- def calc_info(self,prefix):\n+ def calc_info_template(self,prefix):\n \"\"\" Calculate info distionary. \"\"\"\n-\n+ \n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n@@ -309,7 +313,20 @@ def calc_info(self, prefix):\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n \n-\n+ def calc_info_debian(self,prefix):\n+ print 'Trying Debian setup'\n+ info = self.check_libs(os.path.join(prefix,'lib'),\n+ ['cblas','f77blas','atlas'],[])\n+ if not info: return\n+ lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])\n+ if not lapack:\n+ lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])\n+ if not lapack: return\n+ h = (combine_paths(prefix,'include','cblas.h') or [None])[0]\n+ if h: dict_append(info,include_dirs=[os.path.dirname(h)])\n+ dict_append(info,**lapack)\n+ self.set_info(**info)\n+ \n class blas_info(system_info):\n # For Fortran or optimized blas, not atlas.\n pass\n", + "added_lines": 24, + "deleted_lines": 7, + "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n fftw_info\n x11_info\nThe following environment variables are used if defined:\n ATLAS - path to ATLAS library\n FFTW - path to FFTW library\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (or system_info could not find it).\n\nGlobal parameters:\n prefixes - a list of prefixes for scanning the location of\n resources.\n system_info.static_first - a flag for indicating that static\n libraries are searched first than shared ones.\n system_info.verbose - show the results if set.\n\nAuthor:\n Pearu Peterson , February 2002\nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types,pprint\nfrom distutils.errors import DistutilsError\nfrom glob import glob\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n prefixes = ['C:\\\\'] # XXX: what is prefix in win32?\nelse:\n prefixes = ['/usr','/usr/local','/opt']\nif sys.prefix not in prefixes:\n prefixes.append(sys.prefix)\nprefixes = filter(os.path.isdir,prefixes) # XXX: Is this ok on win32? Is 'C:' dir?\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info}.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Either install them in /usr/local/lib/atlas or /usr/lib/atlas\n and retry setup.py. One can use also ATLAS environment variable\n to indicate the location of Atlas libraries.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Either install them in /usr/local/lib or /usr/lib and retry setup.py.\n One can use also FFTW environment variable to indicate\n the location of FFTW libraries.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://pfdubois.com/numpy/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n\n static_first = 1\n verbose = 1\n need_refresh = 1\n saved_results = {}\n \n def __init__ (self):\n self.__class__.info = {}\n #self.__class__.need_refresh = not self.info\n self.local_prefixes = []\n\n def set_info(self,**info):\n #self.__class__.info = info\n self.saved_results[self.__class__.__name__] = info\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n for n in ['calc_info','calc_info_debian']:\n calc_info = getattr(self,n,None)\n if calc_info is None: continue\n for p in self.local_prefixes + prefixes:\n if self.verbose:\n print ' Looking in',p,'...'\n calc_info(p)\n if self.has_info(): break\n if self.has_info(): break\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n print ' %s = %s'%(k,v)\n print\n return res\n\n def calc_info_template(self,prefix):\n \"\"\" Calculate info distionary. \"\"\"\n \n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n mths = [self.check_static_libs,self.check_shared_libs]\n if not self.static_first:\n mths.reverse() # if one prefers shared libraries\n for m in mths:\n info = m(lib_dir,libs,opt_libs)\n if info is not None: return info\n\n def check_static_libs(self,lib_dir,libs,opt_libs =[]):\n #XXX: what are .lib and .dll files under win32?\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs])) == len(libs):\n info = {'libraries':libs,'library_dirs':[lib_dir]}\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs]))\\\n ==len(opt_libs):\n info['libraries'].extend(opt_libs)\n return info\n\n def check_shared_libs(self,lib_dir,libs,opt_libs =[]):\n shared_libs = []\n for l in libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: shared_libs.append(p)\n if len(shared_libs) == len(libs):\n info = {'extra_objects':shared_libs}\n opt_shared_libs = []\n for l in opt_libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: opt_shared_libs.append(p)\n info['extra_objects'].extend(opt_shared_libs)\n return info\n\n\nclass fftw_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('FFTW')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self,prefix): \n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,'lib',['fftw*','FFTW*']))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'lib'))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','fftw*','FFTW*']))\n \n if not lib_dirs:\n lib_dirs = [prefix]\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,'include',['fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'include'))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['include','fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = [prefix]\n incl_dir = None\n\n libs = ['fftw','rfftw']\n opt_libs = ['fftw_threads','rfftw_threads']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['fftw.h','rfftw.h']))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_FFTW_H',1)])\n else:\n info = None\n\n if info is None:\n libs = ['dfftw','drfftw']\n opt_libs = ['dfftw_threads','drfftw_threads']\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['dfftw.h','drfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n incl_dirs = [d]\n incl_dir = d\n flag = 1\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)])\n else:\n info = None\n \n libs = ['sfftw','srfftw']\n opt_libs = ['sfftw_threads','srfftw_threads']\n flag = 0\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n if info is None: info = r\n else: dict_append(info,**r)\n flag = 1\n break\n if info is not None and flag:\n for d in incl_dirs:\n if len(combine_paths(d,['sfftw.h','srfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n dict_append(info,define_macros=[('SCIPY_SFFTW_H',1)])\n break\n if info is not None:\n self.set_info(**info)\n\n\nclass atlas_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('ATLAS')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self, prefix):\n print combine_paths(prefix,'lib',['atlas*','ATLAS*'])\n lib_dirs = filter(os.path.isdir,combine_paths(prefix,'lib',\n ['atlas*','ATLAS*']))\n if lib_dirs:\n other_dirs = filter(os.path.isdir,combine_paths(lib_dirs,'*'))\n other_dirs.extend(filter(os.path.isdir,combine_paths(prefix,'lib')))\n lib_dirs.extend(other_dirs)\n else:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','atlas*','ATLAS*']))\n if not lib_dirs:\n lib_dirs = [prefix]\n\n h = (combine_paths(lib_dirs,'cblas.h') or [None])[0]\n if not h:\n h = (combine_paths(lib_dirs,'include','cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n\n libs = ['lapack','f77blas','cblas','atlas']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,[])\n if r is not None:\n info = r\n break\n if info is None: return\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n\n def calc_info_debian(self,prefix):\n print 'Trying Debian setup'\n info = self.check_libs(os.path.join(prefix,'lib'),\n ['cblas','f77blas','atlas'],[])\n if not info: return\n lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])\n if not lapack:\n lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])\n if not lapack: return\n h = (combine_paths(prefix,'include','cblas.h') or [None])[0]\n if h: dict_append(info,include_dirs=[os.path.dirname(h)])\n dict_append(info,**lapack)\n self.set_info(**info)\n \nclass blas_info(system_info):\n # For Fortran or optimized blas, not atlas.\n pass\n\n\nclass lapack_info(system_info):\n # For Fortran or optimized lapack, not atlas\n pass\n\n\nclass x11_info(system_info):\n\n def calc_info(self, prefix):\n if sys.platform == 'win32':\n return\n for x11_dir in combine_paths(prefix,['X11R6','X11']):\n inc_dir = None\n for d in combine_paths(x11_dir,['include','include/X11']):\n if combine_paths(d,'X.h'):\n inc_dir = d\n break\n if not d: return\n lib_dir = combine_paths(x11_dir,'lib')\n if not lib_dir: return\n info = self.check_libs(lib_dir[0],['X11'],[])\n if info is None:\n continue\n dict_append(info,include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef shortest_path(pths):\n pths.sort()\n if pths: return pths[0]\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n fftw_info\n x11_info\nThe following environment variables are used if defined:\n ATLAS - path to ATLAS library\n FFTW - path to FFTW library\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (or system_info could not find it).\n\nGlobal parameters:\n prefixes - a list of prefixes for scanning the location of\n resources.\n system_info.static_first - a flag for indicating that static\n libraries are searched first than shared ones.\n system_info.verbose - show the results if set.\n\nAuthor:\n Pearu Peterson , February 2002\nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types,pprint\nfrom distutils.errors import DistutilsError\nfrom glob import glob\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n prefixes = ['C:\\\\'] # XXX: what is prefix in win32?\nelse:\n prefixes = ['/usr','/usr/local','/opt']\nif sys.prefix not in prefixes:\n prefixes.append(sys.prefix)\nprefixes = filter(os.path.isdir,prefixes) # XXX: Is this ok on win32? Is 'C:' dir?\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info}.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Either install them in /usr/local/lib/atlas or /usr/lib/atlas\n and retry setup.py. One can use also ATLAS environment variable\n to indicate the location of Atlas libraries.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Either install them in /usr/local/lib or /usr/lib and retry setup.py.\n One can use also FFTW environment variable to indicate\n the location of FFTW libraries.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://pfdubois.com/numpy/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n\n static_first = 1\n verbose = 1\n need_refresh = 1\n saved_results = {}\n \n def __init__ (self):\n self.__class__.info = {}\n #self.__class__.need_refresh = not self.info\n self.local_prefixes = []\n\n def set_info(self,**info):\n #self.__class__.info = info\n self.saved_results[self.__class__.__name__] = info\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n for p in self.local_prefixes + prefixes:\n if self.verbose:\n print ' Looking in',p,'...'\n self.calc_info(p)\n if self.has_info(): break\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n print ' %s = %s'%(k,v)\n print\n return res\n\n def calc_info(self,prefix):\n \"\"\" Calculate info distionary. \"\"\"\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n mths = [self.check_static_libs,self.check_shared_libs]\n if not self.static_first:\n mths.reverse() # if one prefers shared libraries\n for m in mths:\n info = m(lib_dir,libs,opt_libs)\n if info is not None: return info\n\n def check_static_libs(self,lib_dir,libs,opt_libs =[]):\n #XXX: what are .lib and .dll files under win32?\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs])) == len(libs):\n info = {'libraries':libs,'library_dirs':[lib_dir]}\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs]))\\\n ==len(opt_libs):\n info['libraries'].extend(opt_libs)\n return info\n\n def check_shared_libs(self,lib_dir,libs,opt_libs =[]):\n shared_libs = []\n for l in libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: shared_libs.append(p)\n if len(shared_libs) == len(libs):\n info = {'extra_objects':shared_libs}\n opt_shared_libs = []\n for l in opt_libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: opt_shared_libs.append(p)\n info['extra_objects'].extend(opt_shared_libs)\n return info\n\n\nclass fftw_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('FFTW')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self,prefix): \n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,'lib',['fftw*','FFTW*']))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'lib'))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','fftw*','FFTW*']))\n \n if not lib_dirs:\n lib_dirs = [prefix]\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,'include',['fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'include'))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['include','fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = [prefix]\n incl_dir = None\n\n libs = ['fftw','rfftw']\n opt_libs = ['fftw_threads','rfftw_threads']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['fftw.h','rfftw.h']))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_FFTW_H',1)])\n else:\n info = None\n\n if info is None:\n libs = ['dfftw','drfftw']\n opt_libs = ['dfftw_threads','drfftw_threads']\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['dfftw.h','drfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n incl_dirs = [d]\n incl_dir = d\n flag = 1\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)])\n else:\n info = None\n \n libs = ['sfftw','srfftw']\n opt_libs = ['sfftw_threads','srfftw_threads']\n flag = 0\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n if info is None: info = r\n else: dict_append(info,**r)\n flag = 1\n break\n if info is not None and flag:\n for d in incl_dirs:\n if len(combine_paths(d,['sfftw.h','srfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n dict_append(info,define_macros=[('SCIPY_SFFTW_H',1)])\n break\n if info is not None:\n self.set_info(**info)\n\n\nclass atlas_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('ATLAS')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self, prefix):\n print combine_paths(prefix,'lib',['atlas*','ATLAS*'])\n lib_dirs = filter(os.path.isdir,combine_paths(prefix,'lib',\n ['atlas*','ATLAS*']))\n if lib_dirs:\n other_dirs = filter(os.path.isdir,combine_paths(lib_dirs,'*'))\n other_dirs.extend(filter(os.path.isdir,combine_paths(prefix,'lib')))\n lib_dirs.extend(other_dirs)\n else:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','atlas*','ATLAS*']))\n if not lib_dirs:\n lib_dirs = [prefix]\n\n h = (combine_paths(lib_dirs,'cblas.h') or [None])[0]\n if not h:\n h = (combine_paths(lib_dirs,'include','cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n\n libs = ['lapack','f77blas','cblas','atlas']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,[])\n if r is not None:\n info = r\n break\n if info is None: return\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n\n\nclass blas_info(system_info):\n # For Fortran or optimized blas, not atlas.\n pass\n\n\nclass lapack_info(system_info):\n # For Fortran or optimized lapack, not atlas\n pass\n\n\nclass x11_info(system_info):\n\n def calc_info(self, prefix):\n if sys.platform == 'win32':\n return\n for x11_dir in combine_paths(prefix,['X11R6','X11']):\n inc_dir = None\n for d in combine_paths(x11_dir,['include','include/X11']):\n if combine_paths(d,'X.h'):\n inc_dir = d\n break\n if not d: return\n lib_dir = combine_paths(x11_dir,'lib')\n if not lib_dir: return\n info = self.check_libs(lib_dir[0],['X11'],[])\n if info is None:\n continue\n dict_append(info,include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef shortest_path(pths):\n pths.sort()\n if pths: return pths[0]\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", + "methods": [ + { + "name": "get_info", + "long_name": "get_info( name )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "name" + ], + "start_line": 52, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "info" + ], + "start_line": 103, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "has_info", + "long_name": "has_info( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 14, + "token_count": 165, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "calc_info_template", + "long_name": "calc_info_template( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 4, + "token_count": 60, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 142, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_static_libs", + "long_name": "check_static_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 5, + "token_count": 91, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 152, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_shared_libs", + "long_name": "check_shared_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 119, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 161, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 178, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 84, + "complexity": 30, + "token_count": 561, + "parameters": [ + "self", + "prefix" + ], + "start_line": 186, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 278, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 11, + "token_count": 244, + "parameters": [ + "self", + "prefix" + ], + "start_line": 286, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "calc_info_debian", + "long_name": "calc_info_debian( self , prefix )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 154, + "parameters": [ + "self", + "prefix" + ], + "start_line": 316, + "end_line": 328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 17, + "complexity": 8, + "token_count": 117, + "parameters": [ + "self", + "prefix" + ], + "start_line": 342, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "shortest_path", + "long_name": "shortest_path( pths )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "pths" + ], + "start_line": 360, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args )", + "filename": "system_info.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "args" + ], + "start_line": 364, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 387, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "show_all", + "long_name": "show_all( )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 3, + "token_count": 59, + "parameters": [], + "start_line": 394, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "get_info", + "long_name": "get_info( name )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "name" + ], + "start_line": 52, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "info" + ], + "start_line": 103, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "has_info", + "long_name": "has_info( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 23, + "complexity": 11, + "token_count": 134, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 135, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 4, + "token_count": 60, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 138, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_static_libs", + "long_name": "check_static_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 5, + "token_count": 91, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 148, + "end_line": 155, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_shared_libs", + "long_name": "check_shared_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 119, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 157, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 174, + "end_line": 180, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 84, + "complexity": 30, + "token_count": 561, + "parameters": [ + "self", + "prefix" + ], + "start_line": 182, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 274, + "end_line": 280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 11, + "token_count": 244, + "parameters": [ + "self", + "prefix" + ], + "start_line": 282, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 17, + "complexity": 8, + "token_count": 117, + "parameters": [ + "self", + "prefix" + ], + "start_line": 325, + "end_line": 341, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "shortest_path", + "long_name": "shortest_path( pths )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "pths" + ], + "start_line": 343, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args )", + "filename": "system_info.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "args" + ], + "start_line": 347, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 370, + "end_line": 375, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "show_all", + "long_name": "show_all( )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 3, + "token_count": 59, + "parameters": [], + "start_line": 377, + "end_line": 384, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "calc_info_debian", + "long_name": "calc_info_debian( self , prefix )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 154, + "parameters": [ + "self", + "prefix" + ], + "start_line": 316, + "end_line": 328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 14, + "token_count": 165, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 135, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_info_template", + "long_name": "calc_info_template( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "nloc": 343, + "complexity": 112, + "token_count": 2219, + "diff_parsed": { + "added": [ + " for n in ['calc_info','calc_info_debian']:", + " calc_info = getattr(self,n,None)", + " if calc_info is None: continue", + " for p in self.local_prefixes + prefixes:", + " if self.verbose:", + " print ' Looking in',p,'...'", + " calc_info(p)", + " if self.has_info(): break", + " def calc_info_template(self,prefix):", + "", + " def calc_info_debian(self,prefix):", + " print 'Trying Debian setup'", + " info = self.check_libs(os.path.join(prefix,'lib'),", + " ['cblas','f77blas','atlas'],[])", + " if not info: return", + " lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])", + " if not lapack:", + " lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])", + " if not lapack: return", + " h = (combine_paths(prefix,'include','cblas.h') or [None])[0]", + " if h: dict_append(info,include_dirs=[os.path.dirname(h)])", + " dict_append(info,**lapack)", + " self.set_info(**info)", + "" + ], + "deleted": [ + " for p in self.local_prefixes + prefixes:", + " if self.verbose:", + " print ' Looking in',p,'...'", + " self.calc_info(p)", + " def calc_info(self,prefix):", + "", + "" + ] + } + } + ] + }, + { + "hash": "c68907a03908af098bcd498a2bc932aed3bc5452", + "msg": "changes for MacOS X compatibility", + "author": { + "name": "jswhit", + "email": "jswhit@localhost" + }, + "committer": { + "name": "jswhit", + "email": "jswhit@localhost" + }, + "author_date": "2002-03-23T14:07:57+00:00", + "author_timezone": 0, + "committer_date": "2002-03-23T14:07:57+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "f977db592df256485e8bbf5871bc103d7381375a" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 1, + "insertions": 7, + "lines": 8, + "files": 2, + "dmm_unit_size": 0.5, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 0.5, + "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": "@@ -249,6 +249,9 @@ def build_libraries (self, libraries):\n self.compiler.create_static_lib(objects, lib_name,\n output_dir=self.build_clib,\n debug=self.debug)\n+ cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)\n+ print cmd\n+ os.system(cmd)\n \n # for libraries\n \n", + "added_lines": 3, + "deleted_lines": 0, + "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\nfrom glob import glob\nfrom types import *\nfrom distutils.core import Command\nfrom distutils.errors import *\nfrom distutils.sysconfig import customize_compiler\n\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 # 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 cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)\n print cmd\n os.system(cmd)\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\n\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 # 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\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": 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": 15, + "complexity": 5, + "token_count": 108, + "parameters": [ + "self" + ], + "start_line": 96, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 126, + "end_line": 149, + "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": 154, + "end_line": 187, + "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": 193, + "end_line": 203, + "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": 208, + "end_line": 218, + "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": 24, + "complexity": 4, + "token_count": 160, + "parameters": [ + "self", + "libraries" + ], + "start_line": 220, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "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": 15, + "complexity": 5, + "token_count": 108, + "parameters": [ + "self" + ], + "start_line": 96, + "end_line": 118, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 126, + "end_line": 149, + "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": 154, + "end_line": 187, + "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": 193, + "end_line": 203, + "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": 208, + "end_line": 218, + "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": 21, + "complexity": 4, + "token_count": 141, + "parameters": [ + "self", + "libraries" + ], + "start_line": 220, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 32, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "build_libraries", + "long_name": "build_libraries( self , libraries )", + "filename": "build_clib.py", + "nloc": 24, + "complexity": 4, + "token_count": 160, + "parameters": [ + "self", + "libraries" + ], + "start_line": 220, + "end_line": 254, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 35, + "top_nesting_level": 1 + } + ], + "nloc": 150, + "complexity": 39, + "token_count": 894, + "diff_parsed": { + "added": [ + " cmd = 'ranlib %s/lib%s.a' % (self.build_clib,lib_name)", + " print cmd", + " os.system(cmd)" + ], + "deleted": [] + } + }, + { + "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": "@@ -388,6 +388,9 @@ def create_static_lib(self, object_files, library_name,\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n+ cmd = 'ranlib %s ' % lib_file\n+ print cmd\n+ os.system(cmd)\n \n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n@@ -695,7 +698,7 @@ def find_lib_directories(self):\n \n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n- if sys.platform != 'win32':\n+ if sys.platform != 'win32' and os.uname()[0] != 'Darwin':\n return [self.f77_compiler,'-shared']\n \n def f90_compile(self,source_files,module_files,temp_dir=''):\n", + "added_lines": 4, + "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\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\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 *\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\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 \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\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 fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\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 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, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\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.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 files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\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 cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError, 'failure during compile' \n object_files.append(object)\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 f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n cmd = 'ranlib %s ' % lib_file\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_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 # 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 self.create_static_lib(obj,library_name,temp_dir)\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.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: Is 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 #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\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 return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(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):\n fortran_compiler_base.__init__(self)\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 = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\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 self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\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 def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\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\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\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 = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\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 def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = ['g2c']\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 switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\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\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if 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 ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32' and os.uname()[0] != 'Darwin':\n return [self.f77_compiler,'-shared']\n \n def f90_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/f50/linux/\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, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\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 '\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\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\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 for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\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):\n fortran_compiler_base.__init__(self)\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.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\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\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 # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\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)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_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 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\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\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 *\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\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 \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\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 fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\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 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, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\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.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 files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\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 cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError, 'failure during compile' \n object_files.append(object)\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 f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_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 # 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 self.create_static_lib(obj,library_name,temp_dir)\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.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: Is 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 #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\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 return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(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):\n fortran_compiler_base.__init__(self)\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 = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\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 self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\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 def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\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\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\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 = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\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 def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = ['g2c']\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 switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\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\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if 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 ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32':\n return [self.f77_compiler,'-shared']\n \n def f90_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/f50/linux/\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, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\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 '\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\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\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 for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\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):\n fortran_compiler_base.__init__(self)\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.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\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\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 # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\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)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_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 gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", + "methods": [ + { + "name": "run_command", + "long_name": "run_command( command )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "command" + ], + "start_line": 59, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "show_compilers", + "long_name": "show_compilers( )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 3, + "token_count": 23, + "parameters": [], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_flib.py", + "nloc": 17, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 138, + "end_line": 140, + "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": 142, + "end_line": 145, + "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": 149, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 155, + "end_line": 175, + "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": 177, + "end_line": 182, + "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": 184, + "end_line": 189, + "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": 193, + "end_line": 210, + "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": 214, + "end_line": 223, + "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": 227, + "end_line": 238, + "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": 25, + "complexity": 10, + "token_count": 181, + "parameters": [ + "self", + "fortran_libraries" + ], + "start_line": 240, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "verbose", + "dry_run", + "force" + ], + "start_line": 287, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "to_object", + "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 16, + "complexity": 3, + "token_count": 89, + "parameters": [ + "self", + "dirty_files", + "module_dirs", + "temp_dir" + ], + "start_line": 312, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 329, + "end_line": 334, + "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": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f_compile", + "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 4, + "token_count": 132, + "parameters": [ + "self", + "compiler", + "switches", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 341, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 365, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f77_compile", + "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 370, + "end_line": 373, + "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 )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 376, + "end_line": 377, + "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 )", + "filename": "build_flib.py", + "nloc": 12, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "object_files", + "library_name", + "output_dir", + "debug" + ], + "start_line": 379, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "build_library", + "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self", + "library_name", + "source_list", + "module_dirs", + "temp_dir" + ], + "start_line": 395, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dummy_fortran_files", + "long_name": "dummy_fortran_files( self )", + "filename": "build_flib.py", + "nloc": 8, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 425, + "end_line": 432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 434, + "end_line": 435, + "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": 10, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 437, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 457, + "end_line": 458, + "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": 459, + "end_line": 460, + "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": 461, + "end_line": 462, + "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": 463, + "end_line": 464, + "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": 465, + "end_line": 470, + "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": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 472, + "end_line": 473, + "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 )", + "filename": "build_flib.py", + "nloc": 31, + "complexity": 5, + "token_count": 177, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 481, + "end_line": 519, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 521, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "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": 528, + "end_line": 529, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 542, + "end_line": 564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 566, + "end_line": 571, + "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": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 573, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 588, + "end_line": 589, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_extra_link_args", + "long_name": "get_extra_link_args( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 590, + "end_line": 591, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 599, + "end_line": 617, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 619, + "end_line": 621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "find_lib_dir", + "long_name": "find_lib_dir( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 622, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 625, + "end_line": 626, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_extra_link_args", + "long_name": "get_extra_link_args( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self" + ], + "start_line": 627, + "end_line": 628, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 636, + "end_line": 660, + "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": 21, + "complexity": 10, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 662, + "end_line": 685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "find_lib_directories", + "long_name": "find_lib_directories( self )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 687, + "end_line": 697, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 3, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 699, + "end_line": 702, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 704, + "end_line": 705, + "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 )", + "filename": "build_flib.py", + "nloc": 22, + "complexity": 5, + "token_count": 140, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 714, + "end_line": 742, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "get_opt", + "long_name": "get_opt( self )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 7, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 744, + "end_line": 758, + "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": 761, + "end_line": 762, + "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 )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 770, + "end_line": 773, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 781, + "end_line": 800, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 802, + "end_line": 804, + "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": 806, + "end_line": 807, + "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 )", + "filename": "build_flib.py", + "nloc": 20, + "complexity": 5, + "token_count": 128, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 815, + "end_line": 839, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 843, + "end_line": 844, + "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 )", + "filename": "build_flib.py", + "nloc": 14, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 851, + "end_line": 873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 875, + "end_line": 877, + "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": 879, + "end_line": 881, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "match_extension", + "long_name": "match_extension( files , ext )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "files", + "ext" + ], + "start_line": 884, + "end_line": 886, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_f77_files", + "long_name": "get_f77_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 888, + "end_line": 889, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_f90_files", + "long_name": "get_f90_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 891, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_fortran_files", + "long_name": "get_fortran_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 894, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "find_fortran_compiler", + "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 5, + "token_count": 59, + "parameters": [ + "vendor", + "fc", + "f90c" + ], + "start_line": 897, + "end_line": 907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "run_command", + "long_name": "run_command( command )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "command" + ], + "start_line": 59, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "show_compilers", + "long_name": "show_compilers( )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 3, + "token_count": 23, + "parameters": [], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_flib.py", + "nloc": 17, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 138, + "end_line": 140, + "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": 142, + "end_line": 145, + "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": 149, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 155, + "end_line": 175, + "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": 177, + "end_line": 182, + "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": 184, + "end_line": 189, + "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": 193, + "end_line": 210, + "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": 214, + "end_line": 223, + "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": 227, + "end_line": 238, + "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": 25, + "complexity": 10, + "token_count": 181, + "parameters": [ + "self", + "fortran_libraries" + ], + "start_line": 240, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "verbose", + "dry_run", + "force" + ], + "start_line": 287, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "to_object", + "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 16, + "complexity": 3, + "token_count": 89, + "parameters": [ + "self", + "dirty_files", + "module_dirs", + "temp_dir" + ], + "start_line": 312, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 329, + "end_line": 334, + "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": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f_compile", + "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 4, + "token_count": 132, + "parameters": [ + "self", + "compiler", + "switches", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 341, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 365, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f77_compile", + "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 370, + "end_line": 373, + "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 )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 376, + "end_line": 377, + "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 )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 2, + "token_count": 68, + "parameters": [ + "self", + "object_files", + "library_name", + "output_dir", + "debug" + ], + "start_line": 379, + "end_line": 390, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "build_library", + "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self", + "library_name", + "source_list", + "module_dirs", + "temp_dir" + ], + "start_line": 392, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dummy_fortran_files", + "long_name": "dummy_fortran_files( self )", + "filename": "build_flib.py", + "nloc": 8, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 422, + "end_line": 429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 431, + "end_line": 432, + "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": 10, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 452, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 454, + "end_line": 455, + "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": 456, + "end_line": 457, + "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": 458, + "end_line": 459, + "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": 460, + "end_line": 461, + "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": 462, + "end_line": 467, + "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": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 469, + "end_line": 470, + "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 )", + "filename": "build_flib.py", + "nloc": 31, + "complexity": 5, + "token_count": 177, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 478, + "end_line": 516, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 518, + "end_line": 523, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "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": 525, + "end_line": 526, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 539, + "end_line": 561, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 563, + "end_line": 568, + "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": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 570, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 585, + "end_line": 586, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_extra_link_args", + "long_name": "get_extra_link_args( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 587, + "end_line": 588, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 596, + "end_line": 614, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 616, + "end_line": 618, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "find_lib_dir", + "long_name": "find_lib_dir( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 619, + "end_line": 621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 622, + "end_line": 623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_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": 624, + "end_line": 625, + "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 )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 633, + "end_line": 657, + "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": 21, + "complexity": 10, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 659, + "end_line": 682, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "find_lib_directories", + "long_name": "find_lib_directories( self )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 684, + "end_line": 694, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 2, + "token_count": 20, + "parameters": [ + "self" + ], + "start_line": 696, + "end_line": 699, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 701, + "end_line": 702, + "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 )", + "filename": "build_flib.py", + "nloc": 22, + "complexity": 5, + "token_count": 140, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 711, + "end_line": 739, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "get_opt", + "long_name": "get_opt( self )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 7, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 741, + "end_line": 755, + "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": 758, + "end_line": 759, + "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 )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 767, + "end_line": 770, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 778, + "end_line": 797, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 799, + "end_line": 801, + "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": 803, + "end_line": 804, + "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 )", + "filename": "build_flib.py", + "nloc": 20, + "complexity": 5, + "token_count": 128, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 812, + "end_line": 836, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 840, + "end_line": 841, + "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 )", + "filename": "build_flib.py", + "nloc": 14, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 848, + "end_line": 870, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 872, + "end_line": 874, + "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": 876, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "match_extension", + "long_name": "match_extension( files , ext )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "files", + "ext" + ], + "start_line": 881, + "end_line": 883, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_f77_files", + "long_name": "get_f77_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 885, + "end_line": 886, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_f90_files", + "long_name": "get_f90_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 888, + "end_line": 889, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_fortran_files", + "long_name": "get_fortran_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 891, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "find_fortran_compiler", + "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 5, + "token_count": 59, + "parameters": [ + "vendor", + "fc", + "f90c" + ], + "start_line": 894, + "end_line": 904, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 3, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 699, + "end_line": 702, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "create_static_lib", + "long_name": "create_static_lib( self , object_files , library_name , output_dir = '' , debug = None )", + "filename": "build_flib.py", + "nloc": 12, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "object_files", + "library_name", + "output_dir", + "debug" + ], + "start_line": 379, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + } + ], + "nloc": 660, + "complexity": 171, + "token_count": 3862, + "diff_parsed": { + "added": [ + " cmd = 'ranlib %s ' % lib_file", + " print cmd", + " os.system(cmd)", + " if sys.platform != 'win32' and os.uname()[0] != 'Darwin':" + ], + "deleted": [ + " if sys.platform != 'win32':" + ] + } + } + ] + }, + { + "hash": "136097468c3b5317bed520eb2a74fd9eaea920c1", + "msg": "Fixed the order of atlas libs for debian woody", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2002-03-24T13:30:03+00:00", + "author_timezone": 0, + "committer_date": "2002-03-24T13:30:03+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "c68907a03908af098bcd498a2bc932aed3bc5452" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 3, + "insertions": 4, + "lines": 7, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": "scipy_distutils/system_info.py", + "new_path": "scipy_distutils/system_info.py", + "filename": "system_info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -315,16 +315,17 @@ def calc_info(self, prefix):\n \n def calc_info_debian(self,prefix):\n print 'Trying Debian setup'\n- info = self.check_libs(os.path.join(prefix,'lib'),\n+ atlas = self.check_libs(os.path.join(prefix,'lib'),\n ['cblas','f77blas','atlas'],[])\n- if not info: return\n+ if not atlas: return\n lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])\n if not lapack:\n lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])\n if not lapack: return\n+ info = lapack\n h = (combine_paths(prefix,'include','cblas.h') or [None])[0]\n if h: dict_append(info,include_dirs=[os.path.dirname(h)])\n- dict_append(info,**lapack)\n+ dict_append(info,**atlas)\n self.set_info(**info)\n \n class blas_info(system_info):\n", + "added_lines": 4, + "deleted_lines": 3, + "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n fftw_info\n x11_info\nThe following environment variables are used if defined:\n ATLAS - path to ATLAS library\n FFTW - path to FFTW library\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (or system_info could not find it).\n\nGlobal parameters:\n prefixes - a list of prefixes for scanning the location of\n resources.\n system_info.static_first - a flag for indicating that static\n libraries are searched first than shared ones.\n system_info.verbose - show the results if set.\n\nAuthor:\n Pearu Peterson , February 2002\nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types,pprint\nfrom distutils.errors import DistutilsError\nfrom glob import glob\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n prefixes = ['C:\\\\'] # XXX: what is prefix in win32?\nelse:\n prefixes = ['/usr','/usr/local','/opt']\nif sys.prefix not in prefixes:\n prefixes.append(sys.prefix)\nprefixes = filter(os.path.isdir,prefixes) # XXX: Is this ok on win32? Is 'C:' dir?\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info}.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Either install them in /usr/local/lib/atlas or /usr/lib/atlas\n and retry setup.py. One can use also ATLAS environment variable\n to indicate the location of Atlas libraries.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Either install them in /usr/local/lib or /usr/lib and retry setup.py.\n One can use also FFTW environment variable to indicate\n the location of FFTW libraries.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://pfdubois.com/numpy/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n\n static_first = 1\n verbose = 1\n need_refresh = 1\n saved_results = {}\n \n def __init__ (self):\n self.__class__.info = {}\n #self.__class__.need_refresh = not self.info\n self.local_prefixes = []\n\n def set_info(self,**info):\n #self.__class__.info = info\n self.saved_results[self.__class__.__name__] = info\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n for n in ['calc_info','calc_info_debian']:\n calc_info = getattr(self,n,None)\n if calc_info is None: continue\n for p in self.local_prefixes + prefixes:\n if self.verbose:\n print ' Looking in',p,'...'\n calc_info(p)\n if self.has_info(): break\n if self.has_info(): break\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n print ' %s = %s'%(k,v)\n print\n return res\n\n def calc_info_template(self,prefix):\n \"\"\" Calculate info distionary. \"\"\"\n \n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n mths = [self.check_static_libs,self.check_shared_libs]\n if not self.static_first:\n mths.reverse() # if one prefers shared libraries\n for m in mths:\n info = m(lib_dir,libs,opt_libs)\n if info is not None: return info\n\n def check_static_libs(self,lib_dir,libs,opt_libs =[]):\n #XXX: what are .lib and .dll files under win32?\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs])) == len(libs):\n info = {'libraries':libs,'library_dirs':[lib_dir]}\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs]))\\\n ==len(opt_libs):\n info['libraries'].extend(opt_libs)\n return info\n\n def check_shared_libs(self,lib_dir,libs,opt_libs =[]):\n shared_libs = []\n for l in libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: shared_libs.append(p)\n if len(shared_libs) == len(libs):\n info = {'extra_objects':shared_libs}\n opt_shared_libs = []\n for l in opt_libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: opt_shared_libs.append(p)\n info['extra_objects'].extend(opt_shared_libs)\n return info\n\n\nclass fftw_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('FFTW')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self,prefix): \n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,'lib',['fftw*','FFTW*']))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'lib'))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','fftw*','FFTW*']))\n \n if not lib_dirs:\n lib_dirs = [prefix]\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,'include',['fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'include'))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['include','fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = [prefix]\n incl_dir = None\n\n libs = ['fftw','rfftw']\n opt_libs = ['fftw_threads','rfftw_threads']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['fftw.h','rfftw.h']))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_FFTW_H',1)])\n else:\n info = None\n\n if info is None:\n libs = ['dfftw','drfftw']\n opt_libs = ['dfftw_threads','drfftw_threads']\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['dfftw.h','drfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n incl_dirs = [d]\n incl_dir = d\n flag = 1\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)])\n else:\n info = None\n \n libs = ['sfftw','srfftw']\n opt_libs = ['sfftw_threads','srfftw_threads']\n flag = 0\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n if info is None: info = r\n else: dict_append(info,**r)\n flag = 1\n break\n if info is not None and flag:\n for d in incl_dirs:\n if len(combine_paths(d,['sfftw.h','srfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n dict_append(info,define_macros=[('SCIPY_SFFTW_H',1)])\n break\n if info is not None:\n self.set_info(**info)\n\n\nclass atlas_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('ATLAS')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self, prefix):\n print combine_paths(prefix,'lib',['atlas*','ATLAS*'])\n lib_dirs = filter(os.path.isdir,combine_paths(prefix,'lib',\n ['atlas*','ATLAS*']))\n if lib_dirs:\n other_dirs = filter(os.path.isdir,combine_paths(lib_dirs,'*'))\n other_dirs.extend(filter(os.path.isdir,combine_paths(prefix,'lib')))\n lib_dirs.extend(other_dirs)\n else:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','atlas*','ATLAS*']))\n if not lib_dirs:\n lib_dirs = [prefix]\n\n h = (combine_paths(lib_dirs,'cblas.h') or [None])[0]\n if not h:\n h = (combine_paths(lib_dirs,'include','cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n\n libs = ['lapack','f77blas','cblas','atlas']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,[])\n if r is not None:\n info = r\n break\n if info is None: return\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n\n def calc_info_debian(self,prefix):\n print 'Trying Debian setup'\n atlas = self.check_libs(os.path.join(prefix,'lib'),\n ['cblas','f77blas','atlas'],[])\n if not atlas: return\n lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])\n if not lapack:\n lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])\n if not lapack: return\n info = lapack\n h = (combine_paths(prefix,'include','cblas.h') or [None])[0]\n if h: dict_append(info,include_dirs=[os.path.dirname(h)])\n dict_append(info,**atlas)\n self.set_info(**info)\n \nclass blas_info(system_info):\n # For Fortran or optimized blas, not atlas.\n pass\n\n\nclass lapack_info(system_info):\n # For Fortran or optimized lapack, not atlas\n pass\n\n\nclass x11_info(system_info):\n\n def calc_info(self, prefix):\n if sys.platform == 'win32':\n return\n for x11_dir in combine_paths(prefix,['X11R6','X11']):\n inc_dir = None\n for d in combine_paths(x11_dir,['include','include/X11']):\n if combine_paths(d,'X.h'):\n inc_dir = d\n break\n if not d: return\n lib_dir = combine_paths(x11_dir,'lib')\n if not lib_dir: return\n info = self.check_libs(lib_dir[0],['X11'],[])\n if info is None:\n continue\n dict_append(info,include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef shortest_path(pths):\n pths.sort()\n if pths: return pths[0]\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n fftw_info\n x11_info\nThe following environment variables are used if defined:\n ATLAS - path to ATLAS library\n FFTW - path to FFTW library\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (or system_info could not find it).\n\nGlobal parameters:\n prefixes - a list of prefixes for scanning the location of\n resources.\n system_info.static_first - a flag for indicating that static\n libraries are searched first than shared ones.\n system_info.verbose - show the results if set.\n\nAuthor:\n Pearu Peterson , February 2002\nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types,pprint\nfrom distutils.errors import DistutilsError\nfrom glob import glob\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n prefixes = ['C:\\\\'] # XXX: what is prefix in win32?\nelse:\n prefixes = ['/usr','/usr/local','/opt']\nif sys.prefix not in prefixes:\n prefixes.append(sys.prefix)\nprefixes = filter(os.path.isdir,prefixes) # XXX: Is this ok on win32? Is 'C:' dir?\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info}.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Either install them in /usr/local/lib/atlas or /usr/lib/atlas\n and retry setup.py. One can use also ATLAS environment variable\n to indicate the location of Atlas libraries.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Either install them in /usr/local/lib or /usr/lib and retry setup.py.\n One can use also FFTW environment variable to indicate\n the location of FFTW libraries.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://pfdubois.com/numpy/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n\n static_first = 1\n verbose = 1\n need_refresh = 1\n saved_results = {}\n \n def __init__ (self):\n self.__class__.info = {}\n #self.__class__.need_refresh = not self.info\n self.local_prefixes = []\n\n def set_info(self,**info):\n #self.__class__.info = info\n self.saved_results[self.__class__.__name__] = info\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n for n in ['calc_info','calc_info_debian']:\n calc_info = getattr(self,n,None)\n if calc_info is None: continue\n for p in self.local_prefixes + prefixes:\n if self.verbose:\n print ' Looking in',p,'...'\n calc_info(p)\n if self.has_info(): break\n if self.has_info(): break\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n print ' %s = %s'%(k,v)\n print\n return res\n\n def calc_info_template(self,prefix):\n \"\"\" Calculate info distionary. \"\"\"\n \n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n mths = [self.check_static_libs,self.check_shared_libs]\n if not self.static_first:\n mths.reverse() # if one prefers shared libraries\n for m in mths:\n info = m(lib_dir,libs,opt_libs)\n if info is not None: return info\n\n def check_static_libs(self,lib_dir,libs,opt_libs =[]):\n #XXX: what are .lib and .dll files under win32?\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs])) == len(libs):\n info = {'libraries':libs,'library_dirs':[lib_dir]}\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs]))\\\n ==len(opt_libs):\n info['libraries'].extend(opt_libs)\n return info\n\n def check_shared_libs(self,lib_dir,libs,opt_libs =[]):\n shared_libs = []\n for l in libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: shared_libs.append(p)\n if len(shared_libs) == len(libs):\n info = {'extra_objects':shared_libs}\n opt_shared_libs = []\n for l in opt_libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: opt_shared_libs.append(p)\n info['extra_objects'].extend(opt_shared_libs)\n return info\n\n\nclass fftw_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('FFTW')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self,prefix): \n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,'lib',['fftw*','FFTW*']))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'lib'))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','fftw*','FFTW*']))\n \n if not lib_dirs:\n lib_dirs = [prefix]\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,'include',['fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'include'))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['include','fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = [prefix]\n incl_dir = None\n\n libs = ['fftw','rfftw']\n opt_libs = ['fftw_threads','rfftw_threads']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['fftw.h','rfftw.h']))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_FFTW_H',1)])\n else:\n info = None\n\n if info is None:\n libs = ['dfftw','drfftw']\n opt_libs = ['dfftw_threads','drfftw_threads']\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['dfftw.h','drfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n incl_dirs = [d]\n incl_dir = d\n flag = 1\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)])\n else:\n info = None\n \n libs = ['sfftw','srfftw']\n opt_libs = ['sfftw_threads','srfftw_threads']\n flag = 0\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n if info is None: info = r\n else: dict_append(info,**r)\n flag = 1\n break\n if info is not None and flag:\n for d in incl_dirs:\n if len(combine_paths(d,['sfftw.h','srfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n dict_append(info,define_macros=[('SCIPY_SFFTW_H',1)])\n break\n if info is not None:\n self.set_info(**info)\n\n\nclass atlas_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('ATLAS')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self, prefix):\n print combine_paths(prefix,'lib',['atlas*','ATLAS*'])\n lib_dirs = filter(os.path.isdir,combine_paths(prefix,'lib',\n ['atlas*','ATLAS*']))\n if lib_dirs:\n other_dirs = filter(os.path.isdir,combine_paths(lib_dirs,'*'))\n other_dirs.extend(filter(os.path.isdir,combine_paths(prefix,'lib')))\n lib_dirs.extend(other_dirs)\n else:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','atlas*','ATLAS*']))\n if not lib_dirs:\n lib_dirs = [prefix]\n\n h = (combine_paths(lib_dirs,'cblas.h') or [None])[0]\n if not h:\n h = (combine_paths(lib_dirs,'include','cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n\n libs = ['lapack','f77blas','cblas','atlas']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,[])\n if r is not None:\n info = r\n break\n if info is None: return\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n\n def calc_info_debian(self,prefix):\n print 'Trying Debian setup'\n info = self.check_libs(os.path.join(prefix,'lib'),\n ['cblas','f77blas','atlas'],[])\n if not info: return\n lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])\n if not lapack:\n lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])\n if not lapack: return\n h = (combine_paths(prefix,'include','cblas.h') or [None])[0]\n if h: dict_append(info,include_dirs=[os.path.dirname(h)])\n dict_append(info,**lapack)\n self.set_info(**info)\n \nclass blas_info(system_info):\n # For Fortran or optimized blas, not atlas.\n pass\n\n\nclass lapack_info(system_info):\n # For Fortran or optimized lapack, not atlas\n pass\n\n\nclass x11_info(system_info):\n\n def calc_info(self, prefix):\n if sys.platform == 'win32':\n return\n for x11_dir in combine_paths(prefix,['X11R6','X11']):\n inc_dir = None\n for d in combine_paths(x11_dir,['include','include/X11']):\n if combine_paths(d,'X.h'):\n inc_dir = d\n break\n if not d: return\n lib_dir = combine_paths(x11_dir,'lib')\n if not lib_dir: return\n info = self.check_libs(lib_dir[0],['X11'],[])\n if info is None:\n continue\n dict_append(info,include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef shortest_path(pths):\n pths.sort()\n if pths: return pths[0]\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", + "methods": [ + { + "name": "get_info", + "long_name": "get_info( name )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "name" + ], + "start_line": 52, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "info" + ], + "start_line": 103, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "has_info", + "long_name": "has_info( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 14, + "token_count": 165, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "calc_info_template", + "long_name": "calc_info_template( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 4, + "token_count": 60, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 142, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_static_libs", + "long_name": "check_static_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 5, + "token_count": 91, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 152, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_shared_libs", + "long_name": "check_shared_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 119, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 161, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 178, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 84, + "complexity": 30, + "token_count": 561, + "parameters": [ + "self", + "prefix" + ], + "start_line": 186, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 278, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 11, + "token_count": 244, + "parameters": [ + "self", + "prefix" + ], + "start_line": 286, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "calc_info_debian", + "long_name": "calc_info_debian( self , prefix )", + "filename": "system_info.py", + "nloc": 14, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "prefix" + ], + "start_line": 316, + "end_line": 329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 17, + "complexity": 8, + "token_count": 117, + "parameters": [ + "self", + "prefix" + ], + "start_line": 343, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "shortest_path", + "long_name": "shortest_path( pths )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "pths" + ], + "start_line": 361, + "end_line": 363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args )", + "filename": "system_info.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "args" + ], + "start_line": 365, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 388, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "show_all", + "long_name": "show_all( )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 3, + "token_count": 59, + "parameters": [], + "start_line": 395, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "get_info", + "long_name": "get_info( name )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "name" + ], + "start_line": 52, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "info" + ], + "start_line": 103, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "has_info", + "long_name": "has_info( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 14, + "token_count": 165, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "calc_info_template", + "long_name": "calc_info_template( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 4, + "token_count": 60, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 142, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_static_libs", + "long_name": "check_static_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 5, + "token_count": 91, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 152, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_shared_libs", + "long_name": "check_shared_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 119, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 161, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 178, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 84, + "complexity": 30, + "token_count": 561, + "parameters": [ + "self", + "prefix" + ], + "start_line": 186, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 278, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 11, + "token_count": 244, + "parameters": [ + "self", + "prefix" + ], + "start_line": 286, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "calc_info_debian", + "long_name": "calc_info_debian( self , prefix )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 154, + "parameters": [ + "self", + "prefix" + ], + "start_line": 316, + "end_line": 328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 17, + "complexity": 8, + "token_count": 117, + "parameters": [ + "self", + "prefix" + ], + "start_line": 342, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "shortest_path", + "long_name": "shortest_path( pths )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "pths" + ], + "start_line": 360, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args )", + "filename": "system_info.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "args" + ], + "start_line": 364, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 387, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "show_all", + "long_name": "show_all( )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 3, + "token_count": 59, + "parameters": [], + "start_line": 394, + "end_line": 401, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "calc_info_debian", + "long_name": "calc_info_debian( self , prefix )", + "filename": "system_info.py", + "nloc": 14, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "prefix" + ], + "start_line": 316, + "end_line": 329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + } + ], + "nloc": 344, + "complexity": 112, + "token_count": 2222, + "diff_parsed": { + "added": [ + " atlas = self.check_libs(os.path.join(prefix,'lib'),", + " if not atlas: return", + " info = lapack", + " dict_append(info,**atlas)" + ], + "deleted": [ + " info = self.check_libs(os.path.join(prefix,'lib'),", + " if not info: return", + " dict_append(info,**lapack)" + ] + } + } + ] + }, + { + "hash": "b539116e300999ded6f418730cce709d9cf1f028", + "msg": "Applied fixes for sun compiler from Berthold H\ufffdllmann.", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2002-03-26T13:08:06+00:00", + "author_timezone": 0, + "committer_date": "2002-03-26T13:08:06+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "136097468c3b5317bed520eb2a74fd9eaea920c1" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 7, + "insertions": 12, + "lines": 19, + "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": "@@ -537,8 +537,9 @@ def get_extra_link_args(self):\n class sun_fortran_compiler(fortran_compiler_base):\n \n vendor = 'Sun'\n- ver_match = r'f77: (?P[^\\s*,]*)'\n-\n+ #ver_match = r'f77: (?P[^\\s*,]*)'\n+ ver_match = r'f90: Sun (?P[^\\s*,]*)'\n+ \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n@@ -554,15 +555,17 @@ def __init__(self, fc = None, f90c = None):\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n \n- self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n+ self.ver_cmd = self.f90_compiler + ' -V'\n+\n+ #self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n+ self.libraries = ['fsu', 'F77', 'M77', 'sunmath', 'm']\n+ \n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n \n- self.ver_cmd = self.f77_compiler + ' -V'\n-\n def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n@@ -610,11 +613,13 @@ def __init__(self, fc = None, f90c = None):\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n+\n+ self.ver_cmd = self.f77_compiler + ' -version'\n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n \n- self.ver_cmd = self.f77_compiler + ' -version'\n+\n \n def build_module_switch(self,module_dirs):\n res = ''\n@@ -655,8 +660,8 @@ def __init__(self, fc = None, f90c = None):\n switches = switches + ' -fpic '\n \n self.f77_switches = switches\n-\n self.ver_cmd = self.f77_compiler + ' -v '\n+\n self.f77_opt = self.get_opt()\n \n def get_opt(self):\n", + "added_lines": 12, + "deleted_lines": 7, + "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\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\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 *\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\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 \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\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 fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\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 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, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\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.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 files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\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 cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError, 'failure during compile' \n object_files.append(object)\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 f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n cmd = 'ranlib %s ' % lib_file\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_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 # 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 self.create_static_lib(obj,library_name,temp_dir)\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.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: Is 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 #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\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 return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(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):\n fortran_compiler_base.__init__(self)\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 = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\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 self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\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 def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\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\n vendor = 'Sun'\n #ver_match = r'f77: (?P[^\\s*,]*)'\n ver_match = r'f90: Sun (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.ver_cmd = self.f90_compiler + ' -V'\n\n #self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n self.libraries = ['fsu', 'F77', 'M77', 'sunmath', 'm']\n \n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n def build_module_switch(self,module_dirs):\n res = ''\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 = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\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 def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n\n self.ver_cmd = self.f77_compiler + ' -version'\n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = ['g2c']\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 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 + ' -v '\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\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if 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 ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32' and os.uname()[0] != 'Darwin':\n return [self.f77_compiler,'-shared']\n \n def f90_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/f50/linux/\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, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\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 '\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\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\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 for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\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):\n fortran_compiler_base.__init__(self)\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.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\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\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 # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\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)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_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 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\nOpen issues:\n *** User-defined compiler flags. Do we need --fflags?\n\nFortran compilers (as to be used with --fcompiler= option):\n Absoft\n Sun\n SGI\n Intel\n Itanium\n NAG\n Compaq\n Gnu\n VAST\n\"\"\"\n\nimport distutils\nimport distutils.dep_util, distutils.dir_util\nimport os,sys,string\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 *\n\nclass FortranCompilerError (CCompilerError):\n \"\"\"Some compile/link operation failed.\"\"\"\nclass FortranCompileError (FortranCompilerError):\n \"\"\"Failure to compile one or more Fortran source files.\"\"\"\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 \ndef show_compilers():\n for compiler_class in all_compilers:\n compiler = compiler_class()\n if compiler.is_available():\n print compiler\n\nclass build_flib (build_clib):\n\n description = \"build f77/f90 libraries used by Python extensions\"\n\n user_options = [\n ('build-flib', 'b',\n \"directory to build f77/f90 libraries to\"),\n ('build-temp', 't',\n \"directory to put temporary build by-products\"),\n ('debug', 'g',\n \"compile with debugging information\"),\n ('force', 'f',\n \"forcibly build everything (ignore file timestamps)\"),\n ('fcompiler=', 'c',\n \"specify the compiler type\"),\n ('fcompiler-exec=', 'e',\n \"specify the path to F77 compiler\"),\n ('f90compiler-exec=', 'x',\n \"specify the path to F90 compiler\"),\n ]\n\n boolean_options = ['debug', 'force']\n\n help_options = [\n ('help-compiler', None,\n \"list available compilers\", show_compilers),\n ]\n\n def initialize_options (self):\n\n self.build_flib = None\n self.build_temp = None\n\n self.fortran_libraries = None\n self.define = None\n self.undef = None\n self.debug = None\n self.force = 0\n self.fcompiler = None\n self.fcompiler_exec = None\n self.f90compiler_exec = None\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 fc = find_fortran_compiler(self.fcompiler,\n self.fcompiler_exec,\n self.f90compiler_exec)\n if not fc:\n raise DistutilsOptionError, 'Fortran compiler not available: %s'%(self.fcompiler)\n else:\n self.announce(' using %s Fortran compiler' % fc)\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 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, temp_dir=self.build_temp)\n\n # for loop\n\n # build_libraries ()\n\n\nclass fortran_compiler_base(CCompiler):\n\n vendor = None\n ver_match = None\n\n compiler_type = 'fortran'\n executables = {}\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.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 files = string.join(dirty_files)\n f90_files = get_f90_files(dirty_files)\n f77_files = get_f77_files(dirty_files)\n if f90_files != []:\n obj1 = self.f90_compile(f90_files,module_dirs,temp_dir = temp_dir)\n else:\n obj1 = []\n if f77_files != []:\n obj2 = self.f77_compile(f77_files, temp_dir = temp_dir)\n else:\n obj2 = []\n return obj1 + obj2\n\n def source_to_object_names(self,source_files, temp_dir=''):\n file_list = map(lambda x: os.path.basename(x),source_files)\n file_base_ext = map(lambda x: os.path.splitext(x),file_list)\n object_list = map(lambda x: x[0] +'.o',file_base_ext)\n object_files = map(lambda x,td=temp_dir: os.path.join(td,x),object_list)\n return object_files\n \n def source_and_object_pairs(self,source_files, temp_dir=''):\n object_files = self.source_to_object_names(source_files,temp_dir)\n file_pairs = zip(source_files,object_files)\n return file_pairs\n \n def f_compile(self,compiler,switches, source_files,\n module_dirs=None, temp_dir=''):\n\n pp_opts = gen_preprocess_options(self.macros,self.include_dirs)\n\n switches = switches + ' ' + string.join(pp_opts,' ')\n\n module_switch = self.build_module_switch(module_dirs)\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 cmd = compiler + ' ' + switches + ' '+\\\n module_switch + \\\n ' -c ' + source + ' -o ' + object \n print cmd\n failure = os.system(cmd)\n if failure:\n raise FortranCompileError, 'failure during compile' \n object_files.append(object)\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 f77_compile(self,source_files,module_dirs=None, temp_dir=''):\n switches = string.join((self.f77_switches, self.f77_opt))\n return self.f_compile(self.f77_compiler,switches,\n source_files, module_dirs,temp_dir)\n\n\n def build_module_switch(self, module_dirs):\n return ''\n\n def create_static_lib(self, object_files, library_name,\n output_dir='', debug=None):\n lib_file = os.path.join(output_dir,'lib'+library_name+'.a')\n newer = distutils.dep_util.newer\n # This doesn't work -- no way to know if the file is in the archive\n #object_files = filter(lambda o,lib=lib_file:\\\n # distutils.dep_util.newer(o,lib),object_files)\n objects = string.join(object_files)\n if objects:\n cmd = 'ar -cur %s %s' % (lib_file,objects)\n print cmd\n os.system(cmd)\n cmd = 'ranlib %s ' % lib_file\n print cmd\n os.system(cmd)\n\n def build_library(self,library_name,source_list,module_dirs=None,\n temp_dir = ''):\n #make sure the temp directory exists before trying to build files\n import distutils.dir_util\n distutils.dir_util.mkpath(temp_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 # 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 self.create_static_lib(obj,library_name,temp_dir)\n else:\n self.create_static_lib(object_list,library_name,temp_dir)\n\n def dummy_fortran_files(self):\n import tempfile \n d = tempfile.gettempdir()\n dummy_name = os.path.join(d,'__dummy.f')\n dummy = open(dummy_name,'w')\n dummy.write(\" subroutine dummy()\\n end\\n\")\n dummy.close()\n return (os.path.join(d,'__dummy.f'),os.path.join(d,'__dummy.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: Is 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 #print 'command:', self.ver_cmd\n exit_status, out_text = run_command(self.ver_cmd)\n #print exit_status, out_text\n if not exit_status:\n m = re.match(self.ver_match,out_text)\n if m:\n self.version = m.group('version')\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 return \"%s %s\" % (self.vendor, self.get_version())\n\n\nclass absoft_fortran_compiler(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):\n fortran_compiler_base.__init__(self)\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 = '-f fixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\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 self.libraries = ['fio', 'fmath', 'f90math', 'COMDLG32']\n else:\n self.f90_switches = '-ffixed -YCFRL=1 -YCOM_NAMES=LCS' \\\n ' -YCOM_PFX -YEXT_PFX -YEXT_NAMES=LCS' \\\n ' -YCOM_SFX=_ -YEXT_SFX=_ -YEXT_NAMES=LCS' \n self.f90_opt = '-O -B101' \n self.f77_switches = '-N22 -N90 -N110 -B108'\n self.f77_opt = '-O -B101'\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 def build_module_switch(self,module_dirs):\n res = ''\n if module_dirs:\n for mod in module_dirs:\n res = res + ' -p' + mod\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\n vendor = 'Sun'\n ver_match = r'f77: (?P[^\\s*,]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -pic '\n self.f77_opt = ' -fast -dalign '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -fixed ' # ??? why fixed?\n self.f90_opt = ' -fast -dalign '\n\n self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']\n #threaded\n #self.libraries = ['f90', 'F77_mt', 'sunmath_mt', 'm', 'thread']\n #self.libraries = []\n self.library_dirs = self.find_lib_dir()\n #print 'sun:',self.library_dirs\n\n self.ver_cmd = self.f77_compiler + ' -V'\n\n def build_module_switch(self,module_dirs):\n res = ''\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 = []\n lib_match = r'### f90: Note: LD_RUN_PATH\\s*= '\\\n '(?P[^\\s.]*).*'\n cmd = self.f90_compiler + ' -dryrun dummy.f'\n exit_status, output = run_command(cmd)\n if not exit_status:\n libs = re.findall(lib_match,output)\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 def get_runtime_library_dirs(self):\n return self.find_lib_dir()\n def get_extra_link_args(self):\n return ['-mimpure-text']\n\n\nclass mips_fortran_compiler(fortran_compiler_base):\n\n vendor = 'SGI'\n ver_match = r'MIPSpro Compilers: Version (?P[^\\s*,]*)'\n \n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if fc is None:\n fc = 'f77'\n if f90c is None:\n f90c = 'f90'\n\n self.f77_compiler = fc # not tested\n self.f77_switches = ' -n32 -KPIC '\n self.f77_opt = ' -O3 '\n\n self.f90_compiler = f90c\n self.f90_switches = ' -n32 -KPIC -fixedform ' # why fixed ???\n self.f90_opt = ' ' \n \n self.libraries = ['fortran', 'ftn', 'm']\n self.library_dirs = self.find_lib_dir()\n\n self.ver_cmd = self.f77_compiler + ' -version'\n\n def build_module_switch(self,module_dirs):\n res = ''\n return res \n def find_lib_dir(self):\n library_dirs = []\n return library_dirs\n def get_runtime_library_dirs(self):\n\treturn self.find_lib_dir() \n def get_extra_link_args(self):\n\treturn []\n\n\nclass gnu_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Gnu'\n ver_match = r'g77 version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n if sys.platform == 'win32':\n self.libraries = ['gcc','g2c']\n self.library_dirs = self.find_lib_directories()\n else:\n # On linux g77 does not need lib_directories to be specified.\n self.libraries = ['g2c']\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 switches = ' -Wall -fno-second-underscore '\n\n if os.name != 'nt':\n switches = switches + ' -fpic '\n\n self.f77_switches = switches\n\n self.ver_cmd = self.f77_compiler + ' -v '\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\n # it.\n if self.get_version():\n if self.version[0]=='3': # is g77 3.x.x\n if cpu.is_AthlonK6():\n opt = opt + ' -march=k6 '\n elif cpu.is_AthlonK7():\n opt = opt + ' -march=athlon '\n if 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 ' \n return opt\n \n def find_lib_directories(self):\n lib_dir = []\n match = r'Reading specs from (.*)/specs'\n\n # works I think only for unix... \n exit_status, out_text = run_command('g77 -v')\n if not exit_status:\n m = re.findall(match,out_text)\n if m:\n lib_dir= m #m[0] \n return lib_dir\n\n def get_linker_so(self):\n # win32 linking should be handled by standard linker\n if sys.platform != 'win32' and os.uname()[0] != 'Darwin':\n return [self.f77_compiler,'-shared']\n \n def f90_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/f50/linux/\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, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 '\n\n self.f77_opt = self.f90_opt = self.get_opt()\n \n debug = ' -g -C '\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 '\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\n def get_linker_so(self):\n return [self.f77_compiler,'-shared']\n\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 for the Itanium\\(TM\\)-based applications, Version (?P[^\\s*]*)'\n\n def __init__(self, fc = None, f90c = None):\n if fc is None:\n fc = 'efc'\n intel_ia32_fortran_compiler.__init__(self, fc, f90c)\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):\n fortran_compiler_base.__init__(self)\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.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\nclass vast_fortran_compiler(fortran_compiler_base):\n\n vendor = 'VAST'\n ver_match = r'\\s*Pacific-Sierra Research vf90 (Personal|Professional)\\s+(?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\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 gnu = gnu_fortran_compiler(fc)\n if not gnu.is_available(): # VAST compiler requires g77.\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 # XXX: need f90 switches, debug, opt\n\n def get_linker_so(self):\n return [self.f90_compiler,'-shared']\n\nclass compaq_fortran_compiler(fortran_compiler_base):\n\n vendor = 'Compaq'\n ver_match = r'Compaq Fortran (?P[^\\s]*)'\n\n def __init__(self, fc = None, f90c = None):\n fortran_compiler_base.__init__(self)\n\n if fc is None:\n fc = 'fort'\n if f90c is None:\n f90c = fc\n\n self.f77_compiler = fc\n self.f90_compiler = f90c\n\n switches = ' -assume no2underscore -nomixed_str_len_arg '\n debug = ' -g -check_bounds '\n\n self.f77_switches = self.f90_switches = switches\n self.f77_debug = self.f90_debug = debug\n self.f77_opt = self.f90_opt = self.get_opt()\n\n # XXX: uncomment if required\n #self.libraries = ' -lUfor -lfor -lFutil -lcpml -lots -lc '\n\n # XXX: fix the version showing flag\n self.ver_cmd = self.f77_compiler+' -V '\n\n def get_opt(self):\n opt = ' -O4 -align dcommons -arch host -assume bigarrays -assume nozsize -math_library fast -tune host '\n return opt\n\n def get_linker_so(self):\n # XXX: is -shared needed?\n return [self.f77_compiler,'-shared']\n\n\ndef match_extension(files,ext):\n match = re.compile(r'.*[.]('+ext+r')\\Z',re.I).match\n return filter(lambda x,match = match: match(x),files)\n\ndef get_f77_files(files):\n return match_extension(files,'for|f77|ftn|f')\n\ndef get_f90_files(files):\n return match_extension(files,'f90|f95')\n\ndef get_fortran_files(files):\n return match_extension(files,'f90|f95|for|f77|ftn|f')\n\ndef find_fortran_compiler(vendor = None, fc = None, f90c = None):\n fcompiler = None\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)\n if compiler.is_available():\n fcompiler = compiler\n break\n return fcompiler\n\nall_compilers = [absoft_fortran_compiler,\n mips_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 gnu_fortran_compiler,\n ]\n\nif __name__ == \"__main__\":\n show_compilers()\n", + "methods": [ + { + "name": "run_command", + "long_name": "run_command( command )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "command" + ], + "start_line": 59, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "show_compilers", + "long_name": "show_compilers( )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 3, + "token_count": 23, + "parameters": [], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_flib.py", + "nloc": 17, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 138, + "end_line": 140, + "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": 142, + "end_line": 145, + "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": 149, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 155, + "end_line": 175, + "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": 177, + "end_line": 182, + "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": 184, + "end_line": 189, + "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": 193, + "end_line": 210, + "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": 214, + "end_line": 223, + "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": 227, + "end_line": 238, + "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": 25, + "complexity": 10, + "token_count": 181, + "parameters": [ + "self", + "fortran_libraries" + ], + "start_line": 240, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "verbose", + "dry_run", + "force" + ], + "start_line": 287, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "to_object", + "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 16, + "complexity": 3, + "token_count": 89, + "parameters": [ + "self", + "dirty_files", + "module_dirs", + "temp_dir" + ], + "start_line": 312, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 329, + "end_line": 334, + "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": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f_compile", + "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 4, + "token_count": 132, + "parameters": [ + "self", + "compiler", + "switches", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 341, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 365, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f77_compile", + "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 370, + "end_line": 373, + "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 )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 376, + "end_line": 377, + "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 )", + "filename": "build_flib.py", + "nloc": 12, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "object_files", + "library_name", + "output_dir", + "debug" + ], + "start_line": 379, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "build_library", + "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self", + "library_name", + "source_list", + "module_dirs", + "temp_dir" + ], + "start_line": 395, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dummy_fortran_files", + "long_name": "dummy_fortran_files( self )", + "filename": "build_flib.py", + "nloc": 8, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 425, + "end_line": 432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 434, + "end_line": 435, + "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": 10, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 437, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 457, + "end_line": 458, + "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": 459, + "end_line": 460, + "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": 461, + "end_line": 462, + "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": 463, + "end_line": 464, + "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": 465, + "end_line": 470, + "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": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 472, + "end_line": 473, + "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 )", + "filename": "build_flib.py", + "nloc": 31, + "complexity": 5, + "token_count": 177, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 481, + "end_line": 519, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 521, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "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": 528, + "end_line": 529, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 543, + "end_line": 566, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 569, + "end_line": 574, + "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": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 576, + "end_line": 590, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 591, + "end_line": 592, + "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": 9, + "parameters": [ + "self" + ], + "start_line": 593, + "end_line": 594, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 602, + "end_line": 620, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 624, + "end_line": 626, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "find_lib_dir", + "long_name": "find_lib_dir( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 627, + "end_line": 629, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "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": 11, + "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": "__init__", + "long_name": "__init__( self , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 641, + "end_line": 665, + "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": 21, + "complexity": 10, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 667, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "find_lib_directories", + "long_name": "find_lib_directories( self )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 692, + "end_line": 702, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 3, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 704, + "end_line": 707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 709, + "end_line": 710, + "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 )", + "filename": "build_flib.py", + "nloc": 22, + "complexity": 5, + "token_count": 140, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 719, + "end_line": 747, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "get_opt", + "long_name": "get_opt( self )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 7, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 749, + "end_line": 763, + "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": 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 )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 775, + "end_line": 778, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 786, + "end_line": 805, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 807, + "end_line": 809, + "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": 811, + "end_line": 812, + "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 )", + "filename": "build_flib.py", + "nloc": 20, + "complexity": 5, + "token_count": 128, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 820, + "end_line": 844, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 848, + "end_line": 849, + "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 )", + "filename": "build_flib.py", + "nloc": 14, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 856, + "end_line": 878, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 880, + "end_line": 882, + "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": 884, + "end_line": 886, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "match_extension", + "long_name": "match_extension( files , ext )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "files", + "ext" + ], + "start_line": 889, + "end_line": 891, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_f77_files", + "long_name": "get_f77_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 893, + "end_line": 894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_f90_files", + "long_name": "get_f90_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 896, + "end_line": 897, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_fortran_files", + "long_name": "get_fortran_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 899, + "end_line": 900, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "find_fortran_compiler", + "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 5, + "token_count": 59, + "parameters": [ + "vendor", + "fc", + "f90c" + ], + "start_line": 902, + "end_line": 912, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "run_command", + "long_name": "run_command( command )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 1, + "token_count": 32, + "parameters": [ + "command" + ], + "start_line": 59, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "show_compilers", + "long_name": "show_compilers( )", + "filename": "build_flib.py", + "nloc": 5, + "complexity": 3, + "token_count": 23, + "parameters": [], + "start_line": 68, + "end_line": 72, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "initialize_options", + "long_name": "initialize_options( self )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 102, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "finalize_options", + "long_name": "finalize_options( self )", + "filename": "build_flib.py", + "nloc": 17, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self" + ], + "start_line": 118, + "end_line": 134, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 138, + "end_line": 140, + "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": 142, + "end_line": 145, + "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": 149, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 155, + "end_line": 175, + "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": 177, + "end_line": 182, + "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": 184, + "end_line": 189, + "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": 193, + "end_line": 210, + "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": 214, + "end_line": 223, + "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": 227, + "end_line": 238, + "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": 25, + "complexity": 10, + "token_count": 181, + "parameters": [ + "self", + "fortran_libraries" + ], + "start_line": 240, + "end_line": 272, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 33, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , verbose = 0 , dry_run = 0 , force = 0 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "verbose", + "dry_run", + "force" + ], + "start_line": 287, + "end_line": 310, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "to_object", + "long_name": "to_object( self , dirty_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 16, + "complexity": 3, + "token_count": 89, + "parameters": [ + "self", + "dirty_files", + "module_dirs", + "temp_dir" + ], + "start_line": 312, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 329, + "end_line": 334, + "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": 336, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f_compile", + "long_name": "f_compile( self , compiler , switches , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 4, + "token_count": 132, + "parameters": [ + "self", + "compiler", + "switches", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 341, + "end_line": 361, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "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": 365, + "end_line": 368, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "f77_compile", + "long_name": "f77_compile( self , source_files , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 1, + "token_count": 48, + "parameters": [ + "self", + "source_files", + "module_dirs", + "temp_dir" + ], + "start_line": 370, + "end_line": 373, + "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 )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 376, + "end_line": 377, + "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 )", + "filename": "build_flib.py", + "nloc": 12, + "complexity": 2, + "token_count": 81, + "parameters": [ + "self", + "object_files", + "library_name", + "output_dir", + "debug" + ], + "start_line": 379, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "build_library", + "long_name": "build_library( self , library_name , source_list , module_dirs = None , temp_dir = '' )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 104, + "parameters": [ + "self", + "library_name", + "source_list", + "module_dirs", + "temp_dir" + ], + "start_line": 395, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "dummy_fortran_files", + "long_name": "dummy_fortran_files( self )", + "filename": "build_flib.py", + "nloc": 8, + "complexity": 1, + "token_count": 69, + "parameters": [ + "self" + ], + "start_line": 425, + "end_line": 432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 434, + "end_line": 435, + "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": 10, + "complexity": 4, + "token_count": 66, + "parameters": [ + "self" + ], + "start_line": 437, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "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": 457, + "end_line": 458, + "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": 459, + "end_line": 460, + "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": 461, + "end_line": 462, + "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": 463, + "end_line": 464, + "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": 465, + "end_line": 470, + "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": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 472, + "end_line": 473, + "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 )", + "filename": "build_flib.py", + "nloc": 31, + "complexity": 5, + "token_count": 177, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 481, + "end_line": 519, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 521, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "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": 528, + "end_line": 529, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 542, + "end_line": 564, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 6, + "complexity": 3, + "token_count": 27, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 566, + "end_line": 571, + "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": 15, + "complexity": 3, + "token_count": 99, + "parameters": [ + "self" + ], + "start_line": 573, + "end_line": 587, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 588, + "end_line": 589, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_extra_link_args", + "long_name": "get_extra_link_args( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 590, + "end_line": 591, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 94, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 599, + "end_line": 617, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 1 + }, + { + "name": "build_module_switch", + "long_name": "build_module_switch( self , module_dirs )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "module_dirs" + ], + "start_line": 619, + "end_line": 621, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "find_lib_dir", + "long_name": "find_lib_dir( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 622, + "end_line": 624, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "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": 11, + "parameters": [ + "self" + ], + "start_line": 625, + "end_line": 626, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_extra_link_args", + "long_name": "get_extra_link_args( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self" + ], + "start_line": 627, + "end_line": 628, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 18, + "complexity": 5, + "token_count": 112, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 636, + "end_line": 660, + "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": 21, + "complexity": 10, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 662, + "end_line": 685, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + }, + { + "name": "find_lib_directories", + "long_name": "find_lib_directories( self )", + "filename": "build_flib.py", + "nloc": 9, + "complexity": 3, + "token_count": 43, + "parameters": [ + "self" + ], + "start_line": 687, + "end_line": 697, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 3, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 699, + "end_line": 702, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 704, + "end_line": 705, + "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 )", + "filename": "build_flib.py", + "nloc": 22, + "complexity": 5, + "token_count": 140, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 714, + "end_line": 742, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "get_opt", + "long_name": "get_opt( self )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 7, + "token_count": 85, + "parameters": [ + "self" + ], + "start_line": 744, + "end_line": 758, + "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": 761, + "end_line": 762, + "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 )", + "filename": "build_flib.py", + "nloc": 4, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 770, + "end_line": 773, + "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 )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 100, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 781, + "end_line": 800, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 802, + "end_line": 804, + "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": 806, + "end_line": 807, + "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 )", + "filename": "build_flib.py", + "nloc": 20, + "complexity": 5, + "token_count": 128, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 815, + "end_line": 839, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 1 + }, + { + "name": "get_linker_so", + "long_name": "get_linker_so( self )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self" + ], + "start_line": 843, + "end_line": 844, + "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 )", + "filename": "build_flib.py", + "nloc": 14, + "complexity": 3, + "token_count": 91, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 851, + "end_line": 873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "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": 875, + "end_line": 877, + "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": 879, + "end_line": 881, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "match_extension", + "long_name": "match_extension( files , ext )", + "filename": "build_flib.py", + "nloc": 3, + "complexity": 1, + "token_count": 44, + "parameters": [ + "files", + "ext" + ], + "start_line": 884, + "end_line": 886, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "get_f77_files", + "long_name": "get_f77_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 888, + "end_line": 889, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_f90_files", + "long_name": "get_f90_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 891, + "end_line": 892, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "get_fortran_files", + "long_name": "get_fortran_files( files )", + "filename": "build_flib.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "files" + ], + "start_line": 894, + "end_line": 895, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "find_fortran_compiler", + "long_name": "find_fortran_compiler( vendor = None , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 11, + "complexity": 5, + "token_count": 59, + "parameters": [ + "vendor", + "fc", + "f90c" + ], + "start_line": 897, + "end_line": 907, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "__init__", + "long_name": "__init__( self , fc = None , f90c = None )", + "filename": "build_flib.py", + "nloc": 15, + "complexity": 3, + "token_count": 98, + "parameters": [ + "self", + "fc", + "f90c" + ], + "start_line": 543, + "end_line": 566, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 1 + } + ], + "nloc": 660, + "complexity": 171, + "token_count": 3862, + "diff_parsed": { + "added": [ + " #ver_match = r'f77: (?P[^\\s*,]*)'", + " ver_match = r'f90: Sun (?P[^\\s*,]*)'", + "", + " self.ver_cmd = self.f90_compiler + ' -V'", + "", + " #self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']", + " self.libraries = ['fsu', 'F77', 'M77', 'sunmath', 'm']", + "", + "", + " self.ver_cmd = self.f77_compiler + ' -version'", + "", + "" + ], + "deleted": [ + " ver_match = r'f77: (?P[^\\s*,]*)'", + "", + " self.libraries = ['f90', 'F77', 'M77', 'sunmath', 'm']", + " self.ver_cmd = self.f77_compiler + ' -V'", + "", + " self.ver_cmd = self.f77_compiler + ' -version'", + "" + ] + } + } + ] + }, + { + "hash": "0562713ee528cae5ac5a4386ce92d7d2c37c3b9e", + "msg": "Refactored to create scipy_base.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-03-30T00:02:58+00:00", + "author_timezone": 0, + "committer_date": "2002-03-30T00:02:58+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "b539116e300999ded6f418730cce709d9cf1f028" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 0, + "insertions": 2138, + "lines": 2138, + "files": 7, + "dmm_unit_size": 0.5451418744625968, + "dmm_unit_complexity": 0.6672398968185727, + "dmm_unit_interfacing": 0.7248495270851246, + "modified_files": [ + { + "old_path": null, + "new_path": "scipy_base/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,14 @@\n+\n+import Numeric\n+from Numeric import *\n+import fastumath\n+from utility import *\n+from convenience import *\n+from polynomial import *\n+from scimath import *\n+from helpmod import help, source\n+from Matrix import Matrix as mat\n+Mat = mat # deprecated\n+\n+\n+\n", + "added_lines": 14, + "deleted_lines": 0, + "source_code": "\nimport Numeric\nfrom Numeric import *\nimport fastumath\nfrom utility import *\nfrom convenience import *\nfrom polynomial import *\nfrom scimath import *\nfrom helpmod import help, source\nfrom Matrix import Matrix as mat\nMat = mat # deprecated\n\n\n\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 10, + "complexity": 0, + "token_count": 39, + "diff_parsed": { + "added": [ + "", + "import Numeric", + "from Numeric import *", + "import fastumath", + "from utility import *", + "from convenience import *", + "from polynomial import *", + "from scimath import *", + "from helpmod import help, source", + "from Matrix import Matrix as mat", + "Mat = mat # deprecated", + "", + "", + "" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy_base/convenience.py", + "filename": "convenience.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,526 @@\n+\"\"\"Contains basic routines of common interest. Always imported first.\n+ Basically MLab minus the LinearAlgebra-dependent functions.\n+\n+ But max is changed to amax (array max)\n+ and min is changed to amin (array min)\n+ so that the builtin max and min are still available.\n+\"\"\"\n+\n+\n+__all__ = ['logspace','linspace','round','any','all','fix','mod','fftshift',\n+ 'ifftshift','fftfreq','cont_ft','toeplitz','hankel','real','imag',\n+ 'iscomplex','isreal','array_iscomplex','array_isreal','isposinf',\n+ 'isneginf','nan_to_num','eye','tri','diag','fliplr','flipud',\n+ 'rot90','tril','triu','amax','amin','ptp','cumsum','prod','cumprod',\n+ 'diff','squeeze','sinc','angle','unwrap','real_if_close',\n+ 'sort_complex']\n+\n+import Numeric\n+\n+def 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 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+\n+def 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 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+\n+#def round(arr):\n+# return Numeric.floor(arr+0.5)\n+round = Numeric.around\n+any = Numeric.sometrue\n+all = Numeric.alltrue\n+\n+def 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+\n+def 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+\n+def fftshift(x,axes=None):\n+ \"\"\"Shift the result of an FFT operation.\n+\n+ Return a shifted version of x (useful for obtaining centered spectra).\n+ This function swaps \"half-spaces\" for all axes listed (defaults to all)\n+ \"\"\"\n+ ndim = len(x.shape)\n+ if axes == None:\n+ axes = range(ndim)\n+ y = x\n+ for k in axes:\n+ N = x.shape[k]\n+ p2 = int(Numeric.ceil(N/2.0))\n+ mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n+ y = Numeric.take(y,mylist,k)\n+ return y\n+\n+def ifftshift(x,axes=None):\n+ \"\"\"Reverse the effect of fftshift.\n+ \"\"\"\n+ ndim = len(x.shape)\n+ if axes == None:\n+ axes = range(ndim)\n+ y = x\n+ for k in axes:\n+ N = x.shape[k]\n+ p2 = int(Numeric.floor(N/2.0))\n+ mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n+ y = Numeric.take(y,mylist,k)\n+ return y\n+\n+def fftfreq(N,sample=1.0):\n+ \"\"\"FFT sample frequencies\n+ \n+ Return the frequency bins in cycles/unit (with zero at the start) given a\n+ window length N and a sample spacing.\n+ \"\"\"\n+ N = int(N)\n+ sample = float(sample)\n+ return Numeric.concatenate((Numeric.arange(0,(N-1)/2+1,1,'d'),Numeric.arange(-(N-1)/2,0,1,'d')))/N/sample\n+\n+def cont_ft(gn,fr,delta=1.0,n=None):\n+ \"\"\"Compute the (scaled) DFT of gn at frequencies fr.\n+\n+ If the gn are alias-free samples of a continuous time function then the\n+ correct value for the spacing, delta, will give the properly scaled,\n+ continuous Fourier spectrum.\n+\n+ The DFT is obtained when delta=1.0\n+ \"\"\"\n+ if n is None:\n+ n = Numeric.arange(len(gn))\n+ dT = delta\n+ trans_kernel = Numeric.exp(-2j*Numeric.pi*fr[:,Numeric.NewAxis]*dT*n)\n+ return dT*Numeric.dot(trans_kernel,gn)\n+\n+def toeplitz(c,r=None):\n+ \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).\n+\n+ Description:\n+\n+ toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first\n+ column and r as its first row.\n+\n+ toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). \n+\n+ See also: hankel\n+ \"\"\"\n+ if isscalar(c) or isscalar(r):\n+ return c \n+ if r is None:\n+ r = c\n+ r[0] = Numeric.conjugate(r[0])\n+ c = Numeric.conjugate(c)\n+ r,c = map(Numeric.asarray,(r,c))\n+ r,c = map(Numeric.ravel,(r,c))\n+ rN,cN = map(len,(r,c))\n+ if r[0] != c[0]:\n+ print \"Warning: column and row values don't agree; column value used.\"\n+ vals = r_[r[rN-1:0:-1], c]\n+ cols = grid[0:cN]\n+ rows = grid[rN:0:-1]\n+ indx = cols[:,Numeric.NewAxis]*Numeric.ones((1,rN)) + \\\n+ rows[Numeric.NewAxis,:]*Numeric.ones((cN,1)) - 1\n+ return Numeric.take(vals, indx)\n+\n+\n+def hankel(c,r=None):\n+ \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).\n+\n+ Description:\n+\n+ hankel(c,r) is a Hankel matrix whose first column is c and whose\n+ last row is r.\n+\n+ hankel(c) is a square Hankel matrix whose first column is C.\n+ Elements below the first anti-diagonal are zero.\n+\n+ See also: toeplitz\n+ \"\"\"\n+ if isscalar(c) or isscalar(r):\n+ return c \n+ if r is None:\n+ r = Numeric.zeros(len(c))\n+ elif r[0] != c[-1]:\n+ print \"Warning: column and row values don't agree; column value used.\"\n+ r,c = map(Numeric.asarray,(r,c))\n+ r,c = map(Numeric.ravel,(r,c))\n+ rN,cN = map(len,(r,c))\n+ vals = r_[c, r[1:rN]]\n+ cols = grid[1:cN+1]\n+ rows = grid[0:rN]\n+ indx = cols[:,Numeric.NewAxis]*Numeric.ones((1,rN)) + \\\n+ rows[Numeric.NewAxis,:]*Numeric.ones((cN,1)) - 1\n+ return Numeric.take(vals, indx)\n+\n+\n+def real(val):\n+ aval = asarray(val)\n+ if aval.typecode() in ['F', 'D']:\n+ return aval.real\n+ else:\n+ return aval\n+\n+def imag(val):\n+ aval = asarray(val)\n+ if aval.typecode() in ['F', 'D']:\n+ return aval.imag\n+ else:\n+ return array(0,aval.typecode())*aval\n+\n+def iscomplex(x):\n+ return imag(x) != Numeric.zeros(asarray(x).shape)\n+\n+def isreal(x):\n+ return imag(x) == Numeric.zeros(asarray(x).shape)\n+\n+def array_iscomplex(x):\n+ return asarray(x).typecode() in ['F', 'D']\n+\n+def array_isreal(x):\n+ return not asarray(x).typecode() in ['F', 'D']\n+\n+def isposinf(val):\n+ # complex not handled currently (and potentially ambiguous)\n+ return Numeric.logical_and(isinf(val),val > 0)\n+\n+def isneginf(val):\n+ # complex not handled currently (and potentially ambiguous)\n+ return Numeric.logical_and(isinf(val),val < 0)\n+ \n+def nan_to_num(x):\n+ # mapping:\n+ # NaN -> 0\n+ # Inf -> scipy.limits.double_max\n+ # -Inf -> scipy.limits.double_min\n+ # complex not handled currently\n+ import scipy.limits\n+ try:\n+ t = x.typecode()\n+ except AttributeError:\n+ t = type(x)\n+ if t in [ComplexType,'F','D']: \n+ y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n+ else: \n+ x = Numeric.asarray(x)\n+ are_inf = isposinf(x)\n+ are_neg_inf = isneginf(x)\n+ are_nan = isnan(x)\n+ choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n+ y = Numeric.choose(choose_array,\n+ (x,scipy.limits.double_min, 0., scipy.limits.double_max))\n+ return y\n+\n+# These are from Numeric\n+from Numeric import *\n+import Numeric\n+import Matrix\n+from utility import isscalar\n+from fastumath import *\n+\n+\n+# Elementary Matrices\n+\n+# zeros is from matrixmodule in C\n+# ones is from Numeric.py\n+\n+\n+def eye(N, M=None, k=0, typecode=None):\n+ \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the \n+ k-th diagonal is all ones, 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+\n+def tri(N, M=None, k=0, typecode=None):\n+ \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all\n+ the diagonals starting from lower left corner up to the k-th are all ones.\n+ \"\"\"\n+ if M is None: M = N\n+ if type(M) == type('d'): \n+ typecode = M\n+ M = N\n+ m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n+ if typecode is None:\n+ return m\n+ else:\n+ return m.astype(typecode)\n+ \n+# Matrix manipulation\n+\n+def diag(v, k=0):\n+ \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or\n+ returns a matrix 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+def fliplr(m):\n+ \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and\n+ columns flipped in the left/right direction. Only works with 2-D\n+ 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+def flipud(m):\n+ \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and\n+ rows flipped in 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+\n+def rot90(m, k=1):\n+ \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees\n+ in the 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+\n+def tril(m, k=0):\n+ \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of\n+ m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n+ diagonal.\n+ \"\"\"\n+ svsp = m.spacesaver()\n+ m = asarray(m,savespace=1)\n+ out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n+ out.savespace(svsp)\n+ return out\n+\n+def triu(m, k=0):\n+ \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of\n+ m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n+ diagonal.\n+ \"\"\"\n+ svsp = m.spacesaver()\n+ m = asarray(m,savespace=1)\n+ out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n+ out.savespace(svsp)\n+ return out\n+\n+# Data analysis\n+\n+# Basic operations\n+def 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+\n+def 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+\n+def 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+\n+def 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+\n+def 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+\n+def 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+\n+def 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+def squeeze(a):\n+ \"Returns a with any ones from the shape of a removed\"\n+ a = asarray(a)\n+ b = asarray(a.shape)\n+ return reshape (a, tuple (compress (not_equal (b, 1), b)))\n+\n+def sinc(x):\n+ \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.\n+ \"\"\"\n+ w = asarray(x*pi)\n+ return where(x==0, 1.0, sin(w)/w)\n+\n+def 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+\n+import copy\n+def unwrap(p,discont=pi,axis=-1):\n+ \"\"\"unwrap(p,discont=pi,axis=-1)\n+\n+ unwraps radian phase p by changing absolute jumps greater than discont to\n+ 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) 0)\n\ndef isneginf(val):\n # complex not handled currently (and potentially ambiguous)\n return Numeric.logical_and(isinf(val),val < 0)\n \ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> scipy.limits.double_max\n # -Inf -> scipy.limits.double_min\n # complex not handled currently\n import scipy.limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = Numeric.asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,scipy.limits.double_min, 0., scipy.limits.double_max))\n return y\n\n# These are from Numeric\nfrom Numeric import *\nimport Numeric\nimport Matrix\nfrom utility import isscalar\nfrom fastumath import *\n\n\n# Elementary Matrices\n\n# zeros is from matrixmodule in C\n# ones is from Numeric.py\n\n\ndef eye(N, M=None, k=0, typecode=None):\n \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the \n k-th diagonal is all ones, 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 tri(N, M=None, k=0, typecode=None):\n \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all\n the diagonals starting from lower left corner up to the k-th are all ones.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n \n# Matrix manipulation\n\ndef diag(v, k=0):\n \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or\n returns a matrix 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 \ndef fliplr(m):\n \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and\n columns flipped in the left/right direction. Only works with 2-D\n 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 \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and\n rows flipped in 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 \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees\n in the 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 tril(m, k=0):\n \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n out.savespace(svsp)\n return out\n\ndef triu(m, k=0):\n \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n out.savespace(svsp)\n return out\n\n# Data analysis\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\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n a = asarray(a)\n b = asarray(a.shape)\n return reshape (a, tuple (compress (not_equal (b, 1), b)))\n\ndef sinc(x):\n \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.\n \"\"\"\n w = asarray(x*pi)\n return where(x==0, 1.0, sin(w)/w)\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\nimport copy\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwrap(p,discont=pi,axis=-1)\n\n unwraps radian phase p by changing absolute jumps greater than discont to\n 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) 0)", + "", + "def isneginf(val):", + " # complex not handled currently (and potentially ambiguous)", + " return Numeric.logical_and(isinf(val),val < 0)", + "", + "def nan_to_num(x):", + " # mapping:", + " # NaN -> 0", + " # Inf -> scipy.limits.double_max", + " # -Inf -> scipy.limits.double_min", + " # complex not handled currently", + " import scipy.limits", + " try:", + " t = x.typecode()", + " except AttributeError:", + " t = type(x)", + " if t in [ComplexType,'F','D']:", + " y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)", + " else:", + " x = Numeric.asarray(x)", + " are_inf = isposinf(x)", + " are_neg_inf = isneginf(x)", + " are_nan = isnan(x)", + " choose_array = are_neg_inf + are_nan * 2 + are_inf * 3", + " y = Numeric.choose(choose_array,", + " (x,scipy.limits.double_min, 0., scipy.limits.double_max))", + " return y", + "", + "# These are from Numeric", + "from Numeric import *", + "import Numeric", + "import Matrix", + "from utility import isscalar", + "from fastumath import *", + "", + "", + "# Elementary Matrices", + "", + "# zeros is from matrixmodule in C", + "# ones is from Numeric.py", + "", + "", + "def eye(N, M=None, k=0, typecode=None):", + " \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the", + " k-th diagonal is all ones, and everything else is zeros.", + " \"\"\"", + " if M is None: M = N", + " if type(M) == type('d'):", + " typecode = M", + " M = N", + " m = equal(subtract.outer(arange(N), arange(M)),-k)", + " if typecode is None:", + " return m", + " else:", + " return m.astype(typecode)", + "", + "def tri(N, M=None, k=0, typecode=None):", + " \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all", + " the diagonals starting from lower left corner up to the k-th are all ones.", + " \"\"\"", + " if M is None: M = N", + " if type(M) == type('d'):", + " typecode = M", + " M = N", + " m = greater_equal(subtract.outer(arange(N), arange(M)),-k)", + " if typecode is None:", + " return m", + " else:", + " return m.astype(typecode)", + "", + "# Matrix manipulation", + "", + "def diag(v, k=0):", + " \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or", + " returns a matrix with v as the k-th diagonal if v is a vector.", + " \"\"\"", + " v = asarray(v)", + " s = v.shape", + " if len(s)==1:", + " n = s[0]+abs(k)", + " if k > 0:", + " v = concatenate((zeros(k, v.typecode()),v))", + " elif k < 0:", + " v = concatenate((v,zeros(-k, v.typecode())))", + " return eye(n, k=k)*v", + " elif len(s)==2:", + " v = add.reduce(eye(s[0], s[1], k=k)*v)", + " if k > 0: return v[k:]", + " elif k < 0: return v[:k]", + " else: return v", + " else:", + " raise ValueError, \"Input must be 1- or 2-D.\"", + "", + "def fliplr(m):", + " \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and", + " columns flipped in the left/right direction. Only works with 2-D", + " arrays.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " return m[:, ::-1]", + "", + "def flipud(m):", + " \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and", + " rows flipped in the up/down direction. Only works with 2-D arrays.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " return m[::-1]", + "", + "# reshape(x, m, n) is not used, instead use reshape(x, (m, n))", + "", + "def rot90(m, k=1):", + " \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees", + " in the counterclockwise direction.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " k = k % 4", + " if k == 0: return m", + " elif k == 1: return transpose(fliplr(m))", + " elif k == 2: return fliplr(flipud(m))", + " else: return fliplr(transpose(m)) # k==3", + "", + "def tril(m, k=0):", + " \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of", + " m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main", + " diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m", + " out.savespace(svsp)", + " return out", + "", + "def triu(m, k=0):", + " \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of", + " m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main", + " diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m", + " out.savespace(svsp)", + " return out", + "", + "# Data analysis", + "", + "# Basic operations", + "def amax(m,axis=-1):", + " \"\"\"Returns the maximum of m along dimension axis.", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return maximum.reduce(m,axis)", + "", + "def amin(m,axis=-1):", + " \"\"\"Returns the minimum of m along dimension axis.", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return minimum.reduce(m,axis)", + "", + "# Actually from Basis, but it fits in so naturally here...", + "", + "def ptp(m,axis=-1):", + " \"\"\"Returns the maximum - minimum along the the given dimension", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return amax(m,axis)-amin(m,axis)", + "", + "def cumsum(m,axis=-1):", + " \"\"\"Returns the cumulative sum of the elements along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return add.accumulate(m,axis)", + "", + "def prod(m,axis=-1):", + " \"\"\"Returns the product of the elements along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return multiply.reduce(m,axis)", + "", + "def cumprod(m,axis=-1):", + " \"\"\"Returns the cumulative product of the elments along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return multiply.accumulate(m,axis)", + "", + "def diff(x, n=1,axis=-1):", + " \"\"\"Calculates the nth order, discrete difference along given axis.", + " \"\"\"", + " x = asarray(x)", + " nd = len(x.shape)", + " slice1 = [slice(None)]*nd", + " slice2 = [slice(None)]*nd", + " slice1[axis] = slice(1,None)", + " slice2[axis] = slice(None,-1)", + " if n > 1:", + " return diff(x[slice1]-x[slice2], n-1, axis=axis)", + " else:", + " return x[slice1]-x[slice2]", + "", + "def squeeze(a):", + " \"Returns a with any ones from the shape of a removed\"", + " a = asarray(a)", + " b = asarray(a.shape)", + " return reshape (a, tuple (compress (not_equal (b, 1), b)))", + "", + "def sinc(x):", + " \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.", + " \"\"\"", + " w = asarray(x*pi)", + " return where(x==0, 1.0, sin(w)/w)", + "", + "def angle(z,deg=0):", + " \"\"\"Return the angle of complex argument z.\"\"\"", + " if deg:", + " fact = 180/pi", + " else:", + " fact = 1.0", + " z = asarray(z)", + " if z.typecode() in ['D','F']:", + " zimag = z.imag", + " zreal = z.real", + " else:", + " zimag = 0", + " zreal = z", + " return arctan2(zimag,zreal) * fact", + "", + "import copy", + "def unwrap(p,discont=pi,axis=-1):", + " \"\"\"unwrap(p,discont=pi,axis=-1)", + "", + " unwraps radian phase p by changing absolute jumps greater than discont to", + " their 2*pi complement along the given axis.", + " \"\"\"", + " p = asarray(p)", + " nd = len(p.shape)", + " dd = diff(p,axis=axis)", + " slice1 = [slice(None,None)]*nd # full slices", + " slice1[axis] = slice(1,None)", + " ddmod = mod(dd+pi,2*pi)-pi", + " putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)", + " ph_correct = ddmod - dd;", + " putmask(ph_correct,abs(dd) width:\n+ k = firstwidth + 1 + len(argument)\n+ newstr = newstr + \",\\n\" + \" \"*(firstwidth+2) + argument\n+ else:\n+ newstr = newstr + addstr + argument\n+ return newstr\n+\n+_namedict = None\n+_dictlist = None\n+\n+# Traverse all module directories underneath globals to see if something is defined\n+def makenamedict():\n+ import scipy\n+ thedict = {'scipy':scipy.__dict__}\n+ dictlist = ['scipy']\n+ totraverse = [scipy.__dict__]\n+ while 1:\n+ if len(totraverse) == 0:\n+ break\n+ thisdict = totraverse.pop(0)\n+ for x in thisdict.keys():\n+ if isinstance(thisdict[x],types.ModuleType):\n+ modname = thisdict[x].__name__\n+ if modname not in dictlist:\n+ moddict = thisdict[x].__dict__\n+ dictlist.append(modname)\n+ totraverse.append(moddict)\n+ thedict[modname] = moddict\n+ return thedict, dictlist\n+\n+\n+def help(object=None,maxwidth=76,output=sys.stdout,):\n+ \"\"\"Get help information for a function, class, or module.\n+ \n+ Example:\n+ >>> from scipy import * \n+ >>> help(polyval)\n+ polyval(p, x)\n+ \n+ Evaluate the polymnomial p at x.\n+ \n+ Description: \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+ global _namedict, _dictlist\n+ if object is None: \n+ help(help)\n+ elif isinstance(object, types.StringType):\n+ if _namedict is None:\n+ _namedict, _dictlist = makenamedict()\n+ numfound = 0\n+ objlist = []\n+ for namestr in _dictlist:\n+ try:\n+ obj = _namedict[namestr][object]\n+ if id(obj) in objlist:\n+ print >> output, \"\\n *** Repeat reference found in %s *** \" % namestr\n+ else:\n+ objlist.append(id(obj))\n+ print >> output, \" *** Found in %s ***\" % namestr\n+ help(obj)\n+ print >> output, \"-\"*maxwidth\n+ numfound += 1\n+ except KeyError:\n+ pass\n+ if numfound == 0:\n+ print >> output, \"Help for %s not found.\" % object\n+ else:\n+ print >> output, \"\\n *** Total of %d references found. ***\" % numfound\n+ \n+ elif inspect.isfunction(object):\n+ name = object.func_name\n+ arguments = apply(inspect.formatargspec, inspect.getargspec(object))\n+\n+ if len(name+arguments) > maxwidth:\n+ argstr = split_line(name, arguments, maxwidth)\n+ else:\n+ argstr = name + arguments\n+\n+ print >> output, \" \" + argstr + \"\\n\"\n+ print >> output, inspect.getdoc(object)\n+\n+ elif inspect.isclass(object): \n+ name = object.__name__\n+ if hasattr(object, '__init__'):\n+ arguments = apply(inspect.formatargspec, inspect.getargspec(object.__init__.im_func)) \n+ arglist = arguments.split(', ')\n+ if len(arglist) > 1:\n+ arglist[1] = \"(\"+arglist[1]\n+ arguments = \", \".join(arglist[1:])\n+ else:\n+ arguments = \"()\"\n+ else:\n+ arguments = \"()\"\n+\n+ if len(name+arguments) > maxwidth:\n+ argstr = split_line(name, arguments, maxwidth)\n+ else:\n+ argstr = name + arguments\n+\n+ print >> output, \" \" + argstr + \"\\n\"\n+ doc1 = inspect.getdoc(object) \n+ if doc1 is None:\n+ if hasattr(object,'__init__'):\n+ print >> output, inspect.getdoc(object.__init__)\n+ else:\n+ print >> output, inspect.getdoc(object)\n+\n+ elif type(object) is types.InstanceType: ## check for __call__ method\n+ print >> output, \"Instance of class: \", object.__class__.__name__\n+ print >> output\n+ if hasattr(object, '__call__'):\n+ arguments = apply(inspect.formatargspec, inspect.getargspec(object.__call__.im_func))\n+ arglist = arguments.split(', ')\n+ if len(arglist) > 1:\n+ arglist[1] = \"(\"+arglist[1]\n+ arguments = \", \".join(arglist[1:])\n+ else:\n+ arguments = \"()\"\n+\n+ name = \"\"\n+ if len(name+arguments) > maxwidth:\n+ argstr = split_line(name, arguments, maxwidth)\n+ else:\n+ argstr = name + arguments\n+\n+ print >> output, \" \" + argstr + \"\\n\"\n+ doc = inspect.getdoc(object.__call__)\n+ if doc is not None:\n+ print >> output, inspect.getdoc(object.__call__)\n+ print >> output, inspect.getdoc(object)\n+ \n+ else:\n+ print >> output, inspect.getdoc(object)\n+ \n+ elif inspect.ismethod(object):\n+ name = object.__name__\n+ arguments = apply(inspect.formatargspec, inspect.getargspec(object.im_func))\n+ arglist = arguments.split(', ')\n+ if len(arglist) > 1:\n+ arglist[1] = \"(\"+arglist[1]\n+ arguments = \", \".join(arglist[1:])\n+ else:\n+ arguments = \"()\"\n+\n+ if len(name+arguments) > maxwidth:\n+ argstr = split_line(name, arguments, maxwidth)\n+ else:\n+ argstr = name + arguments\n+\n+ print >> output, \" \" + argstr + \"\\n\"\n+ print >> output, inspect.getdoc(object)\n+ \n+ elif hasattr(object, '__doc__'):\n+ print >> output, inspect.getdoc(object)\n+ \n+\n+def source(object, output=sys.stdout):\n+ if inspect.isroutine(object):\n+ print >> output, \"In file: %s\\n\" % inspect.getsourcefile(object)\n+ print >> output, inspect.getsource(object)\n+ else:\n+ print >> output, \"Not available for this object.\"\n", + "added_lines": 186, + "deleted_lines": 0, + "source_code": "import inspect\nimport types\nimport sys, os\n\n# NOTE: pydoc defines a help function which works simliarly to this\n# except it uses a pager to take over the screen.\n\n# combine name and arguments and split to multiple lines of\n# width characters. End lines on a comma and begin argument list\n# indented with the rest of the arguments.\ndef split_line(name, arguments, width):\n firstwidth = len(name)\n k = firstwidth\n newstr = name\n sepstr = \", \"\n arglist = arguments.split(sepstr)\n for argument in arglist:\n if k == firstwidth:\n addstr = \"\"\n else:\n addstr = sepstr\n k = k + len(argument) + len(addstr)\n if k > width:\n k = firstwidth + 1 + len(argument)\n newstr = newstr + \",\\n\" + \" \"*(firstwidth+2) + argument\n else:\n newstr = newstr + addstr + argument\n return newstr\n\n_namedict = None\n_dictlist = None\n\n# Traverse all module directories underneath globals to see if something is defined\ndef makenamedict():\n import scipy\n thedict = {'scipy':scipy.__dict__}\n dictlist = ['scipy']\n totraverse = [scipy.__dict__]\n while 1:\n if len(totraverse) == 0:\n break\n thisdict = totraverse.pop(0)\n for x in thisdict.keys():\n if isinstance(thisdict[x],types.ModuleType):\n modname = thisdict[x].__name__\n if modname not in dictlist:\n moddict = thisdict[x].__dict__\n dictlist.append(modname)\n totraverse.append(moddict)\n thedict[modname] = moddict\n return thedict, dictlist\n\n\ndef help(object=None,maxwidth=76,output=sys.stdout,):\n \"\"\"Get help information for a function, class, or module.\n \n Example:\n >>> from scipy import * \n >>> help(polyval)\n polyval(p, x)\n \n Evaluate the polymnomial p at x.\n \n Description: \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 global _namedict, _dictlist\n if object is None: \n help(help)\n elif isinstance(object, types.StringType):\n if _namedict is None:\n _namedict, _dictlist = makenamedict()\n numfound = 0\n objlist = []\n for namestr in _dictlist:\n try:\n obj = _namedict[namestr][object]\n if id(obj) in objlist:\n print >> output, \"\\n *** Repeat reference found in %s *** \" % namestr\n else:\n objlist.append(id(obj))\n print >> output, \" *** Found in %s ***\" % namestr\n help(obj)\n print >> output, \"-\"*maxwidth\n numfound += 1\n except KeyError:\n pass\n if numfound == 0:\n print >> output, \"Help for %s not found.\" % object\n else:\n print >> output, \"\\n *** Total of %d references found. ***\" % numfound\n \n elif inspect.isfunction(object):\n name = object.func_name\n arguments = apply(inspect.formatargspec, inspect.getargspec(object))\n\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n print >> output, inspect.getdoc(object)\n\n elif inspect.isclass(object): \n name = object.__name__\n if hasattr(object, '__init__'):\n arguments = apply(inspect.formatargspec, inspect.getargspec(object.__init__.im_func)) \n arglist = arguments.split(', ')\n if len(arglist) > 1:\n arglist[1] = \"(\"+arglist[1]\n arguments = \", \".join(arglist[1:])\n else:\n arguments = \"()\"\n else:\n arguments = \"()\"\n\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n doc1 = inspect.getdoc(object) \n if doc1 is None:\n if hasattr(object,'__init__'):\n print >> output, inspect.getdoc(object.__init__)\n else:\n print >> output, inspect.getdoc(object)\n\n elif type(object) is types.InstanceType: ## check for __call__ method\n print >> output, \"Instance of class: \", object.__class__.__name__\n print >> output\n if hasattr(object, '__call__'):\n arguments = apply(inspect.formatargspec, inspect.getargspec(object.__call__.im_func))\n arglist = arguments.split(', ')\n if len(arglist) > 1:\n arglist[1] = \"(\"+arglist[1]\n arguments = \", \".join(arglist[1:])\n else:\n arguments = \"()\"\n\n name = \"\"\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n doc = inspect.getdoc(object.__call__)\n if doc is not None:\n print >> output, inspect.getdoc(object.__call__)\n print >> output, inspect.getdoc(object)\n \n else:\n print >> output, inspect.getdoc(object)\n \n elif inspect.ismethod(object):\n name = object.__name__\n arguments = apply(inspect.formatargspec, inspect.getargspec(object.im_func))\n arglist = arguments.split(', ')\n if len(arglist) > 1:\n arglist[1] = \"(\"+arglist[1]\n arguments = \", \".join(arglist[1:])\n else:\n arguments = \"()\"\n\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n print >> output, inspect.getdoc(object)\n \n elif hasattr(object, '__doc__'):\n print >> output, inspect.getdoc(object)\n \n\ndef source(object, output=sys.stdout):\n if inspect.isroutine(object):\n print >> output, \"In file: %s\\n\" % inspect.getsourcefile(object)\n print >> output, inspect.getsource(object)\n else:\n print >> output, \"Not available for this object.\"\n", + "source_code_before": null, + "methods": [ + { + "name": "split_line", + "long_name": "split_line( name , arguments , width )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 4, + "token_count": 104, + "parameters": [ + "name", + "arguments", + "width" + ], + "start_line": 11, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "makenamedict", + "long_name": "makenamedict( )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 6, + "token_count": 113, + "parameters": [], + "start_line": 34, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "help", + "long_name": "help( object = None , maxwidth = 76 , output = sys . stdout , )", + "filename": "helpmod.py", + "nloc": 98, + "complexity": 25, + "token_count": 734, + "parameters": [ + "object", + "maxwidth", + "output" + ], + "start_line": 54, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 125, + "top_nesting_level": 0 + }, + { + "name": "source", + "long_name": "source( object , output = sys . stdout )", + "filename": "helpmod.py", + "nloc": 6, + "complexity": 2, + "token_count": 51, + "parameters": [ + "object", + "output" + ], + "start_line": 181, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "split_line", + "long_name": "split_line( name , arguments , width )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 4, + "token_count": 104, + "parameters": [ + "name", + "arguments", + "width" + ], + "start_line": 11, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "help", + "long_name": "help( object = None , maxwidth = 76 , output = sys . stdout , )", + "filename": "helpmod.py", + "nloc": 98, + "complexity": 25, + "token_count": 734, + "parameters": [ + "object", + "maxwidth", + "output" + ], + "start_line": 54, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 125, + "top_nesting_level": 0 + }, + { + "name": "source", + "long_name": "source( object , output = sys . stdout )", + "filename": "helpmod.py", + "nloc": 6, + "complexity": 2, + "token_count": 51, + "parameters": [ + "object", + "output" + ], + "start_line": 181, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "makenamedict", + "long_name": "makenamedict( )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 6, + "token_count": 113, + "parameters": [], + "start_line": 34, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + } + ], + "nloc": 145, + "complexity": 37, + "token_count": 1020, + "diff_parsed": { + "added": [ + "import inspect", + "import types", + "import sys, os", + "", + "# NOTE: pydoc defines a help function which works simliarly to this", + "# except it uses a pager to take over the screen.", + "", + "# combine name and arguments and split to multiple lines of", + "# width characters. End lines on a comma and begin argument list", + "# indented with the rest of the arguments.", + "def split_line(name, arguments, width):", + " firstwidth = len(name)", + " k = firstwidth", + " newstr = name", + " sepstr = \", \"", + " arglist = arguments.split(sepstr)", + " for argument in arglist:", + " if k == firstwidth:", + " addstr = \"\"", + " else:", + " addstr = sepstr", + " k = k + len(argument) + len(addstr)", + " if k > width:", + " k = firstwidth + 1 + len(argument)", + " newstr = newstr + \",\\n\" + \" \"*(firstwidth+2) + argument", + " else:", + " newstr = newstr + addstr + argument", + " return newstr", + "", + "_namedict = None", + "_dictlist = None", + "", + "# Traverse all module directories underneath globals to see if something is defined", + "def makenamedict():", + " import scipy", + " thedict = {'scipy':scipy.__dict__}", + " dictlist = ['scipy']", + " totraverse = [scipy.__dict__]", + " while 1:", + " if len(totraverse) == 0:", + " break", + " thisdict = totraverse.pop(0)", + " for x in thisdict.keys():", + " if isinstance(thisdict[x],types.ModuleType):", + " modname = thisdict[x].__name__", + " if modname not in dictlist:", + " moddict = thisdict[x].__dict__", + " dictlist.append(modname)", + " totraverse.append(moddict)", + " thedict[modname] = moddict", + " return thedict, dictlist", + "", + "", + "def help(object=None,maxwidth=76,output=sys.stdout,):", + " \"\"\"Get help information for a function, class, or module.", + "", + " Example:", + " >>> from scipy import *", + " >>> help(polyval)", + " polyval(p, x)", + "", + " Evaluate the polymnomial p at x.", + "", + " Description:", + " If p is of length N, this function returns the value:", + " p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]", + " \"\"\"", + " global _namedict, _dictlist", + " if object is None:", + " help(help)", + " elif isinstance(object, types.StringType):", + " if _namedict is None:", + " _namedict, _dictlist = makenamedict()", + " numfound = 0", + " objlist = []", + " for namestr in _dictlist:", + " try:", + " obj = _namedict[namestr][object]", + " if id(obj) in objlist:", + " print >> output, \"\\n *** Repeat reference found in %s *** \" % namestr", + " else:", + " objlist.append(id(obj))", + " print >> output, \" *** Found in %s ***\" % namestr", + " help(obj)", + " print >> output, \"-\"*maxwidth", + " numfound += 1", + " except KeyError:", + " pass", + " if numfound == 0:", + " print >> output, \"Help for %s not found.\" % object", + " else:", + " print >> output, \"\\n *** Total of %d references found. ***\" % numfound", + "", + " elif inspect.isfunction(object):", + " name = object.func_name", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object))", + "", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " print >> output, inspect.getdoc(object)", + "", + " elif inspect.isclass(object):", + " name = object.__name__", + " if hasattr(object, '__init__'):", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object.__init__.im_func))", + " arglist = arguments.split(', ')", + " if len(arglist) > 1:", + " arglist[1] = \"(\"+arglist[1]", + " arguments = \", \".join(arglist[1:])", + " else:", + " arguments = \"()\"", + " else:", + " arguments = \"()\"", + "", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " doc1 = inspect.getdoc(object)", + " if doc1 is None:", + " if hasattr(object,'__init__'):", + " print >> output, inspect.getdoc(object.__init__)", + " else:", + " print >> output, inspect.getdoc(object)", + "", + " elif type(object) is types.InstanceType: ## check for __call__ method", + " print >> output, \"Instance of class: \", object.__class__.__name__", + " print >> output", + " if hasattr(object, '__call__'):", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object.__call__.im_func))", + " arglist = arguments.split(', ')", + " if len(arglist) > 1:", + " arglist[1] = \"(\"+arglist[1]", + " arguments = \", \".join(arglist[1:])", + " else:", + " arguments = \"()\"", + "", + " name = \"\"", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " doc = inspect.getdoc(object.__call__)", + " if doc is not None:", + " print >> output, inspect.getdoc(object.__call__)", + " print >> output, inspect.getdoc(object)", + "", + " else:", + " print >> output, inspect.getdoc(object)", + "", + " elif inspect.ismethod(object):", + " name = object.__name__", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object.im_func))", + " arglist = arguments.split(', ')", + " if len(arglist) > 1:", + " arglist[1] = \"(\"+arglist[1]", + " arguments = \", \".join(arglist[1:])", + " else:", + " arguments = \"()\"", + "", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " print >> output, inspect.getdoc(object)", + "", + " elif hasattr(object, '__doc__'):", + " print >> output, inspect.getdoc(object)", + "", + "", + "def source(object, output=sys.stdout):", + " if inspect.isroutine(object):", + " print >> output, \"In file: %s\\n\" % inspect.getsourcefile(object)", + " print >> output, inspect.getsource(object)", + " else:", + " print >> output, \"Not available for this object.\"" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy_base/polynomial.py", + "filename": "polynomial.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,467 @@\n+import Numeric\n+from Numeric import *\n+from scimath import *\n+from convenience import diag\n+from utility import hstack, r1array, trim_zeros\n+\n+__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n+ 'polydiv','polyval','poly1d']\n+ \n+def get_eigval_func():\n+ try:\n+ import scipy.linalg\n+ eigvals = scipy.linalg.eigvals\n+ except:\n+ try:\n+ import LinearAlgebra\n+ eigvals = LinearAlgebra.eigenvalues\n+ except:\n+ raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n+ return eigvals\n+\n+def 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 = r1array(seq_of_zeros) \n+ sh = shape(seq_of_zeros)\n+ if len(sh) == 2 and sh[0] == sh[1]:\n+ seq_of_zeros, vecs = MLab.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+\n+def 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 = r1array(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(a))\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+\n+ # tack any zeros onto the back of the array \n+ roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n+ return roots\n+\n+def 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 = r1array(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+ \n+def 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+\n+def 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+\n+def polyadd(a1,a2):\n+ \"\"\"Adds two polynomials represented as lists\n+ \"\"\"\n+ truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n+ a1,a2 = map(r1array,(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+def polysub(a1,a2):\n+ \"\"\"Subtracts two polynomials represented as lists\n+ \"\"\"\n+ truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n+ a1,a2 = map(r1array,(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+\n+def 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+\n+def 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+\n+def 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 = r1array(signal)\n+ den = r1array(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+\n+import re\n+_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\n+def _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+ \n+class 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 = r1array(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", + "added_lines": 467, + "deleted_lines": 0, + "source_code": "import Numeric\nfrom Numeric import *\nfrom scimath import *\nfrom convenience import diag\nfrom utility import hstack, r1array, trim_zeros\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:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = r1array(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros, vecs = MLab.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 = r1array(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(a))\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\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 = r1array(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(r1array,(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(r1array,(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 = r1array(signal)\n den = r1array(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 = r1array(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key == '__coerce__':\n raise KeyError\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", + "source_code_before": null, + "methods": [ + { + "name": "get_eigval_func", + "long_name": "get_eigval_func( )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 36, + "parameters": [], + "start_line": 10, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 22, + "complexity": 9, + "token_count": 194, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 22, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 61, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "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": 98, + "end_line": 128, + "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": 130, + "end_line": 146, + "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": 148, + "end_line": 161, + "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": 163, + "end_line": 179, + "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": 181, + "end_line": 197, + "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": 200, + "end_line": 207, + "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": 209, + "end_line": 218, + "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": 220, + "end_line": 239, + "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": 243, + "end_line": 267, + "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": 287, + "end_line": 301, + "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": 303, + "end_line": 307, + "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": 309, + "end_line": 312, + "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": 314, + "end_line": 315, + "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": 317, + "end_line": 358, + "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": 361, + "end_line": 362, + "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": 364, + "end_line": 369, + "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": 371, + "end_line": 376, + "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": 378, + "end_line": 383, + "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": 385, + "end_line": 390, + "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": 392, + "end_line": 398, + "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": 400, + "end_line": 405, + "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": 407, + "end_line": 412, + "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": 414, + "end_line": 419, + "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": 421, + "end_line": 426, + "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": 428, + "end_line": 429, + "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": 431, + "end_line": 441, + "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": 443, + "end_line": 449, + "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": 451, + "end_line": 461, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "methods_before": [], + "changed_methods": [ + { + "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": 463, + "end_line": 464, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 378, + "end_line": 383, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "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": 287, + "end_line": 301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "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": 364, + "end_line": 369, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "polynomial.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 309, + "end_line": 312, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "get_eigval_func", + "long_name": "get_eigval_func( )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 36, + "parameters": [], + "start_line": 10, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , val )", + "filename": "polynomial.py", + "nloc": 7, + "complexity": 3, + "token_count": 37, + "parameters": [ + "self", + "val" + ], + "start_line": 443, + "end_line": 449, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__str__", + "long_name": "__str__( self )", + "filename": "polynomial.py", + "nloc": 41, + "complexity": 17, + "token_count": 244, + "parameters": [ + "self" + ], + "start_line": 317, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "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": 371, + "end_line": 376, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "polyder", + "long_name": "polyder( p , m = 1 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 4, + "token_count": 99, + "parameters": [ + "p", + "m" + ], + "start_line": 130, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 163, + "end_line": 179, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 61, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "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": 148, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 314, + "end_line": 315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__call__", + "long_name": "__call__( self , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 16, + "parameters": [ + "self", + "val" + ], + "start_line": 361, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 421, + "end_line": 426, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "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": 451, + "end_line": 461, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "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": 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": 392, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "polymul", + "long_name": "polymul( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 3, + "token_count": 46, + "parameters": [ + "a1", + "a2" + ], + "start_line": 200, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "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": 243, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "deriv", + "long_name": "deriv( self , m = 1 )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 23, + "parameters": [ + "self", + "m" + ], + "start_line": 466, + "end_line": 467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 407, + "end_line": 412, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "polydiv", + "long_name": "polydiv( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 8, + "complexity": 5, + "token_count": 94, + "parameters": [ + "a1", + "a2" + ], + "start_line": 209, + "end_line": 218, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 22, + "complexity": 9, + "token_count": 194, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 22, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "__radd__", + "long_name": "__radd__( self , other )", + "filename": "polynomial.py", + "nloc": 6, + "complexity": 2, + "token_count": 44, + "parameters": [ + "self", + "other" + ], + "start_line": 385, + "end_line": 390, + "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": 414, + "end_line": 419, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 124, + "parameters": [ + "a1", + "a2" + ], + "start_line": 181, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "__setattr__", + "long_name": "__setattr__( self , key , val )", + "filename": "polynomial.py", + "nloc": 2, + "complexity": 1, + "token_count": 13, + "parameters": [ + "self", + "key", + "val" + ], + "start_line": 428, + "end_line": 429, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 303, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "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": 98, + "end_line": 128, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "__getattr__", + "long_name": "__getattr__( self , key )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 5, + "token_count": 65, + "parameters": [ + "self", + "key" + ], + "start_line": 431, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 1 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 3, + "token_count": 115, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 220, + "end_line": 239, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "nloc": 368, + "complexity": 119, + "token_count": 2683, + "diff_parsed": { + "added": [ + "import Numeric", + "from Numeric import *", + "from scimath import *", + "from convenience import diag", + "from utility import hstack, r1array, trim_zeros", + "", + "__all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',", + " 'polydiv','polyval','poly1d']", + "", + "def get_eigval_func():", + " try:", + " import scipy.linalg", + " eigvals = scipy.linalg.eigvals", + " except:", + " try:", + " import LinearAlgebra", + " eigvals = LinearAlgebra.eigenvalues", + " except:", + " raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"", + " return eigvals", + "", + "def poly(seq_of_zeros):", + " \"\"\" Return a sequence representing a polynomial given a sequence of roots.", + "", + " If the input is a matrix, return the characteristic polynomial.", + "", + " Example:", + "", + " >>> b = roots([1,3,1,5,6])", + " >>> poly(b)", + " array([1., 3., 1., 5., 6.])", + " \"\"\"", + " seq_of_zeros = r1array(seq_of_zeros)", + " sh = shape(seq_of_zeros)", + " if len(sh) == 2 and sh[0] == sh[1]:", + " seq_of_zeros, vecs = MLab.eig(seq_of_zeros)", + " elif len(sh) ==1:", + " pass", + " else:", + " raise ValueError, \"input must be 1d or square 2d array.\"", + "", + " if len(seq_of_zeros) == 0:", + " return 1.0", + "", + " a = [1]", + " for k in range(len(seq_of_zeros)):", + " a = convolve(a,[1, -seq_of_zeros[k]], mode=2)", + "", + "", + " if a.typecode() in ['F','D']:", + " # if complex roots are all complex conjugates, the roots are real.", + " roots = asarray(seq_of_zeros,'D')", + " pos_roots = sort_complex(compress(roots.imag > 0,roots))", + " neg_roots = conjugate(sort_complex(compress(roots.imag < 0,roots)))", + " if (len(pos_roots) == len(neg_roots) and", + " alltrue(neg_roots == pos_roots)):", + " a = a.real.copy()", + "", + " return a", + "", + "def roots(p):", + " \"\"\" Return the roots of the polynomial coefficients in p.", + "", + " The values in the rank-1 array p are coefficients of a polynomial.", + " If the length of p is n+1 then the polynomial is", + " p[0] * x**n + p[1] * x**(n-1) + ... + p[n-1]*x + p[n]", + " \"\"\"", + " # If input is scalar, this makes it an array", + " eig = get_eigval_func()", + " p = r1array(p)", + " if len(p.shape) != 1:", + " raise ValueError,\"Input must be a rank-1 array.\"", + "", + " # find non-zero array entries", + " non_zero = nonzero(ravel(a))", + "", + " # find the number of trailing zeros -- this is the number of roots at 0.", + " trailing_zeros = len(p) - non_zero[-1] - 1", + "", + " # strip leading and trailing zeros", + " p = p[int(non_zero[0]):int(non_zero[-1])+1]", + "", + " # casting: if incoming array isn't floating point, make it floating point.", + " if p.typecode() not in ['f','d','F','D']:", + " p = p.astype('d')", + "", + " N = len(p)", + " if N > 1:", + " # build companion matrix and find its eigenvalues (the roots)", + " A = diag(ones((N-2,),p.typecode()),-1)", + " A[0,:] = -p[1:] / p[0]", + " roots = eig(A)", + "", + " # tack any zeros onto the back of the array", + " roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))", + " return roots", + "", + "def polyint(p,m=1,k=None):", + " \"\"\"Return the mth analytical integral of the polynomial p.", + "", + " If k is None, then zero-valued constants of integration are used.", + " otherwise, k should be a list of length m (or a scalar if m=1) to", + " represent the constants of integration to use for each integration", + " (starting with k[0])", + " \"\"\"", + " m = int(m)", + " if m < 0:", + " raise ValueError, \"Order of integral must be positive (see polyder)\"", + " if k is None:", + " k = Numeric.zeros(m)", + " k = r1array(k)", + " if len(k) == 1 and m > 1:", + " k = k[0]*Numeric.ones(m)", + " if len(k) < m:", + " raise ValueError, \\", + " \"k must be a scalar or a rank-1 array of length 1 or >m.\"", + " if m == 0:", + " return p", + " else:", + " truepoly = isinstance(p,poly1d)", + " p = Numeric.asarray(p)", + " y = Numeric.zeros(len(p)+1,'d')", + " y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)", + " y[-1] = k[0]", + " val = polyint(y,m-1,k=k[1:])", + " if truepoly:", + " val = poly1d(val)", + " return val", + "", + "def polyder(p,m=1):", + " \"\"\"Return the mth derivative of the polynomial p.", + " \"\"\"", + " m = int(m)", + " truepoly = isinstance(p,poly1d)", + " p = Numeric.asarray(p)", + " n = len(p)-1", + " y = p[:-1] * Numeric.arange(n,0,-1)", + " if m < 0:", + " raise ValueError, \"Order of derivative must be positive (see polyint)\"", + " if m == 0:", + " return p", + " else:", + " val = polyder(y,m-1)", + " if truepoly:", + " val = poly1d(val)", + " return val", + "", + "def polyval(p,x):", + " \"\"\"Evaluate the polymnomial p at x.", + "", + " Description:", + "", + " If p is of length N, this function returns the value:", + " p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]", + " \"\"\"", + " x = Numeric.asarray(x)", + " p = Numeric.asarray(p)", + " y = Numeric.zeros(x.shape,x.typecode())", + " for i in range(len(p)):", + " y = x * y + p[i]", + " return y", + "", + "def polyadd(a1,a2):", + " \"\"\"Adds two polynomials represented as lists", + " \"\"\"", + " truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))", + " a1,a2 = map(r1array,(a1,a2))", + " diff = len(a2) - len(a1)", + " if diff == 0:", + " return a1 + a2", + " elif diff > 0:", + " zr = Numeric.zeros(diff)", + " val = Numeric.concatenate((zr,a1)) + a2", + " else:", + " zr = Numeric.zeros(abs(diff))", + " val = a1 + Numeric.concatenate((zr,a2))", + " if truepoly:", + " val = poly1d(val)", + " return val", + "", + "def polysub(a1,a2):", + " \"\"\"Subtracts two polynomials represented as lists", + " \"\"\"", + " truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))", + " a1,a2 = map(r1array,(a1,a2))", + " diff = len(a2) - len(a1)", + " if diff == 0:", + " return a1 - a2", + " elif diff > 0:", + " zr = Numeric.zeros(diff)", + " val = Numeric.concatenate((zr,a1)) - a2", + " else:", + " zr = Numeric.zeros(abs(diff))", + " val = a1 - Numeric.concatenate((zr,a2))", + " if truepoly:", + " val = poly1d(val)", + " return val", + "", + "", + "def polymul(a1,a2):", + " \"\"\"Multiplies two polynomials represented as lists.", + " \"\"\"", + " truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))", + " val = Numeric.convolve(a1,a2)", + " if truepoly:", + " val = poly1d(val)", + " return val", + "", + "def polydiv(a1,a2):", + " \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)", + " \"\"\"", + " truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))", + " q, r = deconvolve(a1,a2)", + " while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):", + " r = r[1:]", + " if truepoly:", + " q, r = map(poly1d,(q,r))", + " return q, r", + "", + "def deconvolve(signal, divisor):", + " \"\"\"Deconvolves divisor out of signal.", + " \"\"\"", + " try:", + " import scipy.signal", + " except:", + " print \"You need scipy.signal to use this function.\"", + " num = r1array(signal)", + " den = r1array(divisor)", + " N = len(num)", + " D = len(den)", + " if D > N:", + " quot = [];", + " rem = num;", + " else:", + " input = Numeric.ones(N-D+1,Numeric.Float)", + " input[1:] = 0", + " quot = scipy.signal.lfilter(num, den, input)", + " rem = num - Numeric.convolve(den,quot,mode=2)", + " return quot, rem", + "", + "import re", + "_poly_mat = re.compile(r\"[*][*]([0-9]*)\")", + "def _raise_power(astr, wrap=70):", + " n = 0", + " line1 = ''", + " line2 = ''", + " output = ' '", + " while 1:", + " mat = _poly_mat.search(astr,n)", + " if mat is None:", + " break", + " span = mat.span()", + " power = mat.groups()[0]", + " partstr = astr[n:span[0]]", + " n = span[1]", + " toadd2 = partstr + ' '*(len(power)-1)", + " toadd1 = ' '*(len(partstr)-1) + power", + " if ((len(line2)+len(toadd2) > wrap) or \\", + " (len(line1)+len(toadd1) > wrap)):", + " output += line1 + \"\\n\" + line2 + \"\\n \"", + " line1 = toadd1", + " line2 = toadd2", + " else:", + " line2 += partstr + ' '*(len(power)-1)", + " line1 += ' '*(len(partstr)-1) + power", + " output += line1 + \"\\n\" + line2", + " return output + astr[n:]", + "", + "", + "class poly1d:", + " \"\"\"A one-dimensional polynomial class.", + "", + " p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3", + "", + " p(0.5) evaluates the polynomial at the location", + " p.r is a list of roots", + " p.c is the coefficient array [1,2,3]", + " p.order is the polynomial order (after leading zeros in p.c are removed)", + " p[k] is the coefficient on the kth power of x (backwards from", + " sequencing the coefficient array.", + "", + " polynomials can be added, substracted, multplied and divided (returns", + " quotient and remainder).", + " asarray(p) will also give the coefficient array, so polynomials can", + " be used in all functions that accept arrays.", + " \"\"\"", + " def __init__(self, c_or_r, r=0):", + " if isinstance(c_or_r,poly1d):", + " for key in c_or_r.__dict__.keys():", + " self.__dict__[key] = c_or_r.__dict__[key]", + " return", + " if r:", + " c_or_r = poly(c_or_r)", + " c_or_r = r1array(c_or_r)", + " if len(c_or_r.shape) > 1:", + " raise ValueError, \"Polynomial must be 1d only.\"", + " c_or_r = trim_zeros(c_or_r, trim='f')", + " if len(c_or_r) == 0:", + " c_or_r = Numeric.array([0])", + " self.__dict__['coeffs'] = c_or_r", + " self.__dict__['order'] = len(c_or_r) - 1", + "", + " def __array__(self,t=None):", + " if t:", + " return Numeric.asarray(self.coeffs,t)", + " else:", + " return Numeric.asarray(self.coeffs)", + "", + " def __repr__(self):", + " vals = repr(self.coeffs)", + " vals = vals[6:-1]", + " return \"poly1d(%s)\" % vals", + "", + " def __len__(self):", + " return self.order", + "", + " def __str__(self):", + " N = self.order", + " thestr = \"0\"", + " for k in range(len(self.coeffs)):", + " coefstr ='%.4g' % abs(self.coeffs[k])", + " if coefstr[-4:] == '0000':", + " coefstr = coefstr[:-5]", + " power = (N-k)", + " if power == 0:", + " if coefstr != '0':", + " newstr = '%s' % (coefstr,)", + " else:", + " if k == 0:", + " newstr = '0'", + " else:", + " newstr = ''", + " elif power == 1:", + " if coefstr == '0':", + " newstr = ''", + " elif coefstr == '1':", + " newstr = 'x'", + " else:", + " newstr = '%s x' % (coefstr,)", + " else:", + " if coefstr == '0':", + " newstr = ''", + " elif coefstr == '1':", + " newstr = 'x**%d' % (power,)", + " else:", + " newstr = '%s x**%d' % (coefstr, power)", + "", + " if k > 0:", + " if newstr != '':", + " if self.coeffs[k] < 0:", + " thestr = \"%s - %s\" % (thestr, newstr)", + " else:", + " thestr = \"%s + %s\" % (thestr, newstr)", + " elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):", + " thestr = \"-%s\" % (newstr,)", + " else:", + " thestr = newstr", + " return _raise_power(thestr)", + "", + "", + " def __call__(self, val):", + " return polyval(self.coeffs, val)", + "", + " def __mul__(self, other):", + " if isscalar(other):", + " return poly1d(other*self.coeffs)", + " else:", + " other = poly1d(other)", + " return poly1d(polymul(self.coeffs, other.coeffs))", + "", + " def __rmul__(self, other):", + " if isscalar(other):", + " return poly1d(other*self.coeffs)", + " else:", + " other = poly1d(other)", + " return poly1d(polymul(self.coeffs, other.coeffs))", + "", + " def __add__(self, other):", + " if isscalar(other):", + " return poly1d(other+self.coeffs)", + " else:", + " other = poly1d(other)", + " return poly1d(polyadd(self.coeffs, other.coeffs))", + "", + " def __radd__(self, other):", + " if isscalar(other):", + " return poly1d(other+self.coeffs)", + " else:", + " other = poly1d(other)", + " return poly1d(polyadd(self.coeffs, other.coeffs))", + "", + " def __pow__(self, val):", + " if not isscalar(val) or int(val) != val or val < 0:", + " raise ValueError, \"Power to non-negative integers only.\"", + " res = [1]", + " for k in range(val):", + " res = polymul(self.coeffs, res)", + " return poly1d(res)", + "", + " def __sub__(self, other):", + " if isscalar(other):", + " return poly1d(self.coeffs-other)", + " else:", + " other = poly1d(other)", + " return poly1d(polysub(self.coeffs, other.coeffs))", + "", + " def __rsub__(self, other):", + " if isscalar(other):", + " return poly1d(other-self.coeffs)", + " else:", + " other = poly1d(other)", + " return poly1d(polysub(other.coeffs, self.coeffs))", + "", + " def __div__(self, other):", + " if isscalar(other):", + " return poly1d(self.coeffs/other)", + " else:", + " other = poly1d(other)", + " return map(poly1d,polydiv(self.coeffs, other.coeffs))", + "", + " def __rdiv__(self, other):", + " if isscalar(other):", + " return poly1d(other/self.coeffs)", + " else:", + " other = poly1d(other)", + " return map(poly1d,polydiv(other.coeffs, self.coeffs))", + "", + " def __setattr__(self, key, val):", + " raise ValueError, \"Attributes cannot be changed this way.\"", + "", + " def __getattr__(self, key):", + " if key == '__coerce__':", + " raise KeyError", + " if key in ['r','roots']:", + " return roots(self.coeffs)", + " elif key in ['c','coef','coefficients']:", + " return self.coeffs", + " elif key in ['o']:", + " return self.order", + " else:", + " return self.__dict__[key]", + "", + " def __getitem__(self, val):", + " ind = self.order - val", + " if val > self.order:", + " return 0", + " if val < 0:", + " return 0", + " return self.coeffs[ind]", + "", + " def __setitem__(self, key, val):", + " ind = self.order - key", + " if key < 0:", + " raise ValueError, \"Does not support negative powers.\"", + " if key > self.order:", + " zr = Numeric.zeros(key-self.order,self.coeffs.typecode())", + " self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))", + " self.__dict__['order'] = key", + " ind = 0", + " self.__dict__['coeffs'][ind] = val", + " return", + "", + " def integ(self, m=1, k=0):", + " return poly1d(polyint(self.coeffs,m=m,k=k))", + "", + " def deriv(self, m=1):", + " return poly1d(polyder(self.coeffs,m=m))" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy_base/scimath.py", + "filename": "scimath.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,84 @@\n+\"\"\"\n+Wrapper functions to more user-friendly calling of certain math functions whose output is\n+different than the input under certain conditions.\n+\"\"\"\n+\n+__all__ = ['sqrt', 'log', 'log10', 'power', 'arccos', 'arcsin', 'arctanh']\n+\n+from convenience import any, isreal\n+import fastumath\n+import Numeric\n+from fastumath import *\n+toextend = fastumath.__dict__.keys()\n+for key in toextend:\n+ if key not in __all__ and key[0] != '_':\n+ __all__.append(key)\n+\n+def _tocomplex(arr):\n+ if arr.typecode() in ['f', 's', 'b', '1']:\n+ return arr.astype('F')\n+ else:\n+ return arr.astype('D')\n+\n+def sqrt(x):\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(x<0):\n+ x = _tocomplex(x)\n+ return fastumath.sqrt(x)\n+\n+def log(x):\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(x<0):\n+ x = _tocomplex(x)\n+ return fastumath.log(x)\n+\n+def log10(x):\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(x<0):\n+ x = _tocomplex(x)\n+ return fastumath.log10(x) \n+\n+def logn(n,s):\n+ \"\"\" logn(n,s) -- Take log base n of s.\n+ \"\"\"\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(x<0):\n+ x = _tocomplex(x)\n+ if isreal(n) and (n<0):\n+ n = _tocomplex(n)\n+ return fastumath.log(s)/fastumath.log(n)\n+\n+def log2(s):\n+ \"\"\" log2(s) -- Take log base 2 of s.\n+ \"\"\"\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(x<0):\n+ x = _tocomplex(x)\n+ return fastumath.log(s)/fastumath.log(2)\n+\n+\n+def power(x, p):\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(x<0):\n+ x = _tocomplex(x)\n+ return fastumath.power(x, p)\n+ \n+def arccos(x):\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(abs(x)>1):\n+ x = _tocomplex(x)\n+ return fastumath.arccos(x)\n+\n+def arcsin(x):\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(abs(x)>1):\n+ x = _tocomplex(x)\n+ return fastumath.arcsin(x)\n+\n+def arctanh(x):\n+ x = Numeric.asarray(x)\n+ if isreal(x) and any(abs(x)>1):\n+ x = _tocomplex(x)\n+ return fastumath.arctanh(x)\n+\n+\n", + "added_lines": 84, + "deleted_lines": 0, + "source_code": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions whose output is\ndifferent than the input under certain conditions.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log10', 'power', 'arccos', 'arcsin', 'arctanh']\n\nfrom convenience import any, isreal\nimport fastumath\nimport Numeric\nfrom fastumath import *\ntoextend = fastumath.__dict__.keys()\nfor key in toextend:\n if key not in __all__ and key[0] != '_':\n __all__.append(key)\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,s):\n \"\"\" logn(n,s) -- Take log base n of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(s)/fastumath.log(n)\n\ndef log2(s):\n \"\"\" log2(s) -- Take log base 2 of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(s)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n\n\n", + "source_code_before": null, + "methods": [ + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 17, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 29, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , s )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "s" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( s )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "s" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 60, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 72, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 60, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 72, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 29, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( s )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "s" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , s )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "s" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 17, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "nloc": 65, + "complexity": 31, + "token_count": 513, + "diff_parsed": { + "added": [ + "\"\"\"", + "Wrapper functions to more user-friendly calling of certain math functions whose output is", + "different than the input under certain conditions.", + "\"\"\"", + "", + "__all__ = ['sqrt', 'log', 'log10', 'power', 'arccos', 'arcsin', 'arctanh']", + "", + "from convenience import any, isreal", + "import fastumath", + "import Numeric", + "from fastumath import *", + "toextend = fastumath.__dict__.keys()", + "for key in toextend:", + " if key not in __all__ and key[0] != '_':", + " __all__.append(key)", + "", + "def _tocomplex(arr):", + " if arr.typecode() in ['f', 's', 'b', '1']:", + " return arr.astype('F')", + " else:", + " return arr.astype('D')", + "", + "def sqrt(x):", + " x = Numeric.asarray(x)", + " if isreal(x) and any(x<0):", + " x = _tocomplex(x)", + " return fastumath.sqrt(x)", + "", + "def log(x):", + " x = Numeric.asarray(x)", + " if isreal(x) and any(x<0):", + " x = _tocomplex(x)", + " return fastumath.log(x)", + "", + "def log10(x):", + " x = Numeric.asarray(x)", + " if isreal(x) and any(x<0):", + " x = _tocomplex(x)", + " return fastumath.log10(x)", + "", + "def logn(n,s):", + " \"\"\" logn(n,s) -- Take log base n of s.", + " \"\"\"", + " x = Numeric.asarray(x)", + " if isreal(x) and any(x<0):", + " x = _tocomplex(x)", + " if isreal(n) and (n<0):", + " n = _tocomplex(n)", + " return fastumath.log(s)/fastumath.log(n)", + "", + "def log2(s):", + " \"\"\" log2(s) -- Take log base 2 of s.", + " \"\"\"", + " x = Numeric.asarray(x)", + " if isreal(x) and any(x<0):", + " x = _tocomplex(x)", + " return fastumath.log(s)/fastumath.log(2)", + "", + "", + "def power(x, p):", + " x = Numeric.asarray(x)", + " if isreal(x) and any(x<0):", + " x = _tocomplex(x)", + " return fastumath.power(x, p)", + "", + "def arccos(x):", + " x = Numeric.asarray(x)", + " if isreal(x) and any(abs(x)>1):", + " x = _tocomplex(x)", + " return fastumath.arccos(x)", + "", + "def arcsin(x):", + " x = Numeric.asarray(x)", + " if isreal(x) and any(abs(x)>1):", + " x = _tocomplex(x)", + " return fastumath.arcsin(x)", + "", + "def arctanh(x):", + " x = Numeric.asarray(x)", + " if isreal(x) and any(abs(x)>1):", + " x = _tocomplex(x)", + " return fastumath.arctanh(x)", + "", + "" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy_base/utility.py", + "filename": "utility.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,860 @@\n+import Numeric\n+import types\n+import cPickle\n+import sys\n+import scipy\n+\n+from Numeric import *\n+from fastumath import *\n+\n+ScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n+\n+__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n+ 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n+ 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n+ 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n+ 'dsplit','array_kind','array_precision','array_type','common_type',\n+ 'trim_zeros','cast']\n+\n+\n+\n+toChar = lambda x: Numeric.array(x, Numeric.Character)\n+toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\n+toInt16 = lambda x: Numeric.array(x, Numeric.Int16)\n+toInt32 = lambda x: Numeric.array(x, Numeric.Int32)\n+toInt = lambda x: Numeric.array(x, Numeric.Int)\n+toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\n+toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\n+toComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\n+toComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n+\n+cast = {Numeric.Character: toChar,\n+ Numeric.Int8: toInt8,\n+ Numeric.Int16: toInt16,\n+ Numeric.Int32: toInt32,\n+ Numeric.Int: toInt,\n+ Numeric.Float32: toFloat32,\n+ Numeric.Float64: toFloat64,\n+ Numeric.Complex32: toComplex32,\n+ Numeric.Complex64: toComplex64}\n+\n+class 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 complex\n+ number, then the stop is not inclusive.\n+\n+ However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n+ part of it's magnitude is interpreted as specifying the number of points to\n+ create between the start and stop values, where the stop value\n+ IS INCLUSIVE.\n+\n+ Example:\n+\n+ >>> grid = nd_grid()\n+ >>> grid[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+ >>> grid[-1:1:5j]\n+ array([-1. , -0.5, 0. , 0.5, 1. ])\n+ \"\"\"\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+ 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+\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+\n+grid = nd_grid()\n+\n+class concatenator:\n+ \"\"\"An object which 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 = linspace(start, stop, num=size, 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+\n+r_=concatenator(0)\n+c_=concatenator(-1)\n+\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+\n+class _index_expression_class:\n+\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+\n+index_exp = _index_expression_class()\n+\n+# End contribution from Konrad.\n+\n+def 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+ 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+def r1array(x):\n+ \"\"\"Ensure x is at least 1-dimensional.\n+ \"\"\"\n+ if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n+ x = [x]\n+ elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n+ x.shape = (1,)\n+ return Numeric.asarray(x)\n+\n+def r2array(x):\n+ \"\"\"Ensure x is at least 2-dimensional.\n+ \"\"\"\n+ if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n+ return Numeric.asarray([[x]])\n+ else:\n+ temp = Numeric.asarray(x)\n+ if len(temp.shape) == 1:\n+ if temp.shape[0] == 0:\n+ temp.shape = (0,) + temp.shape\n+ else:\n+ temp.shape = (1,) + temp.shape\n+ return temp\n+\n+\n+_namefromtype = {'c' : 'character',\n+ '1' : 'signed char',\n+ 'b' : 'unsigned char',\n+ 's' : 'short',\n+ 'i' : 'integer',\n+ 'l' : 'long integer',\n+ 'f' : 'float',\n+ 'd' : 'double',\n+ 'F' : 'complex float',\n+ 'D' : 'complex double',\n+ 'O' : 'object'\n+ }\n+\n+def typename(char):\n+ \"\"\"Return an english name for the given typecode character.\n+ \"\"\"\n+ return _namefromtype[char]\n+\n+def who(vardict=None):\n+ \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n+ \"\"\"\n+ if vardict is None:\n+ print \"Pass in a dictionary: who(globals())\"\n+ return\n+ sta = []\n+ cache = {}\n+ for name in vardict.keys():\n+ if isinstance(vardict[name],Numeric.ArrayType):\n+ var = vardict[name]\n+ idv = id(var)\n+ if idv in cache.keys():\n+ namestr = name + \" (%s)\" % cache[idv]\n+ original=0\n+ else:\n+ cache[idv] = name\n+ namestr = name\n+ original=1\n+ shapestr = \" x \".join(map(str, var.shape))\n+ bytestr = str(var.itemsize()*Numeric.product(var.shape))\n+ sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n+\n+ maxname = 0\n+ maxshape = 0\n+ maxbyte = 0\n+ totalbytes = 0\n+ for k in range(len(sta)):\n+ val = sta[k]\n+ if maxname < len(val[0]):\n+ maxname = len(val[0])\n+ if maxshape < len(val[1]):\n+ maxshape = len(val[1])\n+ if maxbyte < len(val[2]):\n+ maxbyte = len(val[2])\n+ if val[4]:\n+ totalbytes += int(val[2])\n+\n+ max = Numeric.maximum\n+ if len(sta) > 0:\n+ sp1 = max(10,maxname)\n+ sp2 = max(10,maxshape)\n+ sp3 = max(10,maxbyte)\n+ prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n+ print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n+ \n+ for k in range(len(sta)):\n+ val = sta[k]\n+ print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n+ val[1], ' '*(sp2-len(val[1])+5),\n+ val[2], ' '*(sp3-len(val[2])+5),\n+ val[3])\n+ print \"\\nUpper bound on total bytes = %d\" % totalbytes\n+ return\n+ \n+def objsave(file, allglobals, *args):\n+ \"\"\"Pickle the part of a dictionary containing the argument list\n+ into file string.\n+\n+ Syntax: objsave(file, globals(), obj1, obj2, ... )\n+ \"\"\"\n+ fid = open(file,'w')\n+ savedict = {}\n+ for key in allglobals.keys():\n+ inarglist = 0\n+ for obj in args:\n+ if allglobals[key] is obj:\n+ inarglist = 1\n+ break\n+ if inarglist:\n+ savedict[key] = obj\n+ cPickle.dump(savedict,fid,1)\n+ fid.close()\n+ \n+def objload(file, allglobals):\n+ \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n+\n+ Syntax: objload(file, globals())\n+ \"\"\"\n+ fid = open(file,'r')\n+ savedict = cPickle.load(fid)\n+ allglobals.update(savedict)\n+ fid.close()\n+\n+def isscalar(num):\n+ ascalar = 0.0\n+ for type in ScalarType:\n+ ascalar += isinstance(num, type)\n+ return ascalar\n+\n+def all_mat(args):\n+ return map(Matrix.Matrix,args)\n+\n+ \n+# Selector function\n+\n+def 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+def atleast_1d(tup):\n+ \"\"\" Force a sequence of arrays to each be at least 1D.\n+\n+ Description:\n+ Force a sequence of arrays to each be at least 1D. If an array\n+ in the sequence is 0D, the array is converted to a single\n+ row of values. Otherwise, the array is unaltered.\n+ Arguments:\n+ tup -- sequence of arrays.\n+ Returns:\n+ tuple containing input arrays converted to at least 1D arrays.\n+ \"\"\"\n+ new_tup = []\n+ for ary in tup:\n+ if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n+ else: new_tup.append(ary)\n+ return tuple(new_tup)\n+\n+def atleast_2d(tup):\n+ \"\"\" Force a sequence of arrays to each be at least 2D.\n+\n+ Description:\n+ Force a sequence of arrays to each be at least 2D. If an array\n+ in the sequence is 0D or 1D, the array is converted to a single\n+ row of values. Otherwise, the array is unaltered.\n+ Arguments:\n+ tup -- sequence of arrays.\n+ Returns:\n+ tuple containing input arrays converted to at least 2D arrays.\n+ \"\"\"\n+ new_tup = []\n+ for ary in tup:\n+ if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n+ if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n+ else: new_tup.append(ary)\n+ return tuple(new_tup)\n+\n+def atleast_3d(tup):\n+ \"\"\" Force a sequence of arrays to each be at least 3D.\n+\n+ Description:\n+ Force a sequence of arrays to each be at least 3D. If an array\n+ in the sequence is 0D or 1D, the array is converted to a single\n+ 1xNx1 array of values where N is the orginal length of the array.\n+ If the array is 2D, the array is converted to a single MxNx1\n+ array of values where MxN is the orginal shape of the array.\n+ Otherwise, the array is unaltered.\n+ Arguments:\n+ tup -- sequence of arrays.\n+ Returns:\n+ tuple containing input arrays converted to at least 2D arrays.\n+ \"\"\"\n+ new_tup = []\n+ for ary in tup:\n+ if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n+ if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n+ elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n+ else: new_tup.append(ary)\n+ return tuple(new_tup)\n+\n+def vstack(tup):\n+ \"\"\" Stack arrays in sequence vertically (row wise)\n+\n+ Description:\n+ Take a sequence of arrays and stack them veritcally\n+ to make a single array. All arrays in the sequence\n+ must have the same shape along all but the first axis. \n+ vstack will rebuild arrays divided by vsplit.\n+ Arguments:\n+ tup -- sequence of arrays. All arrays must have the same \n+ shape.\n+ Examples:\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.vstack((a,b))\n+ array([[1, 2, 3],\n+ [2, 3, 4]])\n+ >>> a = array([[1],[2],[3]])\n+ >>> b = array([[2],[3],[4]])\n+ >>> scipy.vstack((a,b))\n+ array([[1],\n+ [2],\n+ [3],\n+ [2],\n+ [3],\n+ [4]])\n+\n+ \"\"\"\n+ return Numeric.concatenate(atleast_2d(tup),0)\n+\n+def hstack(tup):\n+ \"\"\" Stack arrays in sequence horizontally (column wise)\n+\n+ Description:\n+ Take a sequence of arrays and stack them horizontally\n+ to make a single array. All arrays in the sequence\n+ must have the same shape along all but the second axis.\n+ hstack will rebuild arrays divided by hsplit.\n+ Arguments:\n+ tup -- sequence of arrays. All arrays must have the same \n+ shape.\n+ Examples:\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.hstack((a,b))\n+ array([1, 2, 3, 2, 3, 4])\n+ >>> a = array([[1],[2],[3]])\n+ >>> b = array([[2],[3],[4]])\n+ >>> scipy.hstack((a,b))\n+ array([[1, 2],\n+ [2, 3],\n+ [3, 4]])\n+\n+ \"\"\"\n+ return Numeric.concatenate(atleast_1d(tup),1)\n+\n+def column_stack(tup):\n+ \"\"\" Stack 1D arrays as columns into a 2D array\n+\n+ Description:\n+ Take a sequence of 1D arrays and stack them as columns\n+ to make a single 2D array. All arrays in the sequence\n+ must have the same length.\n+ Arguments:\n+ tup -- sequence of 1D arrays. All arrays must have the same \n+ length.\n+ Examples:\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.vstack((a,b))\n+ array([[1, 2],\n+ [2, 3],\n+ [3, 4]])\n+\n+ \"\"\"\n+ arrays = map(Numeric.transpose,atleast_2d(tup))\n+ return Numeric.concatenate(arrays,1)\n+ \n+def dstack(tup):\n+ \"\"\" Stack arrays in sequence depth wise (along third dimension)\n+\n+ Description:\n+ Take a sequence of arrays and stack them along the third axis.\n+ All arrays in the sequence must have the same shape along all \n+ but the third axis. This is a simple way to stack 2D arrays \n+ (images) into a single 3D array for processing.\n+ dstack will rebuild arrays divided by dsplit.\n+ Arguments:\n+ tup -- sequence of arrays. All arrays must have the same \n+ shape.\n+ Examples:\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.dstack((a,b))\n+ array([ [[1, 2],\n+ [2, 3],\n+ [3, 4]]])\n+ >>> a = array([[1],[2],[3]])\n+ >>> b = array([[2],[3],[4]])\n+ >>> scipy.dstack((a,b))\n+ array([[ [1, 2]],\n+ [ [2, 3]],\n+ [ [3, 4]]])\n+ \"\"\"\n+ return Numeric.concatenate(atleast_3d(tup),2)\n+\n+def replace_zero_by_x_arrays(sub_arys):\n+ for i in range(len(sub_arys)):\n+ if len(Numeric.shape(sub_arys[i])) == 0:\n+ sub_arys[i] = Numeric.array([])\n+ elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n+ sub_arys[i] = Numeric.array([]) \n+ return sub_arys\n+ \n+def array_split(ary,indices_or_sections,axis = 0):\n+ \"\"\" Divide an array into a list of sub-arrays.\n+\n+ Description:\n+ Divide ary into a list of sub-arrays along the\n+ specified axis. If indices_or_sections is an integer,\n+ ary is divided into that many equally sized arrays.\n+ If it is impossible to make an equal split, each of the\n+ leading arrays in the list have one additional member. If\n+ indices_or_sections is a list of sorted integers, its\n+ entries define the indexes where ary is split.\n+\n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ axis -- integer. default=0.\n+ Specifies the axis along which to split ary.\n+ Caveats:\n+ Currently, the default for axis is 0. This\n+ means a 2D array is divided into multiple groups\n+ of rows. This seems like the appropriate default, but\n+ we've agreed most other functions should default to\n+ axis=-1. Perhaps we should use axis=-1 for consistency.\n+ However, we could also make the argument that SciPy\n+ works on \"rows\" by default. sum() sums up rows of\n+ values. split() will split data into rows. Opinions?\n+ \"\"\"\n+ try:\n+ Ntotal = ary.shape[axis]\n+ except AttributeError:\n+ Ntotal = len(ary)\n+ try: # handle scalar case.\n+ Nsections = len(indices_or_sections) + 1\n+ div_points = [0] + list(indices_or_sections) + [Ntotal]\n+ except TypeError: #indices_or_sections is a scalar, not an array.\n+ Nsections = int(indices_or_sections)\n+ if Nsections <= 0:\n+ raise ValueError, 'number sections must be larger than 0.'\n+ Neach_section,extras = divmod(Ntotal,Nsections)\n+ section_sizes = [0] + \\\n+ extras * [Neach_section+1] + \\\n+ (Nsections-extras) * [Neach_section]\n+ div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n+\n+ sub_arys = []\n+ sary = Numeric.swapaxes(ary,axis,0)\n+ for i in range(Nsections):\n+ st = div_points[i]; end = div_points[i+1]\n+ sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n+\n+ # there is a wierd issue with array slicing that allows\n+ # 0x10 arrays and other such things. The following cluge is needed\n+ # to get around this issue.\n+ sub_arys = replace_zero_by_x_arrays(sub_arys)\n+ # end cluge.\n+\n+ return sub_arys\n+\n+def split(ary,indices_or_sections,axis=0):\n+ \"\"\" Divide an array into a list of sub-arrays.\n+\n+ Description:\n+ Divide ary into a list of sub-arrays along the\n+ specified axis. If indices_or_sections is an integer,\n+ ary is divided into that many equally sized arrays.\n+ If it is impossible to make an equal split, an error is \n+ raised. This is the only way this function differs from\n+ the array_split() function. If indices_or_sections is a \n+ list of sorted integers, its entries define the indexes\n+ where ary is split.\n+\n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ axis -- integer. default=0.\n+ Specifies the axis along which to split ary.\n+ Caveats:\n+ Currently, the default for axis is 0. This\n+ means a 2D array is divided into multiple groups\n+ of rows. This seems like the appropriate default, but\n+ we've agreed most other functions should default to\n+ axis=-1. Perhaps we should use axis=-1 for consistency.\n+ However, we could also make the argument that SciPy\n+ works on \"rows\" by default. sum() sums up rows of\n+ values. split() will split data into rows. Opinions?\n+ \"\"\"\n+ try: len(indices_or_sections)\n+ except TypeError:\n+ sections = indices_or_sections\n+ N = ary.shape[axis]\n+ if N % sections:\n+ raise ValueError, 'array split does not result in an equal division'\n+ res = array_split(ary,indices_or_sections,axis)\n+ return res\n+\n+def hsplit(ary,indices_or_sections):\n+ \"\"\" Split ary into multiple columns of sub-arrays\n+\n+ Description:\n+ Split a single array into multiple sub arrays. The array is\n+ divided into groups of columns. If indices_or_sections is\n+ an integer, ary is divided into that many equally sized sub arrays.\n+ If it is impossible to make the sub-arrays equally sized, the\n+ operation throws a ValueError exception. See array_split and\n+ split for other options on indices_or_sections. \n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ Returns:\n+ sequence of sub-arrays. The returned arrays have the same \n+ number of dimensions as the input array.\n+ Related:\n+ hstack, split, array_split, vsplit, dsplit. \n+ Examples:\n+ >>> a= array((1,2,3,4))\n+ >>> scipy.hsplit(a,2)\n+ [array([1, 2]), array([3, 4])]\n+ >>> a = array([[1,2,3,4],[1,2,3,4]])\n+ [array([[1, 2],\n+ [1, 2]]), array([[3, 4],\n+ [3, 4]])]\n+ \n+ \"\"\"\n+ if len(Numeric.shape(ary)) == 0:\n+ raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n+ if len(ary.shape) > 1:\n+ return split(ary,indices_or_sections,1)\n+ else:\n+ return split(ary,indices_or_sections,0)\n+ \n+def vsplit(ary,indices_or_sections):\n+ \"\"\" Split ary into multiple rows of sub-arrays\n+\n+ Description:\n+ Split a single array into multiple sub arrays. The array is\n+ divided into groups of rows. If indices_or_sections is\n+ an integer, ary is divided into that many equally sized sub arrays.\n+ If it is impossible to make the sub-arrays equally sized, the\n+ operation throws a ValueError exception. See array_split and\n+ split for other options on indices_or_sections.\n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ Returns:\n+ sequence of sub-arrays. The returned arrays have the same \n+ number of dimensions as the input array. \n+ Caveats:\n+ How should we handle 1D arrays here? I am currently raising\n+ an error when I encounter them. Any better approach? \n+ \n+ Should we reduce the returned array to their minium dimensions\n+ by getting rid of any dimensions that are 1?\n+ Related:\n+ vstack, split, array_split, hsplit, dsplit.\n+ Examples:\n+ >>> a = array([[1,2,3,4],\n+ ... [1,2,3,4]])\n+ [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n+ \n+ \"\"\"\n+ if len(Numeric.shape(ary)) < 2:\n+ raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n+ return split(ary,indices_or_sections,0)\n+\n+def dsplit(ary,indices_or_sections):\n+ \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n+\n+ Description:\n+ Split a single array into multiple sub arrays. The array is\n+ divided into groups along the 3rd axis. If indices_or_sections is\n+ an integer, ary is divided into that many equally sized sub arrays.\n+ If it is impossible to make the sub-arrays equally sized, the\n+ operation throws a ValueError exception. See array_split and\n+ split for other options on indices_or_sections. \n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ Returns:\n+ sequence of sub-arrays. The returned arrays have the same \n+ number of dimensions as the input array.\n+ Caveats:\n+ See vsplit caveats. \n+ Related:\n+ dstack, split, array_split, hsplit, vsplit.\n+ Examples:\n+ >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n+ [array([ [[1, 2],\n+ [1, 2]]]), array([ [[3, 4],\n+ [3, 4]]])]\n+ \n+ \"\"\"\n+ if len(Numeric.shape(ary)) < 3:\n+ raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n+ return split(ary,indices_or_sections,2)\n+\n+ \n+# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n+\n+#determine the \"minimum common type code\" for a group of arrays.\n+array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\n+array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\n+array_type = [['f', 'd'], ['F', 'D']]\n+def common_type(*arrays):\n+ kind = 0\n+ precision = 0\n+ for a in arrays:\n+ t = a.typecode()\n+ kind = max(kind, array_kind[t])\n+ precision = max(precision, array_precision[t])\n+ return array_type[kind][precision]\n+\n+def trim_zeros(filt,trim='fb'):\n+ \"\"\"Trim the leading and trailing zeros from a 1D array.\n+ \n+ Example:\n+\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+ \"\"\"\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+\n+ \n+##def test(level=10):\n+## from scipy_test import module_test\n+## module_test(__name__,__file__,level=level)\n+\n+##def test_suite(level=1):\n+## from scipy_test import module_test_suite\n+## return module_test_suite(__name__,__file__,level=level)\n+\n+\n+\n+\n", + "added_lines": 860, + "deleted_lines": 0, + "source_code": "import Numeric\nimport types\nimport cPickle\nimport sys\nimport scipy\n\nfrom Numeric import *\nfrom fastumath import *\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\n__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n 'dsplit','array_kind','array_precision','array_type','common_type',\n 'trim_zeros','cast']\n\n\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoInt = lambda x: Numeric.array(x, Numeric.Int)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\ntoComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n\ncast = {Numeric.Character: toChar,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\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 complex\n number, then the stop is not inclusive.\n\n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n part of it's magnitude is interpreted as specifying the number of points to\n create between the start and stop values, where the stop value\n IS INCLUSIVE.\n\n Example:\n\n >>> grid = nd_grid()\n >>> grid[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 >>> grid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n \"\"\"\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 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\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\ngrid = nd_grid()\n\nclass concatenator:\n \"\"\"An object which 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 = linspace(start, stop, num=size, 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\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\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\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 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\ndef r1array(x):\n \"\"\"Ensure x is at least 1-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n x = [x]\n elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n x.shape = (1,)\n return Numeric.asarray(x)\n\ndef r2array(x):\n \"\"\"Ensure x is at least 2-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n return Numeric.asarray([[x]])\n else:\n temp = Numeric.asarray(x)\n if len(temp.shape) == 1:\n if temp.shape[0] == 0:\n temp.shape = (0,) + temp.shape\n else:\n temp.shape = (1,) + temp.shape\n return temp\n\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'i' : 'integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\ndef who(vardict=None):\n \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n \"\"\"\n if vardict is None:\n print \"Pass in a dictionary: who(globals())\"\n return\n sta = []\n cache = {}\n for name in vardict.keys():\n if isinstance(vardict[name],Numeric.ArrayType):\n var = vardict[name]\n idv = id(var)\n if idv in cache.keys():\n namestr = name + \" (%s)\" % cache[idv]\n original=0\n else:\n cache[idv] = name\n namestr = name\n original=1\n shapestr = \" x \".join(map(str, var.shape))\n bytestr = str(var.itemsize()*Numeric.product(var.shape))\n sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n\n maxname = 0\n maxshape = 0\n maxbyte = 0\n totalbytes = 0\n for k in range(len(sta)):\n val = sta[k]\n if maxname < len(val[0]):\n maxname = len(val[0])\n if maxshape < len(val[1]):\n maxshape = len(val[1])\n if maxbyte < len(val[2]):\n maxbyte = len(val[2])\n if val[4]:\n totalbytes += int(val[2])\n\n max = Numeric.maximum\n if len(sta) > 0:\n sp1 = max(10,maxname)\n sp2 = max(10,maxshape)\n sp3 = max(10,maxbyte)\n prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n \n for k in range(len(sta)):\n val = sta[k]\n print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n val[1], ' '*(sp2-len(val[1])+5),\n val[2], ' '*(sp3-len(val[2])+5),\n val[3])\n print \"\\nUpper bound on total bytes = %d\" % totalbytes\n return\n \ndef objsave(file, allglobals, *args):\n \"\"\"Pickle the part of a dictionary containing the argument list\n into file string.\n\n Syntax: objsave(file, globals(), obj1, obj2, ... )\n \"\"\"\n fid = open(file,'w')\n savedict = {}\n for key in allglobals.keys():\n inarglist = 0\n for obj in args:\n if allglobals[key] is obj:\n inarglist = 1\n break\n if inarglist:\n savedict[key] = obj\n cPickle.dump(savedict,fid,1)\n fid.close()\n \ndef objload(file, allglobals):\n \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n\n Syntax: objload(file, globals())\n \"\"\"\n fid = open(file,'r')\n savedict = cPickle.load(fid)\n allglobals.update(savedict)\n fid.close()\n\ndef isscalar(num):\n ascalar = 0.0\n for type in ScalarType:\n ascalar += isinstance(num, type)\n return ascalar\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n \n# Selector function\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\ndef atleast_1d(tup):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force a sequence of arrays to each be at least 1D. If an array\n in the sequence is 0D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 1D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_2d(tup):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force a sequence of arrays to each be at least 2D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_3d(tup):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force a sequence of arrays to each be at least 3D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n 1xNx1 array of values where N is the orginal length of the array.\n If the array is 2D, the array is converted to a single MxNx1\n array of values where MxN is the orginal shape of the array.\n Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_2d(tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_1d(tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,atleast_2d(tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(atleast_3d(tup),2)\n\ndef replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n \n# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\ndef trim_zeros(filt,trim='fb'):\n \"\"\"Trim the leading and trailing zeros from a 1D array.\n \n Example:\n\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 \"\"\"\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\n \n##def test(level=10):\n## from scipy_test import module_test\n## module_test(__name__,__file__,level=level)\n\n##def test_suite(level=1):\n## from scipy_test import module_test_suite\n## return module_test_suite(__name__,__file__,level=level)\n\n\n\n\n", + "source_code_before": null, + "methods": [ + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 71, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 114, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "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": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 125, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 31, + "complexity": 11, + "token_count": 253, + "parameters": [ + "self", + "key" + ], + "start_line": 127, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 159, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 162, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 195, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 202, + "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": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 204, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 213, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 226, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 235, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 263, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 268, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 323, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 342, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 25, + "parameters": [ + "num" + ], + "start_line": 352, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 364, + "end_line": 410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 412, + "end_line": 428, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 430, + "end_line": 447, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 449, + "end_line": 470, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 472, + "end_line": 500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 502, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 528, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 550, + "end_line": 576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 578, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 586, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 650, + "end_line": 691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 693, + "end_line": 732, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 734, + "end_line": 772, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 774, + "end_line": 809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 818, + "end_line": 825, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 827, + "end_line": 847, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 734, + "end_line": 772, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 213, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 323, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 125, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 114, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 650, + "end_line": 691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 235, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 818, + "end_line": 825, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , start , stop )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 204, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 263, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 364, + "end_line": 410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 528, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 578, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 502, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 25, + "parameters": [ + "num" + ], + "start_line": 352, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 550, + "end_line": 576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 342, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 430, + "end_line": 447, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 449, + "end_line": 470, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 586, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 226, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 693, + "end_line": 732, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 774, + "end_line": 809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 268, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 472, + "end_line": 500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "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": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 195, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 827, + "end_line": 847, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 412, + "end_line": 428, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 71, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + } + ], + "nloc": 405, + "complexity": 121, + "token_count": 3112, + "diff_parsed": { + "added": [ + "import Numeric", + "import types", + "import cPickle", + "import sys", + "import scipy", + "", + "from Numeric import *", + "from fastumath import *", + "", + "ScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]", + "", + "__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',", + " 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',", + " 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',", + " 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',", + " 'dsplit','array_kind','array_precision','array_type','common_type',", + " 'trim_zeros','cast']", + "", + "", + "", + "toChar = lambda x: Numeric.array(x, Numeric.Character)", + "toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte", + "toInt16 = lambda x: Numeric.array(x, Numeric.Int16)", + "toInt32 = lambda x: Numeric.array(x, Numeric.Int32)", + "toInt = lambda x: Numeric.array(x, Numeric.Int)", + "toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)", + "toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)", + "toComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)", + "toComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)", + "", + "cast = {Numeric.Character: toChar,", + " Numeric.Int8: toInt8,", + " Numeric.Int16: toInt16,", + " Numeric.Int32: toInt32,", + " Numeric.Int: toInt,", + " Numeric.Float32: toFloat32,", + " Numeric.Float64: toFloat64,", + " Numeric.Complex32: toComplex32,", + " Numeric.Complex64: toComplex64}", + "", + "class nd_grid:", + " \"\"\"Construct a \"meshgrid\" in N-dimensions.", + "", + " grid = nd_grid() creates an instance which will return a mesh-grid", + " when indexed. The dimension and number of the output arrays are equal", + " to the number of indexing dimensions. If the step length is not a complex", + " number, then the stop is not inclusive.", + "", + " However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer", + " part of it's magnitude is interpreted as specifying the number of points to", + " create between the start and stop values, where the stop value", + " IS INCLUSIVE.", + "", + " Example:", + "", + " >>> grid = nd_grid()", + " >>> grid[0:5,0:5]", + " array([[[0, 0, 0, 0, 0],", + " [1, 1, 1, 1, 1],", + " [2, 2, 2, 2, 2],", + " [3, 3, 3, 3, 3],", + " [4, 4, 4, 4, 4]],", + " [[0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4]]])", + " >>> grid[-1:1:5j]", + " array([-1. , -0.5, 0. , 0.5, 1. ])", + " \"\"\"", + " def __getitem__(self,key):", + " try:", + "\t size = []", + " typecode = Numeric.Int", + "\t for k in range(len(key)):", + "\t step = key[k].step", + " start = key[k].start", + " if start is None: start = 0", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " size.append(int(abs(step)))", + " typecode = Numeric.Float", + " else:", + " size.append(int((key[k].stop - start)/(step*1.0)))", + " if isinstance(step,types.FloatType) or \\", + " isinstance(start, types.FloatType) or \\", + " isinstance(key[k].stop, types.FloatType):", + " typecode = Numeric.Float", + " nn = Numeric.indices(size,typecode)", + "\t for k in range(len(size)):", + " step = key[k].step", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " step = int(abs(step))", + " step = (key[k].stop - key[k].start)/float(step-1)", + " nn[k] = (nn[k]*step+key[k].start)", + "\t return nn", + " except (IndexError, TypeError):", + " step = key.step", + " stop = key.stop", + " start = key.start", + " if start is None: start = 0", + " if type(step) is type(1j):", + " step = abs(step)", + " length = int(step)", + " step = (key.stop-start)/float(step-1)", + " stop = key.stop+step", + " return Numeric.arange(0,length,1,Numeric.Float)*step + start", + " else:", + " return Numeric.arange(start, stop, step)", + "", + " def __getslice__(self,i,j):", + " return Numeric.arange(i,j)", + "", + " def __len__(self):", + " return 0", + "", + "grid = nd_grid()", + "", + "class concatenator:", + " \"\"\"An object which translates slice objects to concatenation along an axis.", + " \"\"\"", + " def __init__(self, axis=0):", + " self.axis = axis", + " def __getitem__(self,key):", + " if type(key) is not types.TupleType:", + " key = (key,)", + " objs = []", + " for k in range(len(key)):", + " if type(key[k]) is types.SliceType:", + " typecode = Numeric.Int", + "\t step = key[k].step", + " start = key[k].start", + " stop = key[k].stop", + " if start is None: start = 0", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " size = int(abs(step))", + " typecode = Numeric.Float", + " endpoint = 1", + " else:", + " size = int((stop - start)/(step*1.0))", + " endpoint = 0", + " if isinstance(step,types.FloatType) or \\", + " isinstance(start, types.FloatType) or \\", + " isinstance(stop, types.FloatType):", + " typecode = Numeric.Float", + " newobj = linspace(start, stop, num=size, endpoint=endpoint)", + " elif type(key[k]) in ScalarType:", + " newobj = Numeric.asarray([key[k]])", + " else:", + " newobj = key[k]", + " objs.append(newobj)", + " return Numeric.concatenate(tuple(objs),axis=self.axis)", + "", + " def __getslice__(self,i,j):", + " return Numeric.arange(i,j)", + "", + " def __len__(self):", + " return 0", + "", + "r_=concatenator(0)", + "c_=concatenator(-1)", + "", + "", + "# A nicer way to build up index tuples for arrays.", + "#", + "# You can do all this with slice() plus a few special objects,", + "# but there's a lot to remember. This version is simpler because", + "# it uses the standard array indexing syntax.", + "#", + "# Written by Konrad Hinsen ", + "# last revision: 1999-7-23", + "#", + "# Cosmetic changes by T. Oliphant 2001", + "#", + "#", + "# This module provides a convenient method for constructing", + "# array indices algorithmically. It provides one importable object,", + "# 'index_expression'.", + "#", + "# For any index combination, including slicing and axis insertion,", + "# 'a[indices]' is the same as 'a[index_expression[indices]]' for any", + "# array 'a'. However, 'index_expression[indices]' can be used anywhere", + "# in Python code and returns a tuple of slice objects that can be", + "# used in the construction of complex index expressions.", + "", + "class _index_expression_class:", + "", + " maxint = sys.maxint", + "", + " def __getitem__(self, item):", + " if type(item) != type(()):", + " return (item,)", + " else:", + " return item", + "", + " def __len__(self):", + " return self.maxint", + "", + " def __getslice__(self, start, stop):", + " if stop == self.maxint:", + " stop = None", + " return self[start:stop:None]", + "", + "index_exp = _index_expression_class()", + "", + "# End contribution from Konrad.", + "", + "def disp(mesg, device=None, linefeed=1):", + " \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.", + " \"\"\"", + " if device is None:", + " device = sys.stdout", + " if linefeed:", + " device.write('%s\\n' % mesg)", + " else:", + " device.write('%s' % mesg)", + " device.flush()", + " return", + "", + "", + "def r1array(x):", + " \"\"\"Ensure x is at least 1-dimensional.", + " \"\"\"", + " if type(x) in [type(1.0), type(1L), type(1), type(1j)]:", + " x = [x]", + " elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):", + " x.shape = (1,)", + " return Numeric.asarray(x)", + "", + "def r2array(x):", + " \"\"\"Ensure x is at least 2-dimensional.", + " \"\"\"", + " if type(x) in [type(1.0), type(1L), type(1), type(1j)]:", + " return Numeric.asarray([[x]])", + " else:", + " temp = Numeric.asarray(x)", + " if len(temp.shape) == 1:", + " if temp.shape[0] == 0:", + " temp.shape = (0,) + temp.shape", + " else:", + " temp.shape = (1,) + temp.shape", + " return temp", + "", + "", + "_namefromtype = {'c' : 'character',", + " '1' : 'signed char',", + " 'b' : 'unsigned char',", + " 's' : 'short',", + " 'i' : 'integer',", + " 'l' : 'long integer',", + " 'f' : 'float',", + " 'd' : 'double',", + " 'F' : 'complex float',", + " 'D' : 'complex double',", + " 'O' : 'object'", + " }", + "", + "def typename(char):", + " \"\"\"Return an english name for the given typecode character.", + " \"\"\"", + " return _namefromtype[char]", + "", + "def who(vardict=None):", + " \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).", + " \"\"\"", + " if vardict is None:", + " print \"Pass in a dictionary: who(globals())\"", + " return", + " sta = []", + " cache = {}", + " for name in vardict.keys():", + " if isinstance(vardict[name],Numeric.ArrayType):", + " var = vardict[name]", + " idv = id(var)", + " if idv in cache.keys():", + " namestr = name + \" (%s)\" % cache[idv]", + " original=0", + " else:", + " cache[idv] = name", + " namestr = name", + " original=1", + " shapestr = \" x \".join(map(str, var.shape))", + " bytestr = str(var.itemsize()*Numeric.product(var.shape))", + " sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])", + "", + " maxname = 0", + " maxshape = 0", + " maxbyte = 0", + " totalbytes = 0", + " for k in range(len(sta)):", + " val = sta[k]", + " if maxname < len(val[0]):", + " maxname = len(val[0])", + " if maxshape < len(val[1]):", + " maxshape = len(val[1])", + " if maxbyte < len(val[2]):", + " maxbyte = len(val[2])", + " if val[4]:", + " totalbytes += int(val[2])", + "", + " max = Numeric.maximum", + " if len(sta) > 0:", + " sp1 = max(10,maxname)", + " sp2 = max(10,maxshape)", + " sp3 = max(10,maxbyte)", + " prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')", + " print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"", + "", + " for k in range(len(sta)):", + " val = sta[k]", + " print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),", + " val[1], ' '*(sp2-len(val[1])+5),", + " val[2], ' '*(sp3-len(val[2])+5),", + " val[3])", + " print \"\\nUpper bound on total bytes = %d\" % totalbytes", + " return", + "", + "def objsave(file, allglobals, *args):", + " \"\"\"Pickle the part of a dictionary containing the argument list", + " into file string.", + "", + " Syntax: objsave(file, globals(), obj1, obj2, ... )", + " \"\"\"", + " fid = open(file,'w')", + " savedict = {}", + " for key in allglobals.keys():", + " inarglist = 0", + " for obj in args:", + " if allglobals[key] is obj:", + " inarglist = 1", + " break", + " if inarglist:", + " savedict[key] = obj", + " cPickle.dump(savedict,fid,1)", + " fid.close()", + "", + "def objload(file, allglobals):", + " \"\"\"Load a previously pickled dictionary and insert into given dictionary.", + "", + " Syntax: objload(file, globals())", + " \"\"\"", + " fid = open(file,'r')", + " savedict = cPickle.load(fid)", + " allglobals.update(savedict)", + " fid.close()", + "", + "def isscalar(num):", + " ascalar = 0.0", + " for type in ScalarType:", + " ascalar += isinstance(num, type)", + " return ascalar", + "", + "def all_mat(args):", + " return map(Matrix.Matrix,args)", + "", + "", + "# Selector function", + "", + "def select(condlist, choicelist, default=0):", + " \"\"\"Returns an array comprised from different elements of choicelist", + " depending on the list of conditions.", + "", + " condlist is a list of condition arrays containing ones or zeros", + "", + " choicelist is a list of choice matrices (of the \"same\" size as the", + " arrays in condlist). The result array has the \"same\" size as the", + " arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist", + " must be of length N. The elements of the choicelist can then be", + " represented as [v0,...,vN-1]. The default choice if none of the", + " conditions are met is given as the default argument.", + "", + " The conditions are tested in order and the first one statisfied is", + " used to select the choice. In other words, the elements of the", + " output array are found from the following tree (notice the order of", + " the conditions matters):", + "", + " if c0: v0", + " elif c1: v1", + " elif c2: v2", + " ...", + " elif cN-1: vN-1", + " else: default", + "", + " Note, that one of the condition arrays must be large enough to handle", + " the largest array in the choice list.", + " \"\"\"", + " n = len(condlist)", + " n2 = len(choicelist)", + " if n2 != n:", + " raise ValueError, \"List of cases, must be same length as the list of conditions.\"", + " choicelist.insert(0,default)", + " S = 0", + " pfac = 1", + " for k in range(1,n+1):", + " S += k * pfac * asarray(condlist[k-1])", + " if k < n:", + " pfac *= (1-asarray(condlist[k-1]))", + " # handle special case of a 1-element condition but", + " # a multi-element choice", + " if type(S) in ScalarType or max(asarray(S).shape)==1:", + " pfac = asarray(1)", + " for k in range(n2+1):", + " pfac = pfac + asarray(choicelist[k])", + " S = S*ones(asarray(pfac).shape)", + " return choose(S, tuple(choicelist))", + "", + "def atleast_1d(tup):", + " \"\"\" Force a sequence of arrays to each be at least 1D.", + "", + " Description:", + " Force a sequence of arrays to each be at least 1D. If an array", + " in the sequence is 0D, the array is converted to a single", + " row of values. Otherwise, the array is unaltered.", + " Arguments:", + " tup -- sequence of arrays.", + " Returns:", + " tuple containing input arrays converted to at least 1D arrays.", + " \"\"\"", + " new_tup = []", + " for ary in tup:", + " if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))", + " else: new_tup.append(ary)", + " return tuple(new_tup)", + "", + "def atleast_2d(tup):", + " \"\"\" Force a sequence of arrays to each be at least 2D.", + "", + " Description:", + " Force a sequence of arrays to each be at least 2D. If an array", + " in the sequence is 0D or 1D, the array is converted to a single", + " row of values. Otherwise, the array is unaltered.", + " Arguments:", + " tup -- sequence of arrays.", + " Returns:", + " tuple containing input arrays converted to at least 2D arrays.", + " \"\"\"", + " new_tup = []", + " for ary in tup:", + " if len(ary.shape) == 0: ary = Numeric.array([ary[0]])", + " if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])", + " else: new_tup.append(ary)", + " return tuple(new_tup)", + "", + "def atleast_3d(tup):", + " \"\"\" Force a sequence of arrays to each be at least 3D.", + "", + " Description:", + " Force a sequence of arrays to each be at least 3D. If an array", + " in the sequence is 0D or 1D, the array is converted to a single", + " 1xNx1 array of values where N is the orginal length of the array.", + " If the array is 2D, the array is converted to a single MxNx1", + " array of values where MxN is the orginal shape of the array.", + " Otherwise, the array is unaltered.", + " Arguments:", + " tup -- sequence of arrays.", + " Returns:", + " tuple containing input arrays converted to at least 2D arrays.", + " \"\"\"", + " new_tup = []", + " for ary in tup:", + " if len(ary.shape) == 0: ary = Numeric.array([ary[0]])", + " if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])", + " elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])", + " else: new_tup.append(ary)", + " return tuple(new_tup)", + "", + "def vstack(tup):", + " \"\"\" Stack arrays in sequence vertically (row wise)", + "", + " Description:", + " Take a sequence of arrays and stack them veritcally", + " to make a single array. All arrays in the sequence", + " must have the same shape along all but the first axis.", + " vstack will rebuild arrays divided by vsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.vstack((a,b))", + " array([[1, 2, 3],", + " [2, 3, 4]])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.vstack((a,b))", + " array([[1],", + " [2],", + " [3],", + " [2],", + " [3],", + " [4]])", + "", + " \"\"\"", + " return Numeric.concatenate(atleast_2d(tup),0)", + "", + "def hstack(tup):", + " \"\"\" Stack arrays in sequence horizontally (column wise)", + "", + " Description:", + " Take a sequence of arrays and stack them horizontally", + " to make a single array. All arrays in the sequence", + " must have the same shape along all but the second axis.", + " hstack will rebuild arrays divided by hsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.hstack((a,b))", + " array([1, 2, 3, 2, 3, 4])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.hstack((a,b))", + " array([[1, 2],", + " [2, 3],", + " [3, 4]])", + "", + " \"\"\"", + " return Numeric.concatenate(atleast_1d(tup),1)", + "", + "def column_stack(tup):", + " \"\"\" Stack 1D arrays as columns into a 2D array", + "", + " Description:", + " Take a sequence of 1D arrays and stack them as columns", + " to make a single 2D array. All arrays in the sequence", + " must have the same length.", + " Arguments:", + " tup -- sequence of 1D arrays. All arrays must have the same", + " length.", + " Examples:", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.vstack((a,b))", + " array([[1, 2],", + " [2, 3],", + " [3, 4]])", + "", + " \"\"\"", + " arrays = map(Numeric.transpose,atleast_2d(tup))", + " return Numeric.concatenate(arrays,1)", + "", + "def dstack(tup):", + " \"\"\" Stack arrays in sequence depth wise (along third dimension)", + "", + " Description:", + " Take a sequence of arrays and stack them along the third axis.", + " All arrays in the sequence must have the same shape along all", + " but the third axis. This is a simple way to stack 2D arrays", + " (images) into a single 3D array for processing.", + " dstack will rebuild arrays divided by dsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.dstack((a,b))", + " array([ [[1, 2],", + " [2, 3],", + " [3, 4]]])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.dstack((a,b))", + " array([[ [1, 2]],", + " [ [2, 3]],", + " [ [3, 4]]])", + " \"\"\"", + " return Numeric.concatenate(atleast_3d(tup),2)", + "", + "def replace_zero_by_x_arrays(sub_arys):", + " for i in range(len(sub_arys)):", + " if len(Numeric.shape(sub_arys[i])) == 0:", + " sub_arys[i] = Numeric.array([])", + " elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):", + " sub_arys[i] = Numeric.array([])", + " return sub_arys", + "", + "def array_split(ary,indices_or_sections,axis = 0):", + " \"\"\" Divide an array into a list of sub-arrays.", + "", + " Description:", + " Divide ary into a list of sub-arrays along the", + " specified axis. If indices_or_sections is an integer,", + " ary is divided into that many equally sized arrays.", + " If it is impossible to make an equal split, each of the", + " leading arrays in the list have one additional member. If", + " indices_or_sections is a list of sorted integers, its", + " entries define the indexes where ary is split.", + "", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " axis -- integer. default=0.", + " Specifies the axis along which to split ary.", + " Caveats:", + " Currently, the default for axis is 0. This", + " means a 2D array is divided into multiple groups", + " of rows. This seems like the appropriate default, but", + " we've agreed most other functions should default to", + " axis=-1. Perhaps we should use axis=-1 for consistency.", + " However, we could also make the argument that SciPy", + " works on \"rows\" by default. sum() sums up rows of", + " values. split() will split data into rows. Opinions?", + " \"\"\"", + " try:", + " Ntotal = ary.shape[axis]", + " except AttributeError:", + " Ntotal = len(ary)", + " try: # handle scalar case.", + " Nsections = len(indices_or_sections) + 1", + " div_points = [0] + list(indices_or_sections) + [Ntotal]", + " except TypeError: #indices_or_sections is a scalar, not an array.", + " Nsections = int(indices_or_sections)", + " if Nsections <= 0:", + " raise ValueError, 'number sections must be larger than 0.'", + " Neach_section,extras = divmod(Ntotal,Nsections)", + " section_sizes = [0] + \\", + " extras * [Neach_section+1] + \\", + " (Nsections-extras) * [Neach_section]", + " div_points = Numeric.add.accumulate(Numeric.array(section_sizes))", + "", + " sub_arys = []", + " sary = Numeric.swapaxes(ary,axis,0)", + " for i in range(Nsections):", + " st = div_points[i]; end = div_points[i+1]", + " sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))", + "", + " # there is a wierd issue with array slicing that allows", + " # 0x10 arrays and other such things. The following cluge is needed", + " # to get around this issue.", + " sub_arys = replace_zero_by_x_arrays(sub_arys)", + " # end cluge.", + "", + " return sub_arys", + "", + "def split(ary,indices_or_sections,axis=0):", + " \"\"\" Divide an array into a list of sub-arrays.", + "", + " Description:", + " Divide ary into a list of sub-arrays along the", + " specified axis. If indices_or_sections is an integer,", + " ary is divided into that many equally sized arrays.", + " If it is impossible to make an equal split, an error is", + " raised. This is the only way this function differs from", + " the array_split() function. If indices_or_sections is a", + " list of sorted integers, its entries define the indexes", + " where ary is split.", + "", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " axis -- integer. default=0.", + " Specifies the axis along which to split ary.", + " Caveats:", + " Currently, the default for axis is 0. This", + " means a 2D array is divided into multiple groups", + " of rows. This seems like the appropriate default, but", + " we've agreed most other functions should default to", + " axis=-1. Perhaps we should use axis=-1 for consistency.", + " However, we could also make the argument that SciPy", + " works on \"rows\" by default. sum() sums up rows of", + " values. split() will split data into rows. Opinions?", + " \"\"\"", + " try: len(indices_or_sections)", + " except TypeError:", + " sections = indices_or_sections", + " N = ary.shape[axis]", + " if N % sections:", + " raise ValueError, 'array split does not result in an equal division'", + " res = array_split(ary,indices_or_sections,axis)", + " return res", + "", + "def hsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple columns of sub-arrays", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups of columns. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Related:", + " hstack, split, array_split, vsplit, dsplit.", + " Examples:", + " >>> a= array((1,2,3,4))", + " >>> scipy.hsplit(a,2)", + " [array([1, 2]), array([3, 4])]", + " >>> a = array([[1,2,3,4],[1,2,3,4]])", + " [array([[1, 2],", + " [1, 2]]), array([[3, 4],", + " [3, 4]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) == 0:", + " raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'", + " if len(ary.shape) > 1:", + " return split(ary,indices_or_sections,1)", + " else:", + " return split(ary,indices_or_sections,0)", + "", + "def vsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple rows of sub-arrays", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups of rows. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Caveats:", + " How should we handle 1D arrays here? I am currently raising", + " an error when I encounter them. Any better approach?", + "", + " Should we reduce the returned array to their minium dimensions", + " by getting rid of any dimensions that are 1?", + " Related:", + " vstack, split, array_split, hsplit, dsplit.", + " Examples:", + " >>> a = array([[1,2,3,4],", + " ... [1,2,3,4]])", + " [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) < 2:", + " raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'", + " return split(ary,indices_or_sections,0)", + "", + "def dsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups along the 3rd axis. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Caveats:", + " See vsplit caveats.", + " Related:", + " dstack, split, array_split, hsplit, vsplit.", + " Examples:", + " >>> a = array([[[1,2,3,4],[1,2,3,4]]])", + " [array([ [[1, 2],", + " [1, 2]]]), array([ [[3, 4],", + " [3, 4]]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) < 3:", + " raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'", + " return split(ary,indices_or_sections,2)", + "", + "", + "# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.", + "", + "#determine the \"minimum common type code\" for a group of arrays.", + "array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}", + "array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}", + "array_type = [['f', 'd'], ['F', 'D']]", + "def common_type(*arrays):", + " kind = 0", + " precision = 0", + " for a in arrays:", + " t = a.typecode()", + " kind = max(kind, array_kind[t])", + " precision = max(precision, array_precision[t])", + " return array_type[kind][precision]", + "", + "def trim_zeros(filt,trim='fb'):", + " \"\"\"Trim the leading and trailing zeros from a 1D array.", + "", + " Example:", + "", + " >>> a = array((0,0,0,1,2,3,2,1,0))", + " >>> scipy.trim_zeros(a)", + " array([1, 2, 3, 2, 1])", + "", + " \"\"\"", + " first = 0", + " if 'f' in trim or 'F' in trim:", + " for i in filt:", + " if i != 0.: break", + " else: first = first + 1", + " last = len(filt)", + " if 'b' in trim or 'B' in trim:", + " for i in filt[::-1]:", + " if i != 0.: break", + " else: last = last - 1", + " return filt[first:last]", + "", + "", + "##def test(level=10):", + "## from scipy_test import module_test", + "## module_test(__name__,__file__,level=level)", + "", + "##def test_suite(level=1):", + "## from scipy_test import module_test_suite", + "## return module_test_suite(__name__,__file__,level=level)", + "", + "", + "", + "" + ], + "deleted": [] + } + }, + { + "old_path": "scipy_test/setup_scipy_test.py", + "new_path": "scipy_test/setup_scipy_test.py", + "filename": "setup_scipy_test.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -20,6 +20,7 @@ def install_package():\n scipy_distutils directory even if it was invoked from another script\n located in a different location.\n \"\"\"\n+ print \"###################I was called####################\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n", + "added_lines": 1, + "deleted_lines": 0, + "source_code": "#!/usr/bin/env python\nimport os\nfrom distutils.core import setup\nfrom scipy_distutils.misc_util import get_path, default_config_dict \n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_test')\n config['package_dir'][parent_package+'scipy_test'] = local_path\n return config\n \ndef install_package():\n \"\"\" Install the scipy_test module. The dance with the current directory \n is done to fool distutils into thinking it is run from the \n scipy_distutils directory even if it was invoked from another script\n located in a different location.\n \"\"\"\n print \"###################I was called####################\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n setup (name = \"scipy_test\",\n version = \"0.1\",\n description = \"Supports testing of SciPy and other heirarchical packages\",\n author = \"Eric Jones\",\n licence = \"BSD Style\",\n url = 'http://www.scipy.org',\n py_modules = ['scipy_test']\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", + "source_code_before": "#!/usr/bin/env python\nimport os\nfrom distutils.core import setup\nfrom scipy_distutils.misc_util import get_path, default_config_dict \n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_test')\n config['package_dir'][parent_package+'scipy_test'] = local_path\n return config\n \ndef install_package():\n \"\"\" Install the scipy_test module. The dance with the current directory \n is done to fool distutils into thinking it is run from the \n scipy_distutils directory even if it was invoked from another script\n located in a different location.\n \"\"\"\n path = get_path(__name__)\n old_path = os.getcwd()\n os.chdir(path)\n try:\n setup (name = \"scipy_test\",\n version = \"0.1\",\n description = \"Supports testing of SciPy and other heirarchical packages\",\n author = \"Eric Jones\",\n licence = \"BSD Style\",\n url = 'http://www.scipy.org',\n py_modules = ['scipy_test']\n )\n finally:\n os.chdir(old_path)\n \nif __name__ == '__main__':\n install_package()\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' )", + "filename": "setup_scipy_test.py", + "nloc": 9, + "complexity": 2, + "token_count": 51, + "parameters": [ + "parent_package" + ], + "start_line": 6, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "install_package", + "long_name": "install_package( )", + "filename": "setup_scipy_test.py", + "nloc": 16, + "complexity": 2, + "token_count": 68, + "parameters": [], + "start_line": 17, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' )", + "filename": "setup_scipy_test.py", + "nloc": 9, + "complexity": 2, + "token_count": 51, + "parameters": [ + "parent_package" + ], + "start_line": 6, + "end_line": 15, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "install_package", + "long_name": "install_package( )", + "filename": "setup_scipy_test.py", + "nloc": 15, + "complexity": 2, + "token_count": 66, + "parameters": [], + "start_line": 17, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "install_package", + "long_name": "install_package( )", + "filename": "setup_scipy_test.py", + "nloc": 16, + "complexity": 2, + "token_count": 68, + "parameters": [], + "start_line": 17, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "nloc": 30, + "complexity": 4, + "token_count": 145, + "diff_parsed": { + "added": [ + " print \"###################I was called####################\"" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "1e175b81241e25e1fd13757c71b704dbf71cd8e4", + "msg": "Changed references to fastumath to scipy_base.fastumath", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-03-30T00:45:45+00:00", + "author_timezone": 0, + "committer_date": "2002-03-30T00:45:45+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "0562713ee528cae5ac5a4386ce92d7d2c37c3b9e" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 8, + "insertions": 8, + "lines": 16, + "files": 6, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "weave/blitz_tools.py", + "new_path": "weave/blitz_tools.py", + "filename": "blitz_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -13,7 +13,7 @@\n from Numeric import *\n # The following try/except so that non-SciPy users can still use blitz\n try:\n- from fastumath import *\n+ from scipy_base.fastumath import *\n except:\n pass # fastumath not available \n \n@@ -153,4 +153,4 @@ def test_suite(level=1):\n return module_test_suite(__name__,__file__,level=level)\n \n if __name__ == \"__main__\":\n- test_function()\n\\ No newline at end of file\n+ test_function()\n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "import parser\nimport string\nimport copy\nimport os,sys\nimport ast_tools\nimport token,symbol\nimport slice_handler\nimport size_check\nimport converters\n\nfrom ast_tools import *\n\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # fastumath not available \n \nfrom types import *\n\nimport inline_tools\nfrom inline_tools import attempt_function_call\nfunction_catalog = inline_tools.function_catalog\nfunction_cache = inline_tools.function_cache\n \ndef blitz(expr,local_dict=None, global_dict=None,check_size=1,verbose=0,**kw):\n # this could call inline, but making a copy of the\n # code here is more efficient for several reasons.\n global function_catalog\n \n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n\n # 1. Check the sizes of the arrays and make sure they are compatible.\n # This is expensive, so unsetting the check_size flag can save a lot\n # of time. It also can cause core-dumps if the sizes of the inputs \n # aren't compatible. \n if check_size and not size_check.check_expr(expr,local_dict,global_dict):\n raise 'inputs failed to pass size check.'\n \n # 2. try local cache \n try:\n results = apply(function_cache[expr],(local_dict,global_dict))\n return results\n except: \n pass\n try:\n results = attempt_function_call(expr,local_dict,global_dict)\n # 3. build the function \n except ValueError:\n # This section is pretty much the only difference \n # between blitz and inline\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n expr_code = ast_to_blitz_expr(ast_list)\n arg_names = harvest_variables(ast_list)\n module_dir = global_dict.get('__file__',None)\n #func = inline_tools.compile_function(expr_code,arg_names,\n # local_dict,global_dict,\n # module_dir,auto_downcast = 1)\n func = inline_tools.compile_function(expr_code,arg_names,local_dict, \n global_dict,module_dir,\n compiler='gcc',auto_downcast=1,\n verbose = verbose,\n type_converters = converters.blitz,\n **kw)\n function_catalog.add_function(expr,func,module_dir)\n try: \n results = attempt_function_call(expr,local_dict,global_dict)\n except ValueError: \n print 'warning: compilation failed. Executing as python code'\n exec expr in global_dict, local_dict\n \ndef ast_to_blitz_expr(ast_seq):\n \"\"\" Convert an ast_sequence to a blitz expression.\n \"\"\"\n \n # Don't overwrite orignal sequence in call to transform slices.\n ast_seq = copy.deepcopy(ast_seq) \n slice_handler.transform_slices(ast_seq)\n \n # Build the actual program statement from ast_seq\n expr = ast_tools.ast_to_string(ast_seq)\n \n # Now find and replace specific symbols to convert this to\n # a blitz++ compatible statement.\n # I'm doing this with string replacement here. It could\n # also be done on the actual ast tree (and probably should from\n # a purest standpoint...).\n \n # this one isn't necessary but it helps code readability\n # and compactness. It requires that \n # Range _all = blitz::Range::all();\n # be included in the generated code. \n # These could all alternatively be done to the ast in\n # build_slice_atom()\n expr = string.replace(expr,'slice(_beg,_end)', '_all' ) \n expr = string.replace(expr,'slice', 'blitz::Range' )\n expr = string.replace(expr,'[','(')\n expr = string.replace(expr,']', ')' )\n expr = string.replace(expr,'_stp', '1' )\n \n # Instead of blitz::fromStart and blitz::toEnd. This requires\n # the following in the generated code.\n # Range _beg = blitz::fromStart;\n # Range _end = blitz::toEnd;\n #expr = string.replace(expr,'_beg', 'blitz::fromStart' )\n #expr = string.replace(expr,'_end', 'blitz::toEnd' )\n \n return expr + ';\\n'\n\ndef test_function():\n from code_blocks import module_header\n\n expr = \"ex[:,1:,1:] = k + ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n #ast = parser.suite('a = (b + c) * sin(d)')\n ast = parser.suite(expr)\n k = 1.\n ex = ones((1,1,1),typecode=Float32)\n ca_x = ones((1,1,1),typecode=Float32)\n cb_y_x = ones((1,1,1),typecode=Float32)\n cb_z_x = ones((1,1,1),typecode=Float32)\n hz = ones((1,1,1),typecode=Float32)\n hy = ones((1,1,1),typecode=Float32)\n blitz(expr)\n \"\"\"\n ast_list = ast.tolist()\n \n expr_code = ast_to_blitz_expr(ast_list)\n arg_list = harvest_variables(ast_list)\n arg_specs = assign_variable_types(arg_list,locals())\n \n func,template_types = create_function('test_function',expr_code,arg_list,arg_specs)\n init,used_names = create_module_init('compile_sample','test_function',template_types)\n #wrapper = create_wrapper(mod_name,func_name,used_names)\n return string.join( [module_header,func,init],'\\n')\n \"\"\"\ndef test(level=10):\n from scipy_test import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n test_function()\n", + "source_code_before": "import parser\nimport string\nimport copy\nimport os,sys\nimport ast_tools\nimport token,symbol\nimport slice_handler\nimport size_check\nimport converters\n\nfrom ast_tools import *\n\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from fastumath import *\nexcept:\n pass # fastumath not available \n \nfrom types import *\n\nimport inline_tools\nfrom inline_tools import attempt_function_call\nfunction_catalog = inline_tools.function_catalog\nfunction_cache = inline_tools.function_cache\n \ndef blitz(expr,local_dict=None, global_dict=None,check_size=1,verbose=0,**kw):\n # this could call inline, but making a copy of the\n # code here is more efficient for several reasons.\n global function_catalog\n \n # this grabs the local variables from the *previous* call\n # frame -- that is the locals from the function that called\n # inline.\n call_frame = sys._getframe().f_back\n if local_dict is None:\n local_dict = call_frame.f_locals\n if global_dict is None:\n global_dict = call_frame.f_globals\n\n # 1. Check the sizes of the arrays and make sure they are compatible.\n # This is expensive, so unsetting the check_size flag can save a lot\n # of time. It also can cause core-dumps if the sizes of the inputs \n # aren't compatible. \n if check_size and not size_check.check_expr(expr,local_dict,global_dict):\n raise 'inputs failed to pass size check.'\n \n # 2. try local cache \n try:\n results = apply(function_cache[expr],(local_dict,global_dict))\n return results\n except: \n pass\n try:\n results = attempt_function_call(expr,local_dict,global_dict)\n # 3. build the function \n except ValueError:\n # This section is pretty much the only difference \n # between blitz and inline\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n expr_code = ast_to_blitz_expr(ast_list)\n arg_names = harvest_variables(ast_list)\n module_dir = global_dict.get('__file__',None)\n #func = inline_tools.compile_function(expr_code,arg_names,\n # local_dict,global_dict,\n # module_dir,auto_downcast = 1)\n func = inline_tools.compile_function(expr_code,arg_names,local_dict, \n global_dict,module_dir,\n compiler='gcc',auto_downcast=1,\n verbose = verbose,\n type_converters = converters.blitz,\n **kw)\n function_catalog.add_function(expr,func,module_dir)\n try: \n results = attempt_function_call(expr,local_dict,global_dict)\n except ValueError: \n print 'warning: compilation failed. Executing as python code'\n exec expr in global_dict, local_dict\n \ndef ast_to_blitz_expr(ast_seq):\n \"\"\" Convert an ast_sequence to a blitz expression.\n \"\"\"\n \n # Don't overwrite orignal sequence in call to transform slices.\n ast_seq = copy.deepcopy(ast_seq) \n slice_handler.transform_slices(ast_seq)\n \n # Build the actual program statement from ast_seq\n expr = ast_tools.ast_to_string(ast_seq)\n \n # Now find and replace specific symbols to convert this to\n # a blitz++ compatible statement.\n # I'm doing this with string replacement here. It could\n # also be done on the actual ast tree (and probably should from\n # a purest standpoint...).\n \n # this one isn't necessary but it helps code readability\n # and compactness. It requires that \n # Range _all = blitz::Range::all();\n # be included in the generated code. \n # These could all alternatively be done to the ast in\n # build_slice_atom()\n expr = string.replace(expr,'slice(_beg,_end)', '_all' ) \n expr = string.replace(expr,'slice', 'blitz::Range' )\n expr = string.replace(expr,'[','(')\n expr = string.replace(expr,']', ')' )\n expr = string.replace(expr,'_stp', '1' )\n \n # Instead of blitz::fromStart and blitz::toEnd. This requires\n # the following in the generated code.\n # Range _beg = blitz::fromStart;\n # Range _end = blitz::toEnd;\n #expr = string.replace(expr,'_beg', 'blitz::fromStart' )\n #expr = string.replace(expr,'_end', 'blitz::toEnd' )\n \n return expr + ';\\n'\n\ndef test_function():\n from code_blocks import module_header\n\n expr = \"ex[:,1:,1:] = k + ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n #ast = parser.suite('a = (b + c) * sin(d)')\n ast = parser.suite(expr)\n k = 1.\n ex = ones((1,1,1),typecode=Float32)\n ca_x = ones((1,1,1),typecode=Float32)\n cb_y_x = ones((1,1,1),typecode=Float32)\n cb_z_x = ones((1,1,1),typecode=Float32)\n hz = ones((1,1,1),typecode=Float32)\n hy = ones((1,1,1),typecode=Float32)\n blitz(expr)\n \"\"\"\n ast_list = ast.tolist()\n \n expr_code = ast_to_blitz_expr(ast_list)\n arg_list = harvest_variables(ast_list)\n arg_specs = assign_variable_types(arg_list,locals())\n \n func,template_types = create_function('test_function',expr_code,arg_list,arg_specs)\n init,used_names = create_module_init('compile_sample','test_function',template_types)\n #wrapper = create_wrapper(mod_name,func_name,used_names)\n return string.join( [module_header,func,init],'\\n')\n \"\"\"\ndef test(level=10):\n from scipy_test import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == \"__main__\":\n test_function()", + "methods": [ + { + "name": "blitz", + "long_name": "blitz( expr , local_dict = None , global_dict = None , check_size = 1 , verbose = 0 , ** kw )", + "filename": "blitz_tools.py", + "nloc": 34, + "complexity": 8, + "token_count": 216, + "parameters": [ + "expr", + "local_dict", + "global_dict", + "check_size", + "verbose", + "kw" + ], + "start_line": 27, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "ast_to_blitz_expr", + "long_name": "ast_to_blitz_expr( ast_seq )", + "filename": "blitz_tools.py", + "nloc": 10, + "complexity": 1, + "token_count": 92, + "parameters": [ + "ast_seq" + ], + "start_line": 81, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "test_function", + "long_name": "test_function( )", + "filename": "blitz_tools.py", + "nloc": 26, + "complexity": 1, + "token_count": 128, + "parameters": [], + "start_line": 119, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "blitz_tools.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "level" + ], + "start_line": 147, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "blitz_tools.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "level" + ], + "start_line": 151, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "blitz", + "long_name": "blitz( expr , local_dict = None , global_dict = None , check_size = 1 , verbose = 0 , ** kw )", + "filename": "blitz_tools.py", + "nloc": 34, + "complexity": 8, + "token_count": 216, + "parameters": [ + "expr", + "local_dict", + "global_dict", + "check_size", + "verbose", + "kw" + ], + "start_line": 27, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 53, + "top_nesting_level": 0 + }, + { + "name": "ast_to_blitz_expr", + "long_name": "ast_to_blitz_expr( ast_seq )", + "filename": "blitz_tools.py", + "nloc": 10, + "complexity": 1, + "token_count": 92, + "parameters": [ + "ast_seq" + ], + "start_line": 81, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 37, + "top_nesting_level": 0 + }, + { + "name": "test_function", + "long_name": "test_function( )", + "filename": "blitz_tools.py", + "nloc": 26, + "complexity": 1, + "token_count": 128, + "parameters": [], + "start_line": 119, + "end_line": 146, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "blitz_tools.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "level" + ], + "start_line": 147, + "end_line": 149, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "blitz_tools.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "level" + ], + "start_line": 151, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 98, + "complexity": 12, + "token_count": 553, + "diff_parsed": { + "added": [ + " from scipy_base.fastumath import *", + " test_function()" + ], + "deleted": [ + " from fastumath import *", + " test_function()" + ] + } + }, + { + "old_path": "weave/size_check.py", + "new_path": "weave/size_check.py", + "filename": "size_check.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,7 @@\n \n # The following try/except so that non-SciPy users can still use blitz\n try:\n- from fastumath import *\n+ from scipy_base.fastumath import *\n except:\n pass # fastumath not available \n \n@@ -290,4 +290,4 @@ def test(level=10):\n def test_suite(level=1):\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n- \n\\ No newline at end of file\n+ \n", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "from Numeric import *\n\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # fastumath not available \n\nfrom ast_tools import *\nfrom types import *\nimport sys\n\ndef time_it():\n import time\n \n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\" \\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n ex = ones((10,10,10),typecode=Float32)\n ca_x = ones((10,10,10),typecode=Float32)\n cb_y_x = ones((10,10,10),typecode=Float32)\n cb_z_x = ones((10,10,10),typecode=Float32)\n hz = ones((10,10,10),typecode=Float32)\n hy = ones((10,10,10),typecode=Float32)\n \n N = 1\n t1 = time.time()\n for i in range(N):\n passed = check_expr(expr,locals())\n t2 = time.time()\n print 'time per call:', (t2 - t1)/N\n print 'passed:', passed\n \ndef check_expr(expr,local_vars,global_vars={}):\n \"\"\" Currently only checks expressions (not suites).\n Doesn't check that lhs = rhs. checked by compiled func though\n \"\"\"\n values ={}\n \n #first handle the globals\n for var,val in global_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n #now handle the locals \n for var,val in local_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n exec(expr,values)\n try:\n exec(expr,values)\n except:\n try:\n eval(expr,values)\n except:\n return 0 \n return 1 \n \nempty = array(())\nempty_slice = slice(None)\n\ndef make_same_length(x,y):\n try:\n Nx = len(x)\n except:\n Nx = 0\n try:\n Ny = len(y)\n except:\n Ny = 0\n if Nx == Ny == 0:\n return empty,empty\n elif Nx == Ny:\n return asarray(x),asarray(y)\n else: \n diff = abs(Nx - Ny)\n front = ones(diff,Int)\n if Nx > Ny:\n return asarray(x), concatenate((front,y))\n elif Ny > Nx:\n return concatenate((front,x)),asarray(y) \n\ndef binary_op_size(xx,yy):\n \"\"\" This returns the resulting size from operating on xx, and yy\n with a binary operator. It accounts for broadcasting, and\n throws errors if the array sizes are incompatible.\n \"\"\"\n x,y = make_same_length(xx,yy)\n res = zeros(len(x))\n for i in range(len(x)):\n if x[i] == y[i]:\n res[i] = x[i]\n elif x[i] == 1:\n res[i] = y[i]\n elif y[i] == 1:\n res[i] = x[i]\n else:\n # offer more information here about which variables.\n raise ValueError, \"frames are not aligned\"\n return res \nclass dummy_array:\n def __init__(self,ary,ary_is_shape = 0,name=None):\n self.name = name\n if ary_is_shape:\n self.shape = ary\n #self.shape = asarray(ary)\n else:\n try:\n self.shape = shape(ary)\n except:\n self.shape = empty\n #self.value = ary \n def binary_op(self,other):\n try: \n x = other.shape\n except AttributeError:\n x = empty \n new_shape = binary_op_size(self.shape,x)\n return dummy_array(new_shape,1)\n def __cmp__(self,other):\n # This isn't an exact compare, but does work for == \n # cluge for Numeric\n if type(other) in [IntType,LongType,FloatType,ComplexType]:\n return 0\n if len(self.shape) == len(other.shape) == 0:\n return 0\n return not alltrue(equal(self.shape,other.shape))\n\n def __add__(self,other): return self.binary_op(other)\n def __radd__(self,other): return self.binary_op(other)\n def __sub__(self,other): return self.binary_op(other)\n def __rsub__(self,other): return self.binary_op(other)\n def __mul__(self,other): return self.binary_op(other)\n def __rmul__(self,other): return self.binary_op(other)\n def __div__(self,other): return self.binary_op(other)\n def __rdiv__(self,other): return self.binary_op(other)\n def __mod__(self,other): return self.binary_op(other)\n def __rmod__(self,other): return self.binary_op(other)\n def __lshift__(self,other): return self.binary_op(other)\n def __rshift__(self,other): return self.binary_op(other)\n # unary ops\n def __neg__(self,other): return self\n def __pos__(self,other): return self\n def __abs__(self,other): return self\n def __invert__(self,other): return self \n # Not sure what to do with coersion ops. Ignore for now.\n #\n # not currently supported by compiler.\n # __divmod__\n # __pow__\n # __rpow__\n # __and__\n # __or__\n # __xor__\n # item access and slicing \n def __setitem__(self,indices,val):\n #ignore for now\n pass\n def __len__(self):\n return self.shape[0]\n def __getslice__(self,i,j):\n # enabling the following would make class compatible with\n # lists. Its current incarnation is compatible with arrays.\n # Both this and Numeric should have this FIXED to correspond\n # to lists.\n #i = max(i, 0); j = max(j, 0)\n return self.__getitem__((slice(i,j),))\n def __getitem__(self,indices):\n # ayeyaya this is a mess\n #print indices, type(indices), indices.shape \n if type(indices) is not TupleType:\n indices = (indices,)\n if Ellipsis in indices:\n raise IndexError, \"Ellipsis not currently supported\"\n new_dims = [] \n dim = 0 \n for index in indices:\n try:\n dim_len = self.shape[dim]\n except IndexError:\n raise IndexError, \"To many indices specified\"\n \n #if (type(index) is SliceType and index.start == index.stop == index.step):\n if (index is empty_slice):\n slc_len = dim_len\n elif type(index) is SliceType:\n beg,end,step = index.start,index.stop,index.step \n # handle if they are dummy arrays\n #if hasattr(beg,'value') and type(beg.value) != ArrayType:\n # beg = beg.value\n #if hasattr(end,'value') and type(end.value) != ArrayType:\n # end = end.value\n #if hasattr(step,'value') and type(step.value) != ArrayType:\n # step = step.value \n if beg is None: beg = 0\n if end == sys.maxint or end is None:\n end = dim_len\n if step is None: \n step = 1\n \n if beg < 0: beg += dim_len\n if end < 0: end += dim_len\n # the following is list like behavior,\n # which isn't adhered to by arrays. \n # FIX THIS ANOMOLY IN NUMERIC!\n if beg < 0: beg = 0\n if beg > dim_len: beg = dim_len\n if end < 0: end = 0\n if end > dim_len: end = dim_len\n # This is rubbish. \n if beg == end:\n beg,end,step = 0,0,1\n elif beg >= dim_len and step > 0:\n beg,end,step = 0,0,1\n #elif index.step > 0 and beg <= end:\n elif step > 0 and beg <= end:\n pass #slc_len = abs(divide(end-beg-1,step)+1) \n # handle [::-1] and [-1::-1] correctly \n #elif index.step > 0 and beg > end:\n elif step > 0 and beg > end:\n beg,end,step = 0,0,1\n elif(step < 0 and index.start is None and index.stop is None):\n beg,end,step = 0,dim_len,-step\n elif(step < 0 and index.start is None):\n # +1 because negative stepping is inclusive\n beg,end,step = end+1,dim_len,-step \n elif(step < 0 and index.stop is None):\n beg,end,step = 0,beg+1,-step\n elif(step < 0 and beg > end): \n beg,end,step = end,beg,-step\n elif(step < 0 and beg < end): \n beg,end,step = 0,0,-step\n slc_len = abs(divide(end-beg-1,step)+1)\n new_dims.append(slc_len)\n else:\n if index < 0: index += dim_len\n if index >=0 and index < dim_len:\n #this reduces the array dimensions by one\n pass\n else:\n raise IndexError, \"Index out of range\" \n dim += 1 \n new_dims.extend(self.shape[dim:])\n if 0 in new_dims:\n raise IndexError, \"Zero length slices not currently supported\"\n return dummy_array(new_dims,1)\n def __repr__(self):\n val = str((self.name, str(self.shape)))\n return val \n\ndef unary(ary):\n return ary\n\ndef not_implemented(ary):\n return ary\n \n#all imported from Numeric and need to be reassigned.\nunary_op = [arccos, arcsin, arctan, cos, cosh, sin, sinh, \n exp,ceil,floor,fabs,log,log10,sqrt]\n\nunsupported = [argmin,argmax, argsort,around, absolute,sign,negative,floor]\n\nfor func in unary_op:\n func = unary\n \nfor func in unsupported:\n func = not_implemented\n \ndef reduction(ary,axis=0):\n if axis < 0:\n axis += len(ary.shape) \n if axis < 0 or axis >= len(ary.shape):\n raise ValueError, \"Dimension not in array\" \n new_dims = list(ary.shape[:axis]) + list(ary.shape[axis+1:])\n return dummy_array(new_dims,1) \n\n# functions currently not supported by compiler\n# reductions are gonna take some array reordering for the general case,\n# so this is gonna take some thought (probably some tree manipulation).\ndef take(ary,axis=0): raise NotImplemented\n# and all the rest\n \ndef test(level=10):\n from scipy_test import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n \n", + "source_code_before": "from Numeric import *\n\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from fastumath import *\nexcept:\n pass # fastumath not available \n\nfrom ast_tools import *\nfrom types import *\nimport sys\n\ndef time_it():\n import time\n \n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,1:])\" \\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n ex = ones((10,10,10),typecode=Float32)\n ca_x = ones((10,10,10),typecode=Float32)\n cb_y_x = ones((10,10,10),typecode=Float32)\n cb_z_x = ones((10,10,10),typecode=Float32)\n hz = ones((10,10,10),typecode=Float32)\n hy = ones((10,10,10),typecode=Float32)\n \n N = 1\n t1 = time.time()\n for i in range(N):\n passed = check_expr(expr,locals())\n t2 = time.time()\n print 'time per call:', (t2 - t1)/N\n print 'passed:', passed\n \ndef check_expr(expr,local_vars,global_vars={}):\n \"\"\" Currently only checks expressions (not suites).\n Doesn't check that lhs = rhs. checked by compiled func though\n \"\"\"\n values ={}\n \n #first handle the globals\n for var,val in global_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n #now handle the locals \n for var,val in local_vars.items():\n if type(val) in [ArrayType]: \n values[var] = dummy_array(val,name=var)\n elif type(val) in [IntType,LongType,FloatType,ComplexType]: \n values[var] = val\n exec(expr,values)\n try:\n exec(expr,values)\n except:\n try:\n eval(expr,values)\n except:\n return 0 \n return 1 \n \nempty = array(())\nempty_slice = slice(None)\n\ndef make_same_length(x,y):\n try:\n Nx = len(x)\n except:\n Nx = 0\n try:\n Ny = len(y)\n except:\n Ny = 0\n if Nx == Ny == 0:\n return empty,empty\n elif Nx == Ny:\n return asarray(x),asarray(y)\n else: \n diff = abs(Nx - Ny)\n front = ones(diff,Int)\n if Nx > Ny:\n return asarray(x), concatenate((front,y))\n elif Ny > Nx:\n return concatenate((front,x)),asarray(y) \n\ndef binary_op_size(xx,yy):\n \"\"\" This returns the resulting size from operating on xx, and yy\n with a binary operator. It accounts for broadcasting, and\n throws errors if the array sizes are incompatible.\n \"\"\"\n x,y = make_same_length(xx,yy)\n res = zeros(len(x))\n for i in range(len(x)):\n if x[i] == y[i]:\n res[i] = x[i]\n elif x[i] == 1:\n res[i] = y[i]\n elif y[i] == 1:\n res[i] = x[i]\n else:\n # offer more information here about which variables.\n raise ValueError, \"frames are not aligned\"\n return res \nclass dummy_array:\n def __init__(self,ary,ary_is_shape = 0,name=None):\n self.name = name\n if ary_is_shape:\n self.shape = ary\n #self.shape = asarray(ary)\n else:\n try:\n self.shape = shape(ary)\n except:\n self.shape = empty\n #self.value = ary \n def binary_op(self,other):\n try: \n x = other.shape\n except AttributeError:\n x = empty \n new_shape = binary_op_size(self.shape,x)\n return dummy_array(new_shape,1)\n def __cmp__(self,other):\n # This isn't an exact compare, but does work for == \n # cluge for Numeric\n if type(other) in [IntType,LongType,FloatType,ComplexType]:\n return 0\n if len(self.shape) == len(other.shape) == 0:\n return 0\n return not alltrue(equal(self.shape,other.shape))\n\n def __add__(self,other): return self.binary_op(other)\n def __radd__(self,other): return self.binary_op(other)\n def __sub__(self,other): return self.binary_op(other)\n def __rsub__(self,other): return self.binary_op(other)\n def __mul__(self,other): return self.binary_op(other)\n def __rmul__(self,other): return self.binary_op(other)\n def __div__(self,other): return self.binary_op(other)\n def __rdiv__(self,other): return self.binary_op(other)\n def __mod__(self,other): return self.binary_op(other)\n def __rmod__(self,other): return self.binary_op(other)\n def __lshift__(self,other): return self.binary_op(other)\n def __rshift__(self,other): return self.binary_op(other)\n # unary ops\n def __neg__(self,other): return self\n def __pos__(self,other): return self\n def __abs__(self,other): return self\n def __invert__(self,other): return self \n # Not sure what to do with coersion ops. Ignore for now.\n #\n # not currently supported by compiler.\n # __divmod__\n # __pow__\n # __rpow__\n # __and__\n # __or__\n # __xor__\n # item access and slicing \n def __setitem__(self,indices,val):\n #ignore for now\n pass\n def __len__(self):\n return self.shape[0]\n def __getslice__(self,i,j):\n # enabling the following would make class compatible with\n # lists. Its current incarnation is compatible with arrays.\n # Both this and Numeric should have this FIXED to correspond\n # to lists.\n #i = max(i, 0); j = max(j, 0)\n return self.__getitem__((slice(i,j),))\n def __getitem__(self,indices):\n # ayeyaya this is a mess\n #print indices, type(indices), indices.shape \n if type(indices) is not TupleType:\n indices = (indices,)\n if Ellipsis in indices:\n raise IndexError, \"Ellipsis not currently supported\"\n new_dims = [] \n dim = 0 \n for index in indices:\n try:\n dim_len = self.shape[dim]\n except IndexError:\n raise IndexError, \"To many indices specified\"\n \n #if (type(index) is SliceType and index.start == index.stop == index.step):\n if (index is empty_slice):\n slc_len = dim_len\n elif type(index) is SliceType:\n beg,end,step = index.start,index.stop,index.step \n # handle if they are dummy arrays\n #if hasattr(beg,'value') and type(beg.value) != ArrayType:\n # beg = beg.value\n #if hasattr(end,'value') and type(end.value) != ArrayType:\n # end = end.value\n #if hasattr(step,'value') and type(step.value) != ArrayType:\n # step = step.value \n if beg is None: beg = 0\n if end == sys.maxint or end is None:\n end = dim_len\n if step is None: \n step = 1\n \n if beg < 0: beg += dim_len\n if end < 0: end += dim_len\n # the following is list like behavior,\n # which isn't adhered to by arrays. \n # FIX THIS ANOMOLY IN NUMERIC!\n if beg < 0: beg = 0\n if beg > dim_len: beg = dim_len\n if end < 0: end = 0\n if end > dim_len: end = dim_len\n # This is rubbish. \n if beg == end:\n beg,end,step = 0,0,1\n elif beg >= dim_len and step > 0:\n beg,end,step = 0,0,1\n #elif index.step > 0 and beg <= end:\n elif step > 0 and beg <= end:\n pass #slc_len = abs(divide(end-beg-1,step)+1) \n # handle [::-1] and [-1::-1] correctly \n #elif index.step > 0 and beg > end:\n elif step > 0 and beg > end:\n beg,end,step = 0,0,1\n elif(step < 0 and index.start is None and index.stop is None):\n beg,end,step = 0,dim_len,-step\n elif(step < 0 and index.start is None):\n # +1 because negative stepping is inclusive\n beg,end,step = end+1,dim_len,-step \n elif(step < 0 and index.stop is None):\n beg,end,step = 0,beg+1,-step\n elif(step < 0 and beg > end): \n beg,end,step = end,beg,-step\n elif(step < 0 and beg < end): \n beg,end,step = 0,0,-step\n slc_len = abs(divide(end-beg-1,step)+1)\n new_dims.append(slc_len)\n else:\n if index < 0: index += dim_len\n if index >=0 and index < dim_len:\n #this reduces the array dimensions by one\n pass\n else:\n raise IndexError, \"Index out of range\" \n dim += 1 \n new_dims.extend(self.shape[dim:])\n if 0 in new_dims:\n raise IndexError, \"Zero length slices not currently supported\"\n return dummy_array(new_dims,1)\n def __repr__(self):\n val = str((self.name, str(self.shape)))\n return val \n\ndef unary(ary):\n return ary\n\ndef not_implemented(ary):\n return ary\n \n#all imported from Numeric and need to be reassigned.\nunary_op = [arccos, arcsin, arctan, cos, cosh, sin, sinh, \n exp,ceil,floor,fabs,log,log10,sqrt]\n\nunsupported = [argmin,argmax, argsort,around, absolute,sign,negative,floor]\n\nfor func in unary_op:\n func = unary\n \nfor func in unsupported:\n func = not_implemented\n \ndef reduction(ary,axis=0):\n if axis < 0:\n axis += len(ary.shape) \n if axis < 0 or axis >= len(ary.shape):\n raise ValueError, \"Dimension not in array\" \n new_dims = list(ary.shape[:axis]) + list(ary.shape[axis+1:])\n return dummy_array(new_dims,1) \n\n# functions currently not supported by compiler\n# reductions are gonna take some array reordering for the general case,\n# so this is gonna take some thought (probably some tree manipulation).\ndef take(ary,axis=0): raise NotImplemented\n# and all the rest\n \ndef test(level=10):\n from scipy_test import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n ", + "methods": [ + { + "name": "time_it", + "long_name": "time_it( )", + "filename": "size_check.py", + "nloc": 18, + "complexity": 2, + "token_count": 158, + "parameters": [], + "start_line": 13, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "check_expr", + "long_name": "check_expr( expr , local_vars , global_vars = { } )", + "filename": "size_check.py", + "nloc": 21, + "complexity": 9, + "token_count": 159, + "parameters": [ + "expr", + "local_vars", + "global_vars" + ], + "start_line": 34, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "make_same_length", + "long_name": "make_same_length( x , y )", + "filename": "size_check.py", + "nloc": 20, + "complexity": 7, + "token_count": 115, + "parameters": [ + "x", + "y" + ], + "start_line": 65, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "binary_op_size", + "long_name": "binary_op_size( xx , yy )", + "filename": "size_check.py", + "nloc": 13, + "complexity": 5, + "token_count": 100, + "parameters": [ + "xx", + "yy" + ], + "start_line": 86, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , ary , ary_is_shape = 0 , name = None )", + "filename": "size_check.py", + "nloc": 9, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "ary", + "ary_is_shape", + "name" + ], + "start_line": 105, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "binary_op", + "long_name": "binary_op( self , other )", + "filename": "size_check.py", + "nloc": 7, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 116, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__cmp__", + "long_name": "__cmp__( self , other )", + "filename": "size_check.py", + "nloc": 6, + "complexity": 3, + "token_count": 59, + "parameters": [ + "self", + "other" + ], + "start_line": 123, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , indices , val )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "indices", + "val" + ], + "start_line": 159, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 162, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 164, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , indices )", + "filename": "size_check.py", + "nloc": 58, + "complexity": 39, + "token_count": 450, + "parameters": [ + "self", + "indices" + ], + "start_line": 171, + "end_line": 249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 250, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "unary", + "long_name": "unary( ary )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "ary" + ], + "start_line": 254, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "not_implemented", + "long_name": "not_implemented( ary )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "ary" + ], + "start_line": 257, + "end_line": 258, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "reduction", + "long_name": "reduction( ary , axis = 0 )", + "filename": "size_check.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "ary", + "axis" + ], + "start_line": 272, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "level" + ], + "start_line": 286, + "end_line": 288, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "level" + ], + "start_line": 290, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "time_it", + "long_name": "time_it( )", + "filename": "size_check.py", + "nloc": 18, + "complexity": 2, + "token_count": 158, + "parameters": [], + "start_line": 13, + "end_line": 32, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "check_expr", + "long_name": "check_expr( expr , local_vars , global_vars = { } )", + "filename": "size_check.py", + "nloc": 21, + "complexity": 9, + "token_count": 159, + "parameters": [ + "expr", + "local_vars", + "global_vars" + ], + "start_line": 34, + "end_line": 60, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "make_same_length", + "long_name": "make_same_length( x , y )", + "filename": "size_check.py", + "nloc": 20, + "complexity": 7, + "token_count": 115, + "parameters": [ + "x", + "y" + ], + "start_line": 65, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "binary_op_size", + "long_name": "binary_op_size( xx , yy )", + "filename": "size_check.py", + "nloc": 13, + "complexity": 5, + "token_count": 100, + "parameters": [ + "xx", + "yy" + ], + "start_line": 86, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , ary , ary_is_shape = 0 , name = None )", + "filename": "size_check.py", + "nloc": 9, + "complexity": 3, + "token_count": 47, + "parameters": [ + "self", + "ary", + "ary_is_shape", + "name" + ], + "start_line": 105, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "binary_op", + "long_name": "binary_op( self , other )", + "filename": "size_check.py", + "nloc": 7, + "complexity": 2, + "token_count": 37, + "parameters": [ + "self", + "other" + ], + "start_line": 116, + "end_line": 122, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__cmp__", + "long_name": "__cmp__( self , other )", + "filename": "size_check.py", + "nloc": 6, + "complexity": 3, + "token_count": 59, + "parameters": [ + "self", + "other" + ], + "start_line": 123, + "end_line": 130, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "__setitem__", + "long_name": "__setitem__( self , indices , val )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 10, + "parameters": [ + "self", + "indices", + "val" + ], + "start_line": 159, + "end_line": 161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self" + ], + "start_line": 162, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 164, + "end_line": 170, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , indices )", + "filename": "size_check.py", + "nloc": 58, + "complexity": 39, + "token_count": 450, + "parameters": [ + "self", + "indices" + ], + "start_line": 171, + "end_line": 249, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 79, + "top_nesting_level": 1 + }, + { + "name": "__repr__", + "long_name": "__repr__( self )", + "filename": "size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 250, + "end_line": 252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "unary", + "long_name": "unary( ary )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "ary" + ], + "start_line": 254, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "not_implemented", + "long_name": "not_implemented( ary )", + "filename": "size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "ary" + ], + "start_line": 257, + "end_line": 258, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "reduction", + "long_name": "reduction( ary , axis = 0 )", + "filename": "size_check.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "ary", + "axis" + ], + "start_line": 272, + "end_line": 278, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "level" + ], + "start_line": 286, + "end_line": 288, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "level" + ], + "start_line": 290, + "end_line": 292, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 213, + "complexity": 82, + "token_count": 1680, + "diff_parsed": { + "added": [ + " from scipy_base.fastumath import *", + "" + ], + "deleted": [ + " from fastumath import *", + "" + ] + } + }, + { + "old_path": "weave/tests/test_ast_tools.py", + "new_path": "weave/tests/test_ast_tools.py", + "filename": "test_ast_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,7 @@\n from Numeric import *\n # The following try/except so that non-SciPy users can still use blitz\n try:\n- from fastumath import *\n+ from scipy_base.fastumath import *\n except:\n pass # fastumath not available \n import RandomArray\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ast_tools\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_harvest_variables(unittest.TestCase):\n \"\"\" Not much testing going on here, but \n at least it is a flame test.\n \"\"\" \n def generic_test(self,expr,desired):\n import parser\n ast_list = parser.suite(expr).tolist()\n actual = ast_tools.harvest_variables(ast_list)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = ['a','b','i'] \n self.generic_test(expr,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_harvest_variables,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "source_code_before": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from fastumath import *\nexcept:\n pass # fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport ast_tools\nrestore_path()\n\nadd_local_to_path(__name__)\nfrom weave_test_utils import *\nrestore_path()\n\nclass test_harvest_variables(unittest.TestCase):\n \"\"\" Not much testing going on here, but \n at least it is a flame test.\n \"\"\" \n def generic_test(self,expr,desired):\n import parser\n ast_list = parser.suite(expr).tolist()\n actual = ast_tools.harvest_variables(ast_list)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = ['a','b','i'] \n self.generic_test(expr,desired)\n\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_harvest_variables,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "methods": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_ast_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_ast_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_ast_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "level" + ], + "start_line": 42, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_ast_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 49, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_ast_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_ast_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 32, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_ast_tools.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "level" + ], + "start_line": 42, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_ast_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 49, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 42, + "complexity": 5, + "token_count": 208, + "diff_parsed": { + "added": [ + " from scipy_base.fastumath import *" + ], + "deleted": [ + " from fastumath import *" + ] + } + }, + { + "old_path": "weave/tests/test_blitz_tools.py", + "new_path": "weave/tests/test_blitz_tools.py", + "filename": "test_blitz_tools.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,7 @@\n from Numeric import *\n # The following try/except so that non-SciPy users can still use blitz\n try:\n- from fastumath import *\n+ from scipy_base.fastumath import *\n except:\n pass # fastumath not available \n import RandomArray\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # fastumath not available \nimport RandomArray\nimport os\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport blitz_tools\nfrom ast_tools import *\nfrom weave_test_utils import *\nrestore_path()\n\nadd_local_to_path(__name__)\nimport test_scalar_spec\nrestore_path()\n\nclass test_ast_to_blitz_expr(unittest.TestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,_Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,_Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(unittest.TestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_types = [Float32,Float64,Complex32,Complex64]\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for typ in all_types:\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_ast_to_blitz_expr,'check_') )\n if level >= 10:\n suites.append( unittest.makeSuite(test_blitz,'check_') ) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "source_code_before": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from fastumath import *\nexcept:\n pass # fastumath not available \nimport RandomArray\nimport os\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path,restore_path\nfrom scipy_distutils.misc_util import add_local_to_path\n\nadd_grandparent_to_path(__name__)\nimport blitz_tools\nfrom ast_tools import *\nfrom weave_test_utils import *\nrestore_path()\n\nadd_local_to_path(__name__)\nimport test_scalar_spec\nrestore_path()\n\nclass test_ast_to_blitz_expr(unittest.TestCase):\n\n def generic_test(self,expr,desired):\n import parser\n ast = parser.suite(expr)\n ast_list = ast.tolist()\n actual = blitz_tools.ast_to_blitz_expr(ast_list)\n actual = remove_whitespace(actual)\n desired = remove_whitespace(desired)\n print_assert_equal(expr,actual,desired)\n\n def check_simple_expr(self):\n \"\"\"convert simple expr to blitz\n \n a[:1:2] = b[:1+i+2:]\n \"\"\"\n expr = \"a[:1:2] = b[:1+i+2:]\" \n desired = \"a(blitz::Range(_beg,1-1,2))=\"\\\n \"b(blitz::Range(_beg,1+i+2-1));\"\n self.generic_test(expr,desired)\n\n def check_fdtd_expr(self):\n \"\"\" convert fdtd equation to blitz.\n ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:] \n + cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\n - cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1]);\n Note: This really should have \"\\\" at the end of each line\n to indicate continuation. \n \"\"\"\n expr = \"ex[:,1:,1:] = ca_x[:,1:,1:] * ex[:,1:,1:]\" \\\n \"+ cb_y_x[:,1:,1:] * (hz[:,1:,1:] - hz[:,:-1,:])\"\\\n \"- cb_z_x[:,1:,1:] * (hy[:,1:,1:] - hy[:,1:,:-1])\" \n desired = 'ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))='\\\n ' ca_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' *ex(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '+cb_y_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hz(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n ' -hz(_all,blitz::Range(_beg,_Nhz(1)-1-1),_all))'\\\n ' -cb_z_x(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '*(hy(_all,blitz::Range(1,_end),blitz::Range(1,_end))'\\\n '-hy(_all,blitz::Range(1,_end),blitz::Range(_beg,_Nhy(2)-1-1)));'\n self.generic_test(expr,desired)\n\nclass test_blitz(unittest.TestCase):\n \"\"\"* These are long running tests...\n \n I'd like to benchmark these things somehow.\n *\"\"\"\n def generic_test(self,expr,arg_dict,type,size,mod_location):\n clean_result = array(arg_dict['result'],copy=1)\n t1 = time.time()\n exec expr in globals(),arg_dict\n t2 = time.time()\n standard = t2 - t1\n desired = arg_dict['result']\n arg_dict['result'] = clean_result\n t1 = time.time()\n old_env = os.environ.get('PYTHONCOMPILED','')\n os.environ['PYTHONCOMPILED'] = mod_location\n blitz_tools.blitz(expr,arg_dict,{},verbose=0) #,\n #extra_compile_args = ['-O3','-malign-double','-funroll-loops'])\n os.environ['PYTHONCOMPILED'] = old_env\n t2 = time.time()\n compiled = t2 - t1\n actual = arg_dict['result']\n # this really should give more info...\n try:\n # this isn't very stringent. Need to tighten this up and\n # learn where failures are occuring.\n assert(allclose(abs(actual.flat),abs(desired.flat),1e-4,1e-6))\n except:\n diff = actual-desired\n print diff[:4,:4]\n print diff[:4,-4:]\n print diff[-4:,:4]\n print diff[-4:,-4:]\n print sum(abs(diff.flat)) \n raise AssertionError \n return standard,compiled\n \n def generic_2d(self,expr):\n \"\"\" The complex testing is pretty lame...\n \"\"\"\n mod_location = empty_temp_dir()\n import parser\n ast = parser.suite(expr)\n arg_list = harvest_variables(ast.tolist())\n #print arg_list\n all_types = [Float32,Float64,Complex32,Complex64]\n all_sizes = [(10,10), (50,50), (100,100), (500,500), (1000,1000)]\n print '\\nExpression:', expr\n for typ in all_types:\n for size in all_sizes:\n result = zeros(size,typ)\n arg_dict = {}\n for arg in arg_list:\n arg_dict[arg] = RandomArray.normal(0,1,size).astype(typ)\n arg_dict[arg].savespace(1)\n # set imag part of complex values to non-zero value\n try: arg_dict[arg].imag = arg_dict[arg].real\n except: pass \n print 'Run:', size,typ\n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1.\n print \"1st run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up) \n standard,compiled = self.generic_test(expr,arg_dict,type,size,\n mod_location)\n try:\n speed_up = standard/compiled\n except:\n speed_up = -1. \n print \"2nd run(Numeric,compiled,speed up): %3.4f, %3.4f, \" \\\n \"%3.4f\" % (standard,compiled,speed_up)\n cleanup_temp_dir(mod_location) \n #def check_simple_2d(self):\n # \"\"\" result = a + b\"\"\" \n # expr = \"result = a + b\"\n # self.generic_2d(expr)\n def check_5point_avg_2d(self):\n \"\"\" result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\n + b[1:-1,2:] + b[1:-1,:-2]) / 5.\n \"\"\" \n expr = \"result[1:-1,1:-1] = (b[1:-1,1:-1] + b[2:,1:-1] + b[:-2,1:-1]\" \\\n \"+ b[1:-1,2:] + b[1:-1,:-2]) / 5.\"\n self.generic_2d(expr)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_ast_to_blitz_expr,'check_') )\n if level >= 10:\n suites.append( unittest.makeSuite(test_blitz,'check_') ) \n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "methods": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_blitz_tools.py", + "nloc": 8, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 27, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_fdtd_expr", + "long_name": "check_fdtd_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 46, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", + "filename": "test_blitz_tools.py", + "nloc": 27, + "complexity": 2, + "token_count": 227, + "parameters": [ + "self", + "expr", + "arg_dict", + "type", + "size", + "mod_location" + ], + "start_line": 73, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_blitz_tools.py", + "nloc": 35, + "complexity": 7, + "token_count": 253, + "parameters": [ + "self", + "expr" + ], + "start_line": 105, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d", + "long_name": "check_5point_avg_2d( self )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_blitz_tools.py", + "nloc": 8, + "complexity": 3, + "token_count": 57, + "parameters": [ + "level" + ], + "start_line": 156, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 165, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired )", + "filename": "test_blitz_tools.py", + "nloc": 8, + "complexity": 1, + "token_count": 54, + "parameters": [ + "self", + "expr", + "desired" + ], + "start_line": 27, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_simple_expr", + "long_name": "check_simple_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 36, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_fdtd_expr", + "long_name": "check_fdtd_expr( self )", + "filename": "test_blitz_tools.py", + "nloc": 14, + "complexity": 1, + "token_count": 40, + "parameters": [ + "self" + ], + "start_line": 46, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , arg_dict , type , size , mod_location )", + "filename": "test_blitz_tools.py", + "nloc": 27, + "complexity": 2, + "token_count": 227, + "parameters": [ + "self", + "expr", + "arg_dict", + "type", + "size", + "mod_location" + ], + "start_line": 73, + "end_line": 103, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_blitz_tools.py", + "nloc": 35, + "complexity": 7, + "token_count": 253, + "parameters": [ + "self", + "expr" + ], + "start_line": 105, + "end_line": 143, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 1 + }, + { + "name": "check_5point_avg_2d", + "long_name": "check_5point_avg_2d( self )", + "filename": "test_blitz_tools.py", + "nloc": 4, + "complexity": 1, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 148, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_blitz_tools.py", + "nloc": 8, + "complexity": 3, + "token_count": 57, + "parameters": [ + "level" + ], + "start_line": 156, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_blitz_tools.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 165, + "end_line": 169, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 133, + "complexity": 17, + "token_count": 794, + "diff_parsed": { + "added": [ + " from scipy_base.fastumath import *" + ], + "deleted": [ + " from fastumath import *" + ] + } + }, + { + "old_path": "weave/tests/test_size_check.py", + "new_path": "weave/tests/test_size_check.py", + "filename": "test_size_check.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,7 @@\n from Numeric import *\n # The following try/except so that non-SciPy users can still use blitz\n try:\n- from fastumath import *\n+ from scipy_base.fastumath import *\n except:\n pass # fastumath not available \n \n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "import unittest, os\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # fastumath not available \n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport size_check\nfrom ast_tools import *\nrestore_path()\n\nempty = array(())\n \ndef array_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired)))\n except AssertionError:\n try:\n # kluge for bug in Numeric\n assert (len(actual[0]) == len(actual[1]) == \n len(desired[0]) == len(desired[1]) == 0)\n except: \n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_make_same_length(unittest.TestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(unittest.TestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(unittest.TestCase):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.array_assert_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to Numeric.array\n # on wrapping of indices.\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self): \n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n\n def check_2d_0(self):\n self.generic_2d('a[:]')\n def check_2d_1(self):\n self.generic_2d('a[:2]')\n def check_2d_2(self):\n self.generic_2d('a[:,:]')\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n beg2 = whrandom.choice(choices)\n end2 = whrandom.choice(choices)\n step2 = whrandom.choice(choices) \n expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)\n self.generic_2d(expr) \n except IndexError:\n pass\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n idx = []\n for i in range(9):\n idx.append(whrandom.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(unittest.TestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(unittest.TestCase): \n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.array_assert_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_make_same_length,'check_') )\n suites.append( unittest.makeSuite(test_binary_op_size,'check_') )\n suites.append( unittest.makeSuite(test_dummy_array,'check_') )\n suites.append( unittest.makeSuite(test_dummy_array_indexing,'check_') )\n suites.append( unittest.makeSuite(test_reduction,'check_') )\n suites.append( unittest.makeSuite(test_expressions,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "source_code_before": "import unittest, os\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from fastumath import *\nexcept:\n pass # fastumath not available \n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport size_check\nfrom ast_tools import *\nrestore_path()\n\nempty = array(())\n \ndef array_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired)))\n except AssertionError:\n try:\n # kluge for bug in Numeric\n assert (len(actual[0]) == len(actual[1]) == \n len(desired[0]) == len(desired[1]) == 0)\n except: \n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_make_same_length(unittest.TestCase):\n\n def generic_test(self,x,y,desired):\n actual = size_check.make_same_length(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n\n def check_scalar(self):\n x,y = (),()\n desired = empty,empty \n self.generic_test(x,y,desired)\n def check_x_scalar(self):\n x,y = (),(1,2)\n desired = array((1,1)),array((1,2))\n self.generic_test(x,y,desired)\n def check_y_scalar(self):\n x,y = (1,2),()\n desired = array((1,2)),array((1,1))\n self.generic_test(x,y,desired)\n def check_x_short(self):\n x,y = (1,2),(1,2,3)\n desired = array((1,1,2)),array((1,2,3))\n self.generic_test(x,y,desired)\n def check_y_short(self):\n x,y = (1,2,3),(1,2)\n desired = array((1,2,3)),array((1,1,2))\n self.generic_test(x,y,desired)\n\nclass test_binary_op_size(unittest.TestCase):\n def generic_test(self,x,y,desired):\n actual = size_check.binary_op_size(x,y)\n desired = desired\n array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n actual = size_check.binary_op_size(x,y)\n #print actual\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return array(val) \n def check_scalar(self):\n x,y = (),()\n desired = self.desired_type(())\n self.generic_test(x,y,desired)\n def check_x1(self):\n x,y = (1,),()\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_y1(self):\n x,y = (),(1,)\n desired = self.desired_type((1,))\n self.generic_test(x,y,desired)\n def check_x_y(self):\n x,y = (5,),(5,)\n desired = self.desired_type((5,))\n self.generic_test(x,y,desired)\n def check_x_y2(self):\n x,y = (5,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y3(self):\n x,y = (5,10),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y4(self):\n x,y = (1,10),(5,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y5(self):\n x,y = (5,1),(1,10)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y6(self):\n x,y = (1,10),(5,1)\n desired = self.desired_type((5,10))\n self.generic_test(x,y,desired)\n def check_x_y7(self):\n x,y = (5,4,3,2,1),(3,2,1)\n desired = self.desired_type((5,4,3,2,1))\n self.generic_test(x,y,desired)\n \n def check_error1(self):\n x,y = (5,),(4,)\n self.generic_error_test(x,y)\n def check_error2(self):\n x,y = (5,5),(4,5)\n self.generic_error_test(x,y)\n\nclass test_dummy_array(test_binary_op_size):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue() \n def generic_test(self,x,y,desired):\n if type(x) is type(()):\n x = ones(x)\n if type(y) is type(()):\n y = ones(y)\n xx = size_check.dummy_array(x)\n yy = size_check.dummy_array(y)\n ops = ['+', '-', '/', '*', '<<', '>>']\n for op in ops:\n actual = eval('xx' + op + 'yy')\n desired = desired\n self.array_assert_equal('',actual,desired)\n def generic_error_test(self,x,y):\n try:\n self.generic_test('',x,y)\n raise AttributeError, \"Should have raised ValueError\"\n except ValueError:\n pass \n def desired_type(self,val):\n return size_check.dummy_array(array(val),1)\n\nclass test_dummy_array_indexing(unittest.TestCase):\n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,ary,expr,desired):\n a = size_check.dummy_array(ary)\n actual = eval(expr).shape \n #print desired, actual\n self.array_assert_equal(expr,actual,desired)\n def generic_wrap(self,a,expr):\n #print expr ,eval(expr)\n desired = array(eval(expr).shape)\n try:\n self.generic_test(a,expr,desired)\n except IndexError:\n if 0 not in desired:\n msg = '%s raised IndexError in dummy_array, but forms\\n' \\\n 'valid array shape -> %s' % (expr, str(desired))\n raise AttributeError, msg \n def generic_1d(self,expr):\n a = arange(10)\n self.generic_wrap(a,expr)\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \n def generic_1d_index(self,expr):\n a = arange(10)\n #print expr ,eval(expr)\n desired = array(())\n self.generic_test(a,expr,desired)\n def check_1d_index_0(self):\n self.generic_1d_index('a[0]')\n def check_1d_index_1(self):\n self.generic_1d_index('a[4]')\n def check_1d_index_2(self):\n self.generic_1d_index('a[-4]')\n def check_1d_index_3(self):\n try: self.generic_1d('a[12]')\n except IndexError: pass \n def check_1d_index_calculated(self):\n self.generic_1d_index('a[0+1]')\n def check_1d_0(self):\n self.generic_1d('a[:]')\n def check_1d_1(self): \n self.generic_1d('a[1:]')\n def check_1d_2(self): \n self.generic_1d('a[-1:]')\n def check_1d_3(self):\n # dummy_array is \"bug for bug\" equiv to Numeric.array\n # on wrapping of indices.\n self.generic_1d('a[-11:]')\n def check_1d_4(self): \n self.generic_1d('a[:1]')\n def check_1d_5(self): \n self.generic_1d('a[:-1]')\n def check_1d_6(self): \n self.generic_1d('a[:-11]')\n def check_1d_7(self): \n self.generic_1d('a[1:5]')\n def check_1d_8(self): \n self.generic_1d('a[1:-5]')\n def check_1d_9(self):\n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[-1:-5]')\n except IndexError: pass \n def check_1d_10(self): \n self.generic_1d('a[-5:-1]')\n \n def check_1d_stride_0(self): \n self.generic_1d('a[::1]') \n def check_1d_stride_1(self): \n self.generic_1d('a[::-1]') \n def check_1d_stride_2(self): \n self.generic_1d('a[1::1]') \n def check_1d_stride_3(self): \n self.generic_1d('a[1::-1]') \n def check_1d_stride_4(self): \n # don't support zero length slicing at the moment.\n try: self.generic_1d('a[1:5:-1]') \n except IndexError: pass \n def check_1d_stride_5(self): \n self.generic_1d('a[5:1:-1]') \n def check_1d_stride_6(self): \n self.generic_1d('a[:4:1]') \n def check_1d_stride_7(self): \n self.generic_1d('a[:4:-1]') \n def check_1d_stride_8(self): \n self.generic_1d('a[:-4:1]') \n def check_1d_stride_9(self): \n self.generic_1d('a[:-4:-1]') \n def check_1d_stride_10(self): \n self.generic_1d('a[:-3:2]') \n def check_1d_stride_11(self): \n self.generic_1d('a[:-3:-2]') \n def check_1d_stride_12(self): \n self.generic_1d('a[:-3:-7]') \n def check_1d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50\n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n self.generic_1d('a[%s:%s:%s]' %(beg,end,step)) \n except IndexError:\n pass\n\n def check_2d_0(self):\n self.generic_2d('a[:]')\n def check_2d_1(self):\n self.generic_2d('a[:2]')\n def check_2d_2(self):\n self.generic_2d('a[:,:]')\n def check_2d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n beg = whrandom.choice(choices)\n end = whrandom.choice(choices)\n step = whrandom.choice(choices) \n beg2 = whrandom.choice(choices)\n end2 = whrandom.choice(choices)\n step2 = whrandom.choice(choices) \n expr = 'a[%s:%s:%s,%s:%s:%s]' %(beg,end,step,beg2,end2,step2)\n self.generic_2d(expr) \n except IndexError:\n pass\n def check_3d_random(self):\n \"\"\" through a bunch of different indexes at it for good measure.\n \"\"\"\n import whrandom\n choices = map(lambda x: `x`,range(50)) + range(50) + ['']*50 \n for i in range(100):\n try:\n idx = []\n for i in range(9):\n idx.append(whrandom.choice(choices))\n expr = 'a[%s:%s:%s,%s:%s:%s,%s:%s:%s]' % tuple(idx)\n self.generic_3d(expr) \n except IndexError:\n pass\n\nclass test_reduction(unittest.TestCase):\n def check_1d_0(self):\n a = ones((5,))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_0(self):\n a = ones((5,10))\n actual = size_check.reduction(a,0)\n desired = size_check.dummy_array((10,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_2d_1(self):\n a = ones((5,10))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_3d_0(self):\n a = ones((5,6,7))\n actual = size_check.reduction(a,1)\n desired = size_check.dummy_array((5,7),1)\n array_assert_equal('',actual.shape,desired.shape) \n def check_error0(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,-2)\n except ValueError:\n pass \n def check_error1(self):\n a = ones((5,))\n try:\n actual = size_check.reduction(a,1)\n except ValueError:\n pass \n\nclass test_expressions(unittest.TestCase): \n def array_assert_equal(self,test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint \n try:\n assert(alltrue(equal(actual,desired))) \n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n def generic_test(self,expr,desired,**kw):\n import parser\n ast_list = parser.expr(expr).tolist()\n args = harvest_variables(ast_list)\n loc = locals().update(kw)\n for var in args:\n s='%s = size_check.dummy_array(%s)'% (var,var)\n exec(s,loc)\n try: \n actual = eval(expr,locals()).shape \n except:\n actual = 'failed' \n if actual is 'failed' and desired is 'failed':\n return\n try: \n self.array_assert_equal(expr,actual,desired)\n except:\n print 'EXPR:',expr\n print 'ACTUAL:',actual\n print 'DEISRED:',desired\n def generic_wrap(self,expr,**kw):\n try:\n x = array(eval(expr,kw))\n try:\n desired = x.shape\n except:\n desired = zeros(())\n except:\n desired = 'failed'\n self.generic_test(expr,desired,**kw)\n def check_generic_1d(self):\n a = arange(10) \n expr = 'a[:]' \n self.generic_wrap(expr,a=a)\n expr = 'a[:] + a' \n self.generic_wrap(expr,a=a)\n bad_expr = 'a[4:] + a' \n self.generic_wrap(bad_expr,a=a)\n a = arange(10) \n b = ones((1,10))\n expr = 'a + b' \n self.generic_wrap(expr,a=a,b=b)\n bad_expr = 'a[:5] + b' \n self.generic_wrap(bad_expr,a=a,b=b)\n def check_single_index(self): \n a = arange(10) \n expr = 'a[5] + a[3]' \n self.generic_wrap(expr,a=a)\n \n def check_calculated_index(self): \n a = arange(10) \n nx = 0\n expr = 'a[5] + a[nx+3]' \n size_check.check_expr(expr,locals())\n def check_calculated_index2(self): \n a = arange(10) \n nx = 0\n expr = 'a[1:5] + a[nx+1:5+nx]' \n size_check.check_expr(expr,locals())\n def generic_2d(self,expr):\n a = ones((10,20))\n self.generic_wrap(a,expr)\n def generic_3d(self,expr):\n a = ones((10,20,1))\n self.generic_wrap(a,expr)\n \ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_make_same_length,'check_') )\n suites.append( unittest.makeSuite(test_binary_op_size,'check_') )\n suites.append( unittest.makeSuite(test_dummy_array,'check_') )\n suites.append( unittest.makeSuite(test_dummy_array_indexing,'check_') )\n suites.append( unittest.makeSuite(test_reduction,'check_') )\n suites.append( unittest.makeSuite(test_expressions,'check_') )\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "methods": [ + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 17, + "complexity": 3, + "token_count": 120, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 18, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 41, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 46, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_scalar", + "long_name": "check_x_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 50, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_scalar", + "long_name": "check_y_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 54, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_short", + "long_name": "check_x_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 58, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_short", + "long_name": "check_y_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 62, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 68, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 72, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "val" + ], + "start_line": 79, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self" + ], + "start_line": 81, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x1", + "long_name": "check_x1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y1", + "long_name": "check_y1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 89, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y", + "long_name": "check_x_y( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 93, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y2", + "long_name": "check_x_y2( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 97, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y3", + "long_name": "check_x_y3( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 101, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y4", + "long_name": "check_x_y4( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 105, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y5", + "long_name": "check_x_y5( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y6", + "long_name": "check_x_y6( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y7", + "long_name": "check_x_y7( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 117, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 122, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_error2", + "long_name": "check_error2( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 125, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 130, + "end_line": 144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 106, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 145, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 157, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "val" + ], + "start_line": 163, + "end_line": 164, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 167, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , ary , expr , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "ary", + "expr", + "desired" + ], + "start_line": 182, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , a , expr )", + "filename": "test_size_check.py", + "nloc": 9, + "complexity": 3, + "token_count": 59, + "parameters": [ + "self", + "a", + "expr" + ], + "start_line": 187, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "generic_1d", + "long_name": "generic_1d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "expr" + ], + "start_line": 197, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 200, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 203, + "end_line": 205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_1d_index", + "long_name": "generic_1d_index( self , expr )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "expr" + ], + "start_line": 207, + "end_line": 211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_0", + "long_name": "check_1d_index_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 212, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_1", + "long_name": "check_1d_index_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 214, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_2", + "long_name": "check_1d_index_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 216, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_3", + "long_name": "check_1d_index_3( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 218, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_calculated", + "long_name": "check_1d_index_calculated( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 223, + "end_line": 224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_1", + "long_name": "check_1d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 225, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_2", + "long_name": "check_1d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 227, + "end_line": 228, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_3", + "long_name": "check_1d_3( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_4", + "long_name": "check_1d_4( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 233, + "end_line": 234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_5", + "long_name": "check_1d_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 235, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_6", + "long_name": "check_1d_6( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 237, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_7", + "long_name": "check_1d_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 239, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_8", + "long_name": "check_1d_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_9", + "long_name": "check_1d_9( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 243, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_10", + "long_name": "check_1d_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 247, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_0", + "long_name": "check_1d_stride_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 250, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_1", + "long_name": "check_1d_stride_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 252, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_2", + "long_name": "check_1d_stride_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 254, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_3", + "long_name": "check_1d_stride_3( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 256, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_4", + "long_name": "check_1d_stride_4( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 258, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_5", + "long_name": "check_1d_stride_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 262, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_6", + "long_name": "check_1d_stride_6( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 264, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_7", + "long_name": "check_1d_stride_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 266, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_8", + "long_name": "check_1d_stride_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 268, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_9", + "long_name": "check_1d_stride_9( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_10", + "long_name": "check_1d_stride_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 272, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_11", + "long_name": "check_1d_stride_11( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 274, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_12", + "long_name": "check_1d_stride_12( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 276, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_random", + "long_name": "check_1d_random( self )", + "filename": "test_size_check.py", + "nloc": 11, + "complexity": 3, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 278, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 292, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 294, + "end_line": 295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_2", + "long_name": "check_2d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 296, + "end_line": 297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_random", + "long_name": "check_2d_random( self )", + "filename": "test_size_check.py", + "nloc": 15, + "complexity": 3, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 298, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_3d_random", + "long_name": "check_3d_random( self )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 315, + "end_line": 328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 331, + "end_line": 335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 336, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3d_0", + "long_name": "check_3d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 346, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_error0", + "long_name": "check_error0( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 351, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 357, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 365, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired , ** kw )", + "filename": "test_size_check.py", + "nloc": 20, + "complexity": 6, + "token_count": 117, + "parameters": [ + "self", + "expr", + "desired", + "kw" + ], + "start_line": 380, + "end_line": 399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , expr , ** kw )", + "filename": "test_size_check.py", + "nloc": 10, + "complexity": 3, + "token_count": 55, + "parameters": [ + "self", + "expr", + "kw" + ], + "start_line": 400, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_generic_1d", + "long_name": "check_generic_1d( self )", + "filename": "test_size_check.py", + "nloc": 14, + "complexity": 1, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 410, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_single_index", + "long_name": "check_single_index( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 424, + "end_line": 427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index", + "long_name": "check_calculated_index( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 429, + "end_line": 433, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index2", + "long_name": "check_calculated_index2( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 438, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 439, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 442, + "end_line": 444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_size_check.py", + "nloc": 11, + "complexity": 2, + "token_count": 104, + "parameters": [ + "level" + ], + "start_line": 446, + "end_line": 456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 458, + "end_line": 462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 17, + "complexity": 3, + "token_count": 120, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 18, + "end_line": 37, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 41, + "end_line": 44, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 29, + "parameters": [ + "self" + ], + "start_line": 46, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_scalar", + "long_name": "check_x_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 50, + "end_line": 53, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_scalar", + "long_name": "check_y_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 46, + "parameters": [ + "self" + ], + "start_line": 54, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_short", + "long_name": "check_x_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 58, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y_short", + "long_name": "check_y_short( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 55, + "parameters": [ + "self" + ], + "start_line": 62, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 32, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 68, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 72, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 12, + "parameters": [ + "self", + "val" + ], + "start_line": 79, + "end_line": 80, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_scalar", + "long_name": "check_scalar( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "self" + ], + "start_line": 81, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x1", + "long_name": "check_x1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 85, + "end_line": 88, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_y1", + "long_name": "check_y1( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self" + ], + "start_line": 89, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y", + "long_name": "check_x_y( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 39, + "parameters": [ + "self" + ], + "start_line": 93, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y2", + "long_name": "check_x_y2( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 97, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y3", + "long_name": "check_x_y3( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 101, + "end_line": 104, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y4", + "long_name": "check_x_y4( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 105, + "end_line": 108, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y5", + "long_name": "check_x_y5( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 109, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y6", + "long_name": "check_x_y6( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 42, + "parameters": [ + "self" + ], + "start_line": 113, + "end_line": 116, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_x_y7", + "long_name": "check_x_y7( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 56, + "parameters": [ + "self" + ], + "start_line": 117, + "end_line": 120, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 26, + "parameters": [ + "self" + ], + "start_line": 122, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_error2", + "long_name": "check_error2( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "self" + ], + "start_line": 125, + "end_line": 127, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 76, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 130, + "end_line": 144, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , x , y , desired )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 106, + "parameters": [ + "self", + "x", + "y", + "desired" + ], + "start_line": 145, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 1 + }, + { + "name": "generic_error_test", + "long_name": "generic_error_test( self , x , y )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 29, + "parameters": [ + "self", + "x", + "y" + ], + "start_line": 157, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "desired_type", + "long_name": "desired_type( self , val )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self", + "val" + ], + "start_line": 163, + "end_line": 164, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 167, + "end_line": 181, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , ary , expr , desired )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 37, + "parameters": [ + "self", + "ary", + "expr", + "desired" + ], + "start_line": 182, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , a , expr )", + "filename": "test_size_check.py", + "nloc": 9, + "complexity": 3, + "token_count": 59, + "parameters": [ + "self", + "a", + "expr" + ], + "start_line": 187, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "generic_1d", + "long_name": "generic_1d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "self", + "expr" + ], + "start_line": 197, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 200, + "end_line": 202, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 203, + "end_line": 205, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_1d_index", + "long_name": "generic_1d_index( self , expr )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 30, + "parameters": [ + "self", + "expr" + ], + "start_line": 207, + "end_line": 211, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_0", + "long_name": "check_1d_index_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 212, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_1", + "long_name": "check_1d_index_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 214, + "end_line": 215, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_2", + "long_name": "check_1d_index_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 216, + "end_line": 217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_3", + "long_name": "check_1d_index_3( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 218, + "end_line": 220, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_1d_index_calculated", + "long_name": "check_1d_index_calculated( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 221, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 223, + "end_line": 224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_1", + "long_name": "check_1d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 225, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_2", + "long_name": "check_1d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 227, + "end_line": 228, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_3", + "long_name": "check_1d_3( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 229, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_4", + "long_name": "check_1d_4( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 233, + "end_line": 234, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_5", + "long_name": "check_1d_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 235, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_6", + "long_name": "check_1d_6( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 237, + "end_line": 238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_7", + "long_name": "check_1d_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 239, + "end_line": 240, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_8", + "long_name": "check_1d_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 241, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_9", + "long_name": "check_1d_9( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 243, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_10", + "long_name": "check_1d_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 247, + "end_line": 248, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_0", + "long_name": "check_1d_stride_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 250, + "end_line": 251, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_1", + "long_name": "check_1d_stride_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 252, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_2", + "long_name": "check_1d_stride_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 254, + "end_line": 255, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_3", + "long_name": "check_1d_stride_3( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 256, + "end_line": 257, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_4", + "long_name": "check_1d_stride_4( self )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 2, + "token_count": 17, + "parameters": [ + "self" + ], + "start_line": 258, + "end_line": 261, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_5", + "long_name": "check_1d_stride_5( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 262, + "end_line": 263, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_6", + "long_name": "check_1d_stride_6( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 264, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_7", + "long_name": "check_1d_stride_7( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 266, + "end_line": 267, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_8", + "long_name": "check_1d_stride_8( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 268, + "end_line": 269, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_9", + "long_name": "check_1d_stride_9( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 270, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_10", + "long_name": "check_1d_stride_10( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 272, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_11", + "long_name": "check_1d_stride_11( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 274, + "end_line": 275, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_stride_12", + "long_name": "check_1d_stride_12( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 276, + "end_line": 277, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_1d_random", + "long_name": "check_1d_random( self )", + "filename": "test_size_check.py", + "nloc": 11, + "complexity": 3, + "token_count": 87, + "parameters": [ + "self" + ], + "start_line": 278, + "end_line": 290, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 292, + "end_line": 293, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 294, + "end_line": 295, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_2", + "long_name": "check_2d_2( self )", + "filename": "test_size_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 296, + "end_line": 297, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_2d_random", + "long_name": "check_2d_random( self )", + "filename": "test_size_check.py", + "nloc": 15, + "complexity": 3, + "token_count": 120, + "parameters": [ + "self" + ], + "start_line": 298, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "check_3d_random", + "long_name": "check_3d_random( self )", + "filename": "test_size_check.py", + "nloc": 12, + "complexity": 4, + "token_count": 86, + "parameters": [ + "self" + ], + "start_line": 315, + "end_line": 328, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_1d_0", + "long_name": "check_1d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 47, + "parameters": [ + "self" + ], + "start_line": 331, + "end_line": 335, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_0", + "long_name": "check_2d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 336, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_2d_1", + "long_name": "check_2d_1( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 50, + "parameters": [ + "self" + ], + "start_line": 341, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_3d_0", + "long_name": "check_3d_0( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 53, + "parameters": [ + "self" + ], + "start_line": 346, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_error0", + "long_name": "check_error0( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 31, + "parameters": [ + "self" + ], + "start_line": 351, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_error1", + "long_name": "check_error1( self )", + "filename": "test_size_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 30, + "parameters": [ + "self" + ], + "start_line": 357, + "end_line": 362, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "array_assert_equal", + "long_name": "array_assert_equal( self , test_string , actual , desired )", + "filename": "test_size_check.py", + "nloc": 13, + "complexity": 2, + "token_count": 82, + "parameters": [ + "self", + "test_string", + "actual", + "desired" + ], + "start_line": 365, + "end_line": 379, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "generic_test", + "long_name": "generic_test( self , expr , desired , ** kw )", + "filename": "test_size_check.py", + "nloc": 20, + "complexity": 6, + "token_count": 117, + "parameters": [ + "self", + "expr", + "desired", + "kw" + ], + "start_line": 380, + "end_line": 399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "generic_wrap", + "long_name": "generic_wrap( self , expr , ** kw )", + "filename": "test_size_check.py", + "nloc": 10, + "complexity": 3, + "token_count": 55, + "parameters": [ + "self", + "expr", + "kw" + ], + "start_line": 400, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 1 + }, + { + "name": "check_generic_1d", + "long_name": "check_generic_1d( self )", + "filename": "test_size_check.py", + "nloc": 14, + "complexity": 1, + "token_count": 100, + "parameters": [ + "self" + ], + "start_line": 410, + "end_line": 423, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "check_single_index", + "long_name": "check_single_index( self )", + "filename": "test_size_check.py", + "nloc": 4, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 424, + "end_line": 427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index", + "long_name": "check_calculated_index( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 429, + "end_line": 433, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "check_calculated_index2", + "long_name": "check_calculated_index2( self )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self" + ], + "start_line": 434, + "end_line": 438, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "generic_2d", + "long_name": "generic_2d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 25, + "parameters": [ + "self", + "expr" + ], + "start_line": 439, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "generic_3d", + "long_name": "generic_3d( self , expr )", + "filename": "test_size_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 27, + "parameters": [ + "self", + "expr" + ], + "start_line": 442, + "end_line": 444, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_size_check.py", + "nloc": 11, + "complexity": 2, + "token_count": 104, + "parameters": [ + "level" + ], + "start_line": 446, + "end_line": 456, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_size_check.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 458, + "end_line": 462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 421, + "complexity": 117, + "token_count": 3159, + "diff_parsed": { + "added": [ + " from scipy_base.fastumath import *" + ], + "deleted": [ + " from fastumath import *" + ] + } + }, + { + "old_path": "weave/tests/test_standard_array_spec.py", + "new_path": "weave/tests/test_standard_array_spec.py", + "filename": "test_standard_array_spec.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,7 @@\n from Numeric import *\n # The following try/except so that non-SciPy users can still use blitz\n try:\n- from fastumath import *\n+ from scipy_base.fastumath import *\n except:\n pass # fastumath not available \n import RandomArray\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from scipy_base.fastumath import *\nexcept:\n pass # fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport standard_array_spec\nrestore_path()\n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_array_converter(unittest.TestCase): \n def check_type_match_string(self):\n s = standard_array_spec.array_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = standard_array_spec.array_converter() \n assert(not s.type_match(5))\n def check_type_match_array(self):\n s = standard_array_spec.array_converter() \n assert(s.type_match(arange(4)))\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_array_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "source_code_before": "import unittest\nfrom Numeric import *\n# The following try/except so that non-SciPy users can still use blitz\ntry:\n from fastumath import *\nexcept:\n pass # fastumath not available \nimport RandomArray\nimport time\n\nfrom scipy_distutils.misc_util import add_grandparent_to_path, restore_path\n\nadd_grandparent_to_path(__name__)\nimport standard_array_spec\nrestore_path()\n\ndef remove_whitespace(in_str):\n import string\n out = string.replace(in_str,\" \",\"\")\n out = string.replace(out,\"\\t\",\"\")\n out = string.replace(out,\"\\n\",\"\")\n return out\n \ndef print_assert_equal(test_string,actual,desired):\n \"\"\"this should probably be in scipy_test\n \"\"\"\n import pprint\n try:\n assert(actual == desired)\n except AssertionError:\n import cStringIO\n msg = cStringIO.StringIO()\n msg.write(test_string)\n msg.write(' failed\\nACTUAL: \\n')\n pprint.pprint(actual,msg)\n msg.write('DESIRED: \\n')\n pprint.pprint(desired,msg)\n raise AssertionError, msg.getvalue()\n\nclass test_array_converter(unittest.TestCase): \n def check_type_match_string(self):\n s = standard_array_spec.array_converter()\n assert( not s.type_match('string') )\n def check_type_match_int(self):\n s = standard_array_spec.array_converter() \n assert(not s.type_match(5))\n def check_type_match_array(self):\n s = standard_array_spec.array_converter() \n assert(s.type_match(arange(4)))\n\ndef test_suite(level=1):\n suites = []\n if level > 0:\n suites.append( unittest.makeSuite(test_array_converter,'check_'))\n\n total_suite = unittest.TestSuite(suites)\n return total_suite\n\ndef test(level=10):\n all_tests = test_suite(level)\n runner = unittest.TextTestRunner()\n runner.run(all_tests)\n return runner\n\nif __name__ == \"__main__\":\n test()\n", + "methods": [ + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "test_standard_array_spec.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 17, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_standard_array_spec.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 24, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 41, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 44, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_array", + "long_name": "check_type_match_array( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 47, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_standard_array_spec.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "level" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_standard_array_spec.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 59, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "remove_whitespace", + "long_name": "remove_whitespace( in_str )", + "filename": "test_standard_array_spec.py", + "nloc": 6, + "complexity": 1, + "token_count": 45, + "parameters": [ + "in_str" + ], + "start_line": 17, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "print_assert_equal", + "long_name": "print_assert_equal( test_string , actual , desired )", + "filename": "test_standard_array_spec.py", + "nloc": 13, + "complexity": 2, + "token_count": 74, + "parameters": [ + "test_string", + "actual", + "desired" + ], + "start_line": 24, + "end_line": 38, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 0 + }, + { + "name": "check_type_match_string", + "long_name": "check_type_match_string( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 41, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_int", + "long_name": "check_type_match_int( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "self" + ], + "start_line": 44, + "end_line": 46, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "check_type_match_array", + "long_name": "check_type_match_array( self )", + "filename": "test_standard_array_spec.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "self" + ], + "start_line": 47, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "test_standard_array_spec.py", + "nloc": 6, + "complexity": 2, + "token_count": 39, + "parameters": [ + "level" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "test_standard_array_spec.py", + "nloc": 5, + "complexity": 1, + "token_count": 28, + "parameters": [ + "level" + ], + "start_line": 59, + "end_line": 63, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 54, + "complexity": 9, + "token_count": 315, + "diff_parsed": { + "added": [ + " from scipy_base.fastumath import *" + ], + "deleted": [ + " from fastumath import *" + ] + } + } + ] + }, + { + "hash": "7c4c41e2dd73f8989ed93b4eda55502e3e02efab", + "msg": "Moved limits.py to scipy_base", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-03-30T00:47:33+00:00", + "author_timezone": 0, + "committer_date": "2002-03-30T00:47:33+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "1e175b81241e25e1fd13757c71b704dbf71cd8e4" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/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": "scipy_base/__init__.py", + "new_path": "scipy_base/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,6 +2,7 @@\n import Numeric\n from Numeric import *\n import fastumath\n+from limits import *\n from utility import *\n from convenience import *\n from polynomial import *\n", + "added_lines": 1, + "deleted_lines": 0, + "source_code": "\nimport Numeric\nfrom Numeric import *\nimport fastumath\nfrom limits import *\nfrom utility import *\nfrom convenience import *\nfrom polynomial import *\nfrom scimath import *\nfrom helpmod import help, source\nfrom Matrix import Matrix as mat\nMat = mat # deprecated\n\n\n\n", + "source_code_before": "\nimport Numeric\nfrom Numeric import *\nimport fastumath\nfrom utility import *\nfrom convenience import *\nfrom polynomial import *\nfrom scimath import *\nfrom helpmod import help, source\nfrom Matrix import Matrix as mat\nMat = mat # deprecated\n\n\n\n", + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": 11, + "complexity": 0, + "token_count": 43, + "diff_parsed": { + "added": [ + "from limits import *" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "8f783998cba36f3b440f1a517e10297ecf6bd761", + "msg": "Added missing files.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-03-30T00:51:03+00:00", + "author_timezone": 0, + "committer_date": "2002-03-30T00:51:03+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "7c4c41e2dd73f8989ed93b4eda55502e3e02efab" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 0, + "insertions": 29, + "lines": 29, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": null, + "new_path": "scipy_base/setup_scipy_base.py", + "filename": "setup_scipy_base.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,29 @@\n+#!/usr/bin/env python\n+\n+import os\n+from glob import glob\n+from scipy_distutils.core import Extension\n+from scipy_distutils.misc_util import get_path, default_config_dict\n+\n+def configuration(parent_package=''):\n+ parent_path = parent_package\n+ if parent_package:\n+ parent_package += '.'\n+ local_path = get_path(__name__)\n+\n+ config = default_config_dict()\n+ config['packages'].append(parent_package+'scipy_base')\n+ config['package_dir'][parent_package+'scipy_base'] = local_path\n+\n+ # fastumath module\n+ sources = ['fastumathmodule.c']\n+ sources = [os.path.join(local_path,x) for x in sources]\n+ ext = Extension('scipy_base.fastumath',sources,libraries=[])\n+ config['ext_modules'].append(ext)\n+ \n+\n+ return config\n+\n+if __name__ == '__main__': \n+ from scipy_distutils.core import setup\n+ setup(**configuration())\n", + "added_lines": 29, + "deleted_lines": 0, + "source_code": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path, default_config_dict\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_base')\n config['package_dir'][parent_package+'scipy_base'] = local_path\n\n # fastumath module\n sources = ['fastumathmodule.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base.fastumath',sources,libraries=[])\n config['ext_modules'].append(ext)\n \n\n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", + "source_code_before": null, + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' )", + "filename": "setup_scipy_base.py", + "nloc": 13, + "complexity": 3, + "token_count": 96, + "parameters": [ + "parent_package" + ], + "start_line": 8, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' )", + "filename": "setup_scipy_base.py", + "nloc": 13, + "complexity": 3, + "token_count": 96, + "parameters": [ + "parent_package" + ], + "start_line": 8, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + } + ], + "nloc": 20, + "complexity": 3, + "token_count": 135, + "diff_parsed": { + "added": [ + "#!/usr/bin/env python", + "", + "import os", + "from glob import glob", + "from scipy_distutils.core import Extension", + "from scipy_distutils.misc_util import get_path, default_config_dict", + "", + "def configuration(parent_package=''):", + " parent_path = parent_package", + " if parent_package:", + " parent_package += '.'", + " local_path = get_path(__name__)", + "", + " config = default_config_dict()", + " config['packages'].append(parent_package+'scipy_base')", + " config['package_dir'][parent_package+'scipy_base'] = local_path", + "", + " # fastumath module", + " sources = ['fastumathmodule.c']", + " sources = [os.path.join(local_path,x) for x in sources]", + " ext = Extension('scipy_base.fastumath',sources,libraries=[])", + " config['ext_modules'].append(ext)", + "", + "", + " return config", + "", + "if __name__ == '__main__':", + " from scipy_distutils.core import setup", + " setup(**configuration())" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "341048691467bd651cae6ee4704f79ca27c0e499", + "msg": "Move limits.py, fastumath", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-03-30T00:56:17+00:00", + "author_timezone": 0, + "committer_date": "2002-03-30T00:56:17+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "8f783998cba36f3b440f1a517e10297ecf6bd761" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 0, + "insertions": 2308, + "lines": 2308, + "files": 1, + "dmm_unit_size": 0.6369489846458642, + "dmm_unit_complexity": 0.8444774640911342, + "dmm_unit_interfacing": 0.27290737989103514, + "modified_files": [ + { + "old_path": null, + "new_path": "scipy_base/fastumathmodule.c", + "filename": "fastumathmodule.c", + "extension": "c", + "change_type": "ADD", + "diff": "@@ -0,0 +1,2308 @@\n+\n+#include \"Python.h\"\n+#include \"Numeric/arrayobject.h\"\n+#include \"Numeric/ufuncobject.h\"\n+#include \"abstract.h\"\n+#include \n+\n+/* Fast umath module whose functions do not check for range and domain errors.\n+\n+ Replacement for umath\n+ */\n+\n+\n+#ifndef CHAR_BIT\n+#define CHAR_BIT 8\n+#endif\n+\n+#ifndef LONG_BIT\n+#define LONG_BIT (CHAR_BIT * sizeof(long))\n+#endif\n+\n+#ifndef INT_BIT\n+#define INT_BIT (CHAR_BIT * sizeof(int))\n+#endif\n+\n+#ifndef SHORT_BIT\n+#define SHORT_BIT (CHAR_BIT * sizeof(short))\n+#endif\n+\n+/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n+\n+#if !defined(__STDC__) && !defined(_MSC_VER)\n+extern double fmod (double, double);\n+extern double frexp (double, int *);\n+extern double ldexp (double, int);\n+extern double modf (double, double *);\n+#endif\n+\n+#ifndef M_PI\n+#define M_PI 3.14159265359\n+#endif\n+\n+#if !defined(HAVE_INVERSE_HYPERBOLIC)\n+static double acosh(double x)\n+{\n+ return log(x + sqrt((x-1.0)*(x+1.0)));\n+}\n+\n+static double asinh(double xx)\n+{\n+ double x;\n+ int sign;\n+ if (x < 0.0) {\n+\tsign = -1;\n+\tx = -xx;\n+ }\n+ else {\n+\tsign = 1;\n+\tx = xx;\n+ }\n+ return sign*log(x + sqrt(x*x+1.0));\n+}\n+\n+static double atanh(double x)\n+{\n+ return 0.5*log((1.0+x)/(1.0-x));\n+}\n+#endif\n+\n+#if defined(HAVE_HYPOT) \n+#if !defined(NeXT) && !defined(_MSC_VER)\n+extern double hypot(double, double);\n+#endif\n+#else\n+double hypot(double x, double y)\n+{\n+ double yx;\n+\n+ x = fabs(x);\n+ y = fabs(y);\n+ if (x < y) {\n+\tdouble temp = x;\n+\tx = y;\n+\ty = temp;\n+ }\n+ if (x == 0.)\n+\treturn 0.;\n+ else {\n+\tyx = y/x;\n+\treturn x*sqrt(1.+yx*yx);\n+ }\n+}\n+#endif\n+\n+#ifdef i860\n+/* Cray APP has bogus definition of HUGE_VAL in */\n+#undef HUGE_VAL\n+#endif\n+\n+#ifdef HUGE_VAL\n+#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n+#else\n+#define CHECK(x) /* Don't know how to check */\n+#endif\n+\n+\n+\n+/* First, the C functions that do the real work */\n+\n+/* constants */\n+static Py_complex c_1 = {1., 0.};\n+static Py_complex c_half = {0.5, 0.};\n+static Py_complex c_i = {0., 1.};\n+static Py_complex c_i2 = {0., 0.5};\n+static Py_complex c_mi = {0., -1.};\n+static Py_complex c_pi2 = {M_PI/2., 0.};\n+\n+static Py_complex c_quot_fast(Py_complex a, Py_complex b)\n+{\n+ /******************************************************************/\n+ \n+ /* This algorithm is better, and is pretty obvious: first divide the\n+ * numerators and denominator by whichever of {b.real, b.imag} has\n+ * larger magnitude. The earliest reference I found was to CACM\n+ * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n+ * University). As usual, though, we're still ignoring all IEEE\n+ * endcases.\n+ */\n+ Py_complex r; /* the result */\n+\n+ const double abs_breal = b.real < 0 ? -b.real : b.real;\n+ const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n+\n+ if ((b.real == 0.0) && (b.imag == 0.0)) {\n+\tr.real = a.real / b.real;\n+\tr.imag = a.imag / b.imag;\n+/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n+/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n+/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n+\t\n+/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n+/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n+/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n+\treturn r;\n+ }\n+ \n+ if (abs_breal >= abs_bimag) {\n+\t/* divide tops and bottom by b.real */\n+\tconst double ratio = b.imag / b.real;\n+\tconst double denom = b.real + b.imag * ratio;\n+\tr.real = (a.real + a.imag * ratio) / denom;\n+\tr.imag = (a.imag - a.real * ratio) / denom;\n+ }\n+ else {\n+\t/* divide tops and bottom by b.imag */\n+\tconst double ratio = b.real / b.imag;\n+\tconst double denom = b.real * ratio + b.imag;\n+\tr.real = (a.real * ratio + a.imag) / denom;\n+\tr.imag = (a.imag * ratio - a.real) / denom;\n+ }\n+ return r;\n+}\n+\n+static Py_complex c_sqrt(Py_complex x)\n+{\n+ Py_complex r;\n+ double s,d;\n+ if (x.real == 0. && x.imag == 0.)\n+\tr = x;\n+ else {\n+\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n+\td = 0.5*x.imag/s;\n+\tif (x.real > 0.) {\n+\t r.real = s;\n+\t r.imag = d;\n+\t}\n+\telse if (x.imag >= 0.) {\n+\t r.real = d;\n+\t r.imag = s;\n+\t}\n+\telse {\n+\t r.real = -d;\n+\t r.imag = -s;\n+\t}\n+ }\n+ return r;\n+}\n+\n+static Py_complex c_log(Py_complex x)\n+{\n+ Py_complex r;\n+ double l = hypot(x.real,x.imag);\n+ r.imag = atan2(x.imag, x.real);\n+ r.real = log(l);\n+ return r;\n+}\n+\n+static Py_complex c_prodi(Py_complex x)\n+{\n+ Py_complex r;\n+ r.real = -x.imag;\n+ r.imag = x.real;\n+ return r;\n+}\n+\n+static Py_complex c_acos(Py_complex x)\n+{\n+ return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n+\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n+}\n+\n+static Py_complex c_acosh(Py_complex x)\n+{\n+ return c_log(c_sum(x,c_prod(c_i,\n+\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n+}\n+\n+static Py_complex c_asin(Py_complex x)\n+{\n+ return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n+\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n+}\n+\n+static Py_complex c_asinh(Py_complex x)\n+{\n+ return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n+}\n+\n+static Py_complex c_atan(Py_complex x)\n+{\n+ return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n+}\n+\n+static Py_complex c_atanh(Py_complex x)\n+{\n+ return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n+}\n+\n+static Py_complex c_cos(Py_complex x)\n+{\n+ Py_complex r;\n+ r.real = cos(x.real)*cosh(x.imag);\n+ r.imag = -sin(x.real)*sinh(x.imag);\n+ return r;\n+}\n+\n+static Py_complex c_cosh(Py_complex x)\n+{\n+ Py_complex r;\n+ r.real = cos(x.imag)*cosh(x.real);\n+ r.imag = sin(x.imag)*sinh(x.real);\n+ return r;\n+}\n+\n+static Py_complex c_exp(Py_complex x)\n+{\n+ Py_complex r;\n+ double l = exp(x.real);\n+ r.real = l*cos(x.imag);\n+ r.imag = l*sin(x.imag);\n+ return r;\n+}\n+\n+static Py_complex c_log10(Py_complex x)\n+{\n+ Py_complex r;\n+ double l = hypot(x.real,x.imag);\n+ r.imag = atan2(x.imag, x.real)/log(10.);\n+ r.real = log10(l);\n+ return r;\n+}\n+\n+static Py_complex c_sin(Py_complex x)\n+{\n+ Py_complex r;\n+ r.real = sin(x.real)*cosh(x.imag);\n+ r.imag = cos(x.real)*sinh(x.imag);\n+ return r;\n+}\n+\n+static Py_complex c_sinh(Py_complex x)\n+{\n+ Py_complex r;\n+ r.real = cos(x.imag)*sinh(x.real);\n+ r.imag = sin(x.imag)*cosh(x.real);\n+ return r;\n+}\n+\n+static Py_complex c_tan(Py_complex x)\n+{\n+ Py_complex r;\n+ double sr,cr,shi,chi;\n+ double rs,is,rc,ic;\n+ double d;\n+ sr = sin(x.real);\n+ cr = cos(x.real);\n+ shi = sinh(x.imag);\n+ chi = cosh(x.imag);\n+ rs = sr*chi;\n+ is = cr*shi;\n+ rc = cr*chi;\n+ ic = -sr*shi;\n+ d = rc*rc + ic*ic;\n+ r.real = (rs*rc+is*ic)/d;\n+ r.imag = (is*rc-rs*ic)/d;\n+ return r;\n+}\n+\n+static Py_complex c_tanh(Py_complex x)\n+{\n+ Py_complex r;\n+ double si,ci,shr,chr;\n+ double rs,is,rc,ic;\n+ double d;\n+ si = sin(x.imag);\n+ ci = cos(x.imag);\n+ shr = sinh(x.real);\n+ chr = cosh(x.real);\n+ rs = ci*shr;\n+ is = si*chr;\n+ rc = ci*chr;\n+ ic = si*shr;\n+ d = rc*rc + ic*ic;\n+ r.real = (rs*rc+is*ic)/d;\n+ r.imag = (is*rc-rs*ic)/d;\n+ return r;\n+}\n+\n+static long powll(long x, long n, int nbits)\n+ /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n+{\n+ long r = 1;\n+ long p = x;\n+ double logtwox;\n+ long mask = 1;\n+ if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n+ if (x != 0) {\n+\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n+\tif (logtwox * (double) n > (double) nbits)\n+\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n+ }\n+ while (mask > 0 && n >= mask) {\n+\tif (n & mask)\n+\t r *= p;\n+\tmask <<= 1;\n+\tp *= p;\n+ }\n+ return r;\n+}\n+\n+static void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i 255) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t*((unsigned char *)op)=(unsigned char) x;\n+ }\n+}\n+static void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ int x;\n+ for(i=0; i 127 || x < -128) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t*((signed char *)op)=(signed char) x;\n+ }\n+}\n+static void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ short a, b, ah, bh, x, y;\n+ int s;\n+ for(i=0; i> (SHORT_BIT/2);\n+\tbh = b >> (SHORT_BIT/2);\n+\t/* Quick test for common case: two small positive shorts */\n+\tif (ah == 0 && bh == 0) {\n+\t if ((x=a*b) < 0) {\n+\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\treturn;\n+\t }\n+\t else {\n+\t\t*((short *)op)=x;\n+\t\tcontinue;\n+\t }\n+\t}\n+\t/* Arrange that a >= b >= 0 */\n+\tif (a < 0) {\n+\t a = -a;\n+\t if (a < 0) {\n+\t\t/* Largest negative */\n+\t\tif (b == 0 || b == 1) {\n+\t\t *((short *)op)=a*b;\n+\t\t continue;\n+\t\t}\n+\t\telse {\n+\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\t return;\n+\t\t}\n+\t }\n+\t s = -s;\n+\t ah = a >> (SHORT_BIT/2);\n+\t}\n+\tif (b < 0) {\n+\t b = -b;\n+\t if (b < 0) {\n+\t\t/* Largest negative */\n+\t\tif (a == 0 || a == 1) {\n+\t\t *((short *)op)=a*b;\n+\t\t continue;\n+\t\t}\n+\t\telse {\n+\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\t return;\n+\t\t}\n+\t }\n+\t s = -s;\n+\t bh = b >> (SHORT_BIT/2);\n+\t}\n+\t/* 1) both ah and bh > 0 : then report overflow */\n+\tif (ah != 0 && bh != 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t/* 2) both ah and bh = 0 : then compute a*b and report\n+\t overflow if it comes out negative */\n+\tif (ah == 0 && bh == 0) {\n+\t if ((x=a*b) < 0) {\n+\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\treturn;\n+\t }\n+\t else {\n+\t\t*((short *)op)=s * x;\n+\t\tcontinue;\n+\t }\n+\t}\n+\tif (a < b) {\n+\t /* Swap */\n+\t x = a;\n+\t a = b;\n+\t b = x;\n+\t ah = bh;\n+\t /* bh not used beyond this point */\n+\t}\n+\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n+\t it's >= 2^31\n+\t compute al*bl and report overflow if it's negative\n+\t add (ah*bl)<<32 to al*bl and report overflow if\n+\t it's negative\n+\t (NB b == bl in this case, and we make a = al) */\n+\ty = ah*b;\n+\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\ta &= (1 << (SHORT_BIT/2)) - 1;\n+\tx = a*b;\n+\tif (x < 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\tx += y << (SHORT_BIT/2);\n+\tif (x < 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t*((short *)op)=s*x;\n+ }\n+}\n+static void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ int a, b, ah, bh, x, y;\n+ int s;\n+ for(i=0; i> (INT_BIT/2);\n+\tbh = b >> (INT_BIT/2);\n+\t/* Quick test for common case: two small positive ints */\n+\tif (ah == 0 && bh == 0) {\n+\t if ((x=a*b) < 0) {\n+\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\treturn;\n+\t }\n+\t else {\n+\t\t*((int *)op)=x;\n+\t\tcontinue;\n+\t }\n+\t}\n+\t/* Arrange that a >= b >= 0 */\n+\tif (a < 0) {\n+\t a = -a;\n+\t if (a < 0) {\n+\t\t/* Largest negative */\n+\t\tif (b == 0 || b == 1) {\n+\t\t *((int *)op)=a*b;\n+\t\t continue;\n+\t\t}\n+\t\telse {\n+\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\t return;\n+\t\t}\n+\t }\n+\t s = -s;\n+\t ah = a >> (INT_BIT/2);\n+\t}\n+\tif (b < 0) {\n+\t b = -b;\n+\t if (b < 0) {\n+\t\t/* Largest negative */\n+\t\tif (a == 0 || a == 1) {\n+\t\t *((int *)op)=a*b;\n+\t\t continue;\n+\t\t}\n+\t\telse {\n+\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\t return;\n+\t\t}\n+\t }\n+\t s = -s;\n+\t bh = b >> (INT_BIT/2);\n+\t}\n+\t/* 1) both ah and bh > 0 : then report overflow */\n+\tif (ah != 0 && bh != 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t/* 2) both ah and bh = 0 : then compute a*b and report\n+\t overflow if it comes out negative */\n+\tif (ah == 0 && bh == 0) {\n+\t if ((x=a*b) < 0) {\n+\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\treturn;\n+\t }\n+\t else {\n+\t\t*((int *)op)=s * x;\n+\t\tcontinue;\n+\t }\n+\t}\n+\tif (a < b) {\n+\t /* Swap */\n+\t x = a;\n+\t a = b;\n+\t b = x;\n+\t ah = bh;\n+\t /* bh not used beyond this point */\n+\t}\n+\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n+\t it's >= 2^31\n+\t compute al*bl and report overflow if it's negative\n+\t add (ah*bl)<<32 to al*bl and report overflow if\n+\t it's negative\n+\t (NB b == bl in this case, and we make a = al) */\n+\ty = ah*b;\n+\tif (y >= (1 << (INT_BIT/2 - 1))) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\ta &= (1 << (INT_BIT/2)) - 1;\n+\tx = a*b;\n+\tif (x < 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\tx += y << (INT_BIT/2);\n+\tif (x < 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t*((int *)op)=s*x;\n+ }\n+}\n+static void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ long a, b, ah, bh, x, y;\n+ int s;\n+ for(i=0; i> (LONG_BIT/2);\n+\tbh = b >> (LONG_BIT/2);\n+\t/* Quick test for common case: two small positive ints */\n+\tif (ah == 0 && bh == 0) {\n+\t if ((x=a*b) < 0) {\n+\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\treturn;\n+\t }\n+\t else {\n+\t\t*((long *)op)=x;\n+\t\tcontinue;\n+\t }\n+\t}\n+\t/* Arrange that a >= b >= 0 */\n+\tif (a < 0) {\n+\t a = -a;\n+\t if (a < 0) {\n+\t\t/* Largest negative */\n+\t\tif (b == 0 || b == 1) {\n+\t\t *((long *)op)=a*b;\n+\t\t continue;\n+\t\t}\n+\t\telse {\n+\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\t return;\n+\t\t}\n+\t }\n+\t s = -s;\n+\t ah = a >> (LONG_BIT/2);\n+\t}\n+\tif (b < 0) {\n+\t b = -b;\n+\t if (b < 0) {\n+\t\t/* Largest negative */\n+\t\tif (a == 0 || a == 1) {\n+\t\t *((long *)op)=a*b;\n+\t\t continue;\n+\t\t}\n+\t\telse {\n+\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\t return;\n+\t\t}\n+\t }\n+\t s = -s;\n+\t bh = b >> (LONG_BIT/2);\n+\t}\n+\t/* 1) both ah and bh > 0 : then report overflow */\n+\tif (ah != 0 && bh != 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t/* 2) both ah and bh = 0 : then compute a*b and report\n+\t overflow if it comes out negative */\n+\tif (ah == 0 && bh == 0) {\n+\t if ((x=a*b) < 0) {\n+\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t\treturn;\n+\t }\n+\t else {\n+\t\t*((long *)op)=s * x;\n+\t\tcontinue;\n+\t }\n+\t}\n+\tif (a < b) {\n+\t /* Swap */\n+\t x = a;\n+\t a = b;\n+\t b = x;\n+\t ah = bh;\n+\t /* bh not used beyond this point */\n+\t}\n+\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n+\t it's >= 2^31\n+\t compute al*bl and report overflow if it's negative\n+\t add (ah*bl)<<32 to al*bl and report overflow if\n+\t it's negative\n+\t (NB b == bl in this case, and we make a = al) */\n+\ty = ah*b;\n+\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\ta &= (1L << (LONG_BIT/2)) - 1;\n+\tx = a*b;\n+\tif (x < 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\tx += y << (LONG_BIT/2);\n+\tif (x < 0) {\n+\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n+\t return;\n+\t}\n+\t*((long *)op)=s*x;\n+ }\n+}\n+static void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((unsigned char *)i2);\n+ }\n+}\n+static void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((signed char *)i2);\n+ }\n+}\n+static void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((short *)i2);\n+ }\n+}\n+static void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((int *)i2);\n+ }\n+}\n+static void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((long *)i2);\n+ }\n+}\n+static void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((float *)i2);\n+ }\n+}\n+static void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((double *)i2);\n+ }\n+}\n+static void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i= *((unsigned char *)i2);\n+ }\n+}\n+static void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i= *((signed char *)i2);\n+ }\n+}\n+static void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i= *((short *)i2);\n+ }\n+}\n+static void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i= *((int *)i2);\n+ }\n+}\n+static void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i= *((long *)i2);\n+ }\n+}\n+static void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i= *((float *)i2);\n+ }\n+}\n+static void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i= *((double *)i2);\n+ }\n+}\n+static void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n+ }\n+}\n+static void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n+ }\n+}\n+static void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n+ }\n+}\n+static void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n+ }\n+}\n+static void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n+ }\n+}\n+static void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n+ }\n+}\n+static void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n+ }\n+}\n+static void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i> *((unsigned char *)i2);\n+ }\n+}\n+static void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i> *((signed char *)i2);\n+ }\n+}\n+static void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i> *((short *)i2);\n+ }\n+}\n+static void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i> *((int *)i2);\n+ }\n+}\n+static void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n+ int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n+ char *i1=args[0], *i2=args[1], *op=args[2];\n+ for(i=0; i> *((long *)i2);\n+ }\n+}\n+\n+static PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\n+static PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\n+static PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\n+static PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\n+static PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\n+static PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\n+static PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\n+static PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\n+static PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\n+static PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\n+static PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, };\n+static PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, };\n+static PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, };\n+static PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, };\n+static PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\n+static PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\n+static PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\n+static PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\n+static PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\n+static PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\n+static PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\n+static PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\n+static PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\n+static PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\n+static PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\n+static PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\n+static PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\n+static PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\n+static PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\n+static PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\n+static PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\n+static void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\n+static void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\n+static void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\n+static void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\n+static void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\n+static void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\n+static void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\n+static void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\n+static void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\n+static void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\n+static void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\n+static void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\n+static void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\n+static void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\n+static void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\n+static void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\n+static void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\n+static void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\n+static void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\n+static void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\n+static void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\n+static void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\n+static void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\n+static void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\n+static void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\n+static char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n+static char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\n+static char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n+static char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n+static char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n+static char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n+static char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_LONG, PyArray_UBYTE, PyArray_UBYTE, PyArray_LONG, PyArray_SBYTE, PyArray_SBYTE, PyArray_LONG, PyArray_SHORT, PyArray_SHORT, PyArray_LONG, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_LONG, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_LONG, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_LONG};\n+static char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_LONG, PyArray_SBYTE, PyArray_SBYTE, PyArray_LONG, PyArray_SHORT, PyArray_SHORT, PyArray_LONG, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_LONG, };\n+static char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, };\n+static char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\n+static char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\n+static char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n+static char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n+static char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\n+static void InitOperators(PyObject *dictionary) {\n+ PyObject *f;\n+\n+ add_data[9] =(void *)PyNumber_Add;\n+ subtract_data[9] = (void *)PyNumber_Subtract;\n+ multiply_data[7] = (void *)c_prod;\n+ multiply_data[8] = (void *)c_prod;\n+ multiply_data[9] = (void *)PyNumber_Multiply;\n+ divide_data[7] = (void *)c_quot_fast;\n+ divide_data[8] = (void *)c_quot_fast;\n+ divide_data[9] = (void *)PyNumber_Divide;\n+ divide_safe_data[7] = (void *)c_quot;\n+ divide_safe_data[8] = (void *)c_quot;\n+ divide_safe_data[9] = (void *)PyNumber_Divide;\n+ conjugate_data[9] = (void *)\"conjugate\";\n+ remainder_data[5] = (void *)fmod;\n+ remainder_data[6] = (void *)fmod;\n+ remainder_data[7] = (void *)PyNumber_Remainder;\n+ power_data[5] = (void *)pow;\n+ power_data[6] = (void *)pow;\n+ power_data[7] = (void *)c_pow;\n+ power_data[8] = (void *)c_pow;\n+ power_data[9] = (void *)PyNumber_Power;\n+ absolute_data[8] = (void *)PyNumber_Absolute;\n+ negative_data[8] = (void *)PyNumber_Negative;\n+ bitwise_and_data[5] = (void *)PyNumber_And;\n+ bitwise_or_data[5] = (void *)PyNumber_Or;\n+ bitwise_xor_data[5] = (void *)PyNumber_Xor;\n+ invert_data[5] = (void *)PyNumber_Invert;\n+ left_shift_data[5] = (void *)PyNumber_Lshift;\n+ right_shift_data[5] = (void *)PyNumber_Rshift;\n+\n+\n+ add_functions[9] = PyUFunc_OO_O;\n+ subtract_functions[9] = PyUFunc_OO_O;\n+ multiply_functions[7] = PyUFunc_FF_F_As_DD_D;\n+ multiply_functions[8] = PyUFunc_DD_D;\n+ multiply_functions[9] = PyUFunc_OO_O;\n+ divide_functions[7] = PyUFunc_FF_F_As_DD_D;\n+ divide_functions[8] = PyUFunc_DD_D;\n+ divide_functions[9] = PyUFunc_OO_O;\n+ divide_safe_functions[7] = PyUFunc_FF_F_As_DD_D;\n+ divide_safe_functions[8] = PyUFunc_DD_D;\n+ divide_safe_functions[9] = PyUFunc_OO_O;\n+ conjugate_functions[9] = PyUFunc_O_O_method;\n+ remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n+ remainder_functions[6] = PyUFunc_dd_d;\n+ remainder_functions[7] = PyUFunc_OO_O;\n+ power_functions[5] = PyUFunc_ff_f_As_dd_d;\n+ power_functions[6] = PyUFunc_dd_d;\n+ power_functions[7] = PyUFunc_FF_F_As_DD_D;\n+ power_functions[8] = PyUFunc_DD_D;\n+ power_functions[9] = PyUFunc_OO_O;\n+ absolute_functions[8] = PyUFunc_O_O;\n+ negative_functions[8] = PyUFunc_O_O;\n+ bitwise_and_functions[5] = PyUFunc_OO_O;\n+ bitwise_or_functions[5] = PyUFunc_OO_O;\n+ bitwise_xor_functions[5] = PyUFunc_OO_O;\n+ invert_functions[5] = PyUFunc_O_O;\n+ left_shift_functions[5] = PyUFunc_OO_O;\n+ right_shift_functions[5] = PyUFunc_OO_O;\n+ arccos_functions[0] = PyUFunc_f_f_As_d_d;\n+ arccos_functions[1] = PyUFunc_d_d;\n+ arccos_functions[2] = PyUFunc_F_F_As_D_D;\n+ arccos_functions[3] = PyUFunc_D_D;\n+ arccos_functions[4] = PyUFunc_O_O_method;\n+ ceil_functions[0] = PyUFunc_f_f_As_d_d;\n+ ceil_functions[1] = PyUFunc_d_d;\n+ ceil_functions[2] = PyUFunc_O_O_method;\n+ arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n+ arctan2_functions[1] = PyUFunc_dd_d;\n+ arctan2_functions[2] = PyUFunc_O_O_method;\n+\n+ f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n+\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n+\t\t\t\t\"Add the arguments elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"add\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n+\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n+\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"subtract\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n+\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n+\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"multiply\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n+\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n+\t\t\t\t\"Divide the arguments elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"divide\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n+\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n+ PyDict_SetItemString(dictionary, \"divide_safe\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n+\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n+\t\t\t\t\"returns conjugate of each element\", 0);\n+ PyDict_SetItemString(dictionary, \"conjugate\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n+\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n+\t\t\t\t\"returns remainder of division elementwise\", 0);\n+ PyDict_SetItemString(dictionary, \"remainder\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n+\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n+\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"power\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n+\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n+\t\t\t\t\"returns absolute value of each element\", 0);\n+ PyDict_SetItemString(dictionary, \"absolute\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n+\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n+\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"negative\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_None, \"greater\", \n+\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n+ PyDict_SetItemString(dictionary, \"greater\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_None, \"greater_equal\", \n+\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"greater_equal\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_None, \"less\", \n+\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"less\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_None, \"less_equal\", \n+\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"less_equal\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n+\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n+\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"equal\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n+\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n+\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"not_equal\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_One, \"logical_and\", \n+\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n+ PyDict_SetItemString(dictionary, \"logical_and\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_Zero, \"logical_or\", \n+\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n+ PyDict_SetItemString(dictionary, \"logical_or\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_None, \"logical_xor\", \n+\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n+ PyDict_SetItemString(dictionary, \"logical_xor\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n+\t\t\t\t7, 1, 1, PyUFunc_None, \"logical_not\", \n+\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"logical_not\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, divide_safe_signatures, \n+\t\t\t\t7, 2, 1, PyUFunc_None, \"maximum\", \n+\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"maximum\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, divide_safe_signatures,\n+\t\t\t\t7, 2, 1, PyUFunc_None, \"minimum\", \n+\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"minimum\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n+\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n+\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n+ PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n+\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n+\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n+ PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n+\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n+\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n+ PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n+\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n+\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n+ PyDict_SetItemString(dictionary, \"invert\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n+\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n+\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"left_shift\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n+\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n+\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"right_shift\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n+\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n+ PyDict_SetItemString(dictionary, \"arccos\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n+\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n+ PyDict_SetItemString(dictionary, \"arcsin\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n+\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n+ PyDict_SetItemString(dictionary, \"arctan\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n+\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n+ PyDict_SetItemString(dictionary, \"arctanh\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n+\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n+ PyDict_SetItemString(dictionary, \"arccosh\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n+\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n+ PyDict_SetItemString(dictionary, \"arcsinh\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n+\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n+ PyDict_SetItemString(dictionary, \"cos\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n+\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n+ PyDict_SetItemString(dictionary, \"cosh\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n+\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n+ PyDict_SetItemString(dictionary, \"exp\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n+\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n+ PyDict_SetItemString(dictionary, \"log\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n+\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n+ PyDict_SetItemString(dictionary, \"log10\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n+\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n+ PyDict_SetItemString(dictionary, \"sin\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n+\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n+ PyDict_SetItemString(dictionary, \"sinh\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n+\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n+ PyDict_SetItemString(dictionary, \"sqrt\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n+\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n+ PyDict_SetItemString(dictionary, \"tan\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n+\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n+\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n+ PyDict_SetItemString(dictionary, \"tanh\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n+\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n+\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n+ PyDict_SetItemString(dictionary, \"ceil\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n+\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n+\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n+\n+ PyDict_SetItemString(dictionary, \"fabs\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n+\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n+\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n+ PyDict_SetItemString(dictionary, \"floor\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n+\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n+\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n+ PyDict_SetItemString(dictionary, \"arctan2\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n+\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n+\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n+ PyDict_SetItemString(dictionary, \"fmod\", f);\n+ Py_DECREF(f);\n+ f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n+\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n+\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n+ PyDict_SetItemString(dictionary, \"hypot\", f);\n+ Py_DECREF(f);\n+}\n+\n+\n+/* Initialization function for the module (*must* be called initArray) */\n+\n+static struct PyMethodDef methods[] = {\n+ {NULL,\t\tNULL, 0}\t\t/* sentinel */\n+};\n+\n+DL_EXPORT(void) initfastumath() {\n+ PyObject *m, *d, *s, *f1, *f2;\n+ \n+ /* Create the module and add the functions */\n+ m = Py_InitModule(\"fastumath\", methods); \n+\n+ /* Import the array and ufunc objects */\n+ import_array();\n+ import_ufunc();\n+\n+ /* Add some symbolic constants to the module */\n+ d = PyModule_GetDict(m);\n+\n+ s = PyString_FromString(\"1.0\");\n+ PyDict_SetItemString(d, \"__version__\", s);\n+ Py_DECREF(s);\n+\n+ /* Load the ufunc operators into the array module's namespace */\n+ InitOperators(d); \n+\n+ PyDict_SetItemString(d, \"pi\", s = PyFloat_FromDouble(atan(1.0) * 4.0));\n+ Py_DECREF(s);\n+ PyDict_SetItemString(d, \"e\", s = PyFloat_FromDouble(exp(1.0)));\n+ Py_DECREF(s);\n+\n+\n+ /* Temporarily set \"invert\" to \"conjugate\" in the dictionary so the call\n+ to SetNumericOps will make ~ do complex conjugation */\n+\n+ f1 = PyDict_GetItemString(d, \"conjugate\"); /* Borrowed reference */\n+ /* f2 = PyDict_GetItemString(d, \"invert\"); */ /* Borrowed reference */\n+ /* Py_INCREF(f2);*//*so we must incref it or it will be destroyed on next line*/\n+ /* PyDict_SetItemString(d, \"invert\", f1);*/ /* Set invert to this reference so \n+ that ~ will mean conjugation */\n+ /* Setup the array object's numerical structures */\n+ PyArray_SetNumericOps(d);\n+\n+ /* Reset dictionary so that \"invert\" will mean bitwise invert */\n+ /* PyDict_SetItemString(d, \"invert\", f2); \n+ Py_DECREF(f2) */\n+ PyDict_SetItemString(d, \"conj\", f1); /* shorthand for conjugate */\n+ \n+ /* Check for errors */\n+ if (PyErr_Occurred())\n+\tPy_FatalError(\"can't initialize module fast_umath\");\n+}\n+\n", + "added_lines": 2308, + "deleted_lines": 0, + "source_code": "\n#include \"Python.h\"\n#include \"Numeric/arrayobject.h\"\n#include \"Numeric/ufuncobject.h\"\n#include \"abstract.h\"\n#include \n\n/* Fast umath module whose functions do not check for range and domain errors.\n\n Replacement for umath\n */\n\n\n#ifndef CHAR_BIT\n#define CHAR_BIT 8\n#endif\n\n#ifndef LONG_BIT\n#define LONG_BIT (CHAR_BIT * sizeof(long))\n#endif\n\n#ifndef INT_BIT\n#define INT_BIT (CHAR_BIT * sizeof(int))\n#endif\n\n#ifndef SHORT_BIT\n#define SHORT_BIT (CHAR_BIT * sizeof(short))\n#endif\n\n/* A whole slew of basic math functions are provided by Konrad Hinsen. */\n\n#if !defined(__STDC__) && !defined(_MSC_VER)\nextern double fmod (double, double);\nextern double frexp (double, int *);\nextern double ldexp (double, int);\nextern double modf (double, double *);\n#endif\n\n#ifndef M_PI\n#define M_PI 3.14159265359\n#endif\n\n#if !defined(HAVE_INVERSE_HYPERBOLIC)\nstatic double acosh(double x)\n{\n return log(x + sqrt((x-1.0)*(x+1.0)));\n}\n\nstatic double asinh(double xx)\n{\n double x;\n int sign;\n if (x < 0.0) {\n\tsign = -1;\n\tx = -xx;\n }\n else {\n\tsign = 1;\n\tx = xx;\n }\n return sign*log(x + sqrt(x*x+1.0));\n}\n\nstatic double atanh(double x)\n{\n return 0.5*log((1.0+x)/(1.0-x));\n}\n#endif\n\n#if defined(HAVE_HYPOT) \n#if !defined(NeXT) && !defined(_MSC_VER)\nextern double hypot(double, double);\n#endif\n#else\ndouble hypot(double x, double y)\n{\n double yx;\n\n x = fabs(x);\n y = fabs(y);\n if (x < y) {\n\tdouble temp = x;\n\tx = y;\n\ty = temp;\n }\n if (x == 0.)\n\treturn 0.;\n else {\n\tyx = y/x;\n\treturn x*sqrt(1.+yx*yx);\n }\n}\n#endif\n\n#ifdef i860\n/* Cray APP has bogus definition of HUGE_VAL in */\n#undef HUGE_VAL\n#endif\n\n#ifdef HUGE_VAL\n#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE\n#else\n#define CHECK(x) /* Don't know how to check */\n#endif\n\n\n\n/* First, the C functions that do the real work */\n\n/* constants */\nstatic Py_complex c_1 = {1., 0.};\nstatic Py_complex c_half = {0.5, 0.};\nstatic Py_complex c_i = {0., 1.};\nstatic Py_complex c_i2 = {0., 0.5};\nstatic Py_complex c_mi = {0., -1.};\nstatic Py_complex c_pi2 = {M_PI/2., 0.};\n\nstatic Py_complex c_quot_fast(Py_complex a, Py_complex b)\n{\n /******************************************************************/\n \n /* This algorithm is better, and is pretty obvious: first divide the\n * numerators and denominator by whichever of {b.real, b.imag} has\n * larger magnitude. The earliest reference I found was to CACM\n * Algorithm 116 (Complex Division, Robert L. Smith, Stanford\n * University). As usual, though, we're still ignoring all IEEE\n * endcases.\n */\n Py_complex r; /* the result */\n\n const double abs_breal = b.real < 0 ? -b.real : b.real;\n const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;\n\n if ((b.real == 0.0) && (b.imag == 0.0)) {\n\tr.real = a.real / b.real;\n\tr.imag = a.imag / b.imag;\n/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */\n/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */\n/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */\n\t\n/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */\n/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */\n/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */\n\treturn r;\n }\n \n if (abs_breal >= abs_bimag) {\n\t/* divide tops and bottom by b.real */\n\tconst double ratio = b.imag / b.real;\n\tconst double denom = b.real + b.imag * ratio;\n\tr.real = (a.real + a.imag * ratio) / denom;\n\tr.imag = (a.imag - a.real * ratio) / denom;\n }\n else {\n\t/* divide tops and bottom by b.imag */\n\tconst double ratio = b.real / b.imag;\n\tconst double denom = b.real * ratio + b.imag;\n\tr.real = (a.real * ratio + a.imag) / denom;\n\tr.imag = (a.imag * ratio - a.real) / denom;\n }\n return r;\n}\n\nstatic Py_complex c_sqrt(Py_complex x)\n{\n Py_complex r;\n double s,d;\n if (x.real == 0. && x.imag == 0.)\n\tr = x;\n else {\n\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));\n\td = 0.5*x.imag/s;\n\tif (x.real > 0.) {\n\t r.real = s;\n\t r.imag = d;\n\t}\n\telse if (x.imag >= 0.) {\n\t r.real = d;\n\t r.imag = s;\n\t}\n\telse {\n\t r.real = -d;\n\t r.imag = -s;\n\t}\n }\n return r;\n}\n\nstatic Py_complex c_log(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real);\n r.real = log(l);\n return r;\n}\n\nstatic Py_complex c_prodi(Py_complex x)\n{\n Py_complex r;\n r.real = -x.imag;\n r.imag = x.real;\n return r;\n}\n\nstatic Py_complex c_acos(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,\n\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));\n}\n\nstatic Py_complex c_acosh(Py_complex x)\n{\n return c_log(c_sum(x,c_prod(c_i,\n\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));\n}\n\nstatic Py_complex c_asin(Py_complex x)\n{\n return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),\n\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));\n}\n\nstatic Py_complex c_asinh(Py_complex x)\n{\n return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));\n}\n\nstatic Py_complex c_atan(Py_complex x)\n{\n return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));\n}\n\nstatic Py_complex c_atanh(Py_complex x)\n{\n return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));\n}\n\nstatic Py_complex c_cos(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.real)*cosh(x.imag);\n r.imag = -sin(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_cosh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*cosh(x.real);\n r.imag = sin(x.imag)*sinh(x.real);\n return r;\n}\n\nstatic Py_complex c_exp(Py_complex x)\n{\n Py_complex r;\n double l = exp(x.real);\n r.real = l*cos(x.imag);\n r.imag = l*sin(x.imag);\n return r;\n}\n\nstatic Py_complex c_log10(Py_complex x)\n{\n Py_complex r;\n double l = hypot(x.real,x.imag);\n r.imag = atan2(x.imag, x.real)/log(10.);\n r.real = log10(l);\n return r;\n}\n\nstatic Py_complex c_sin(Py_complex x)\n{\n Py_complex r;\n r.real = sin(x.real)*cosh(x.imag);\n r.imag = cos(x.real)*sinh(x.imag);\n return r;\n}\n\nstatic Py_complex c_sinh(Py_complex x)\n{\n Py_complex r;\n r.real = cos(x.imag)*sinh(x.real);\n r.imag = sin(x.imag)*cosh(x.real);\n return r;\n}\n\nstatic Py_complex c_tan(Py_complex x)\n{\n Py_complex r;\n double sr,cr,shi,chi;\n double rs,is,rc,ic;\n double d;\n sr = sin(x.real);\n cr = cos(x.real);\n shi = sinh(x.imag);\n chi = cosh(x.imag);\n rs = sr*chi;\n is = cr*shi;\n rc = cr*chi;\n ic = -sr*shi;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic Py_complex c_tanh(Py_complex x)\n{\n Py_complex r;\n double si,ci,shr,chr;\n double rs,is,rc,ic;\n double d;\n si = sin(x.imag);\n ci = cos(x.imag);\n shr = sinh(x.real);\n chr = cosh(x.real);\n rs = ci*shr;\n is = si*chr;\n rc = ci*chr;\n ic = si*shr;\n d = rc*rc + ic*ic;\n r.real = (rs*rc+is*ic)/d;\n r.imag = (is*rc-rs*ic)/d;\n return r;\n}\n\nstatic long powll(long x, long n, int nbits)\n /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */\n{\n long r = 1;\n long p = x;\n double logtwox;\n long mask = 1;\n if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");\n if (x != 0) {\n\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);\n\tif (logtwox * (double) n > (double) nbits)\n\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");\n }\n while (mask > 0 && n >= mask) {\n\tif (n & mask)\n\t r *= p;\n\tmask <<= 1;\n\tp *= p;\n }\n return r;\n}\n\nstatic void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i 255) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((unsigned char *)op)=(unsigned char) x;\n }\n}\nstatic void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int x;\n for(i=0; i 127 || x < -128) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((signed char *)op)=(signed char) x;\n }\n}\nstatic void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n short a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (SHORT_BIT/2);\n\tbh = b >> (SHORT_BIT/2);\n\t/* Quick test for common case: two small positive shorts */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (SHORT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((short *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (SHORT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((short *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (SHORT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (SHORT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (SHORT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((short *)op)=s*x;\n }\n}\nstatic void INT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n int a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (INT_BIT/2);\n\tbh = b >> (INT_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (INT_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((int *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (INT_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((int *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1 << (INT_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1 << (INT_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (INT_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((int *)op)=s*x;\n }\n}\nstatic void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n long a, b, ah, bh, x, y;\n int s;\n for(i=0; i> (LONG_BIT/2);\n\tbh = b >> (LONG_BIT/2);\n\t/* Quick test for common case: two small positive ints */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=x;\n\t\tcontinue;\n\t }\n\t}\n\t/* Arrange that a >= b >= 0 */\n\tif (a < 0) {\n\t a = -a;\n\t if (a < 0) {\n\t\t/* Largest negative */\n\t\tif (b == 0 || b == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t ah = a >> (LONG_BIT/2);\n\t}\n\tif (b < 0) {\n\t b = -b;\n\t if (b < 0) {\n\t\t/* Largest negative */\n\t\tif (a == 0 || a == 1) {\n\t\t *((long *)op)=a*b;\n\t\t continue;\n\t\t}\n\t\telse {\n\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\t return;\n\t\t}\n\t }\n\t s = -s;\n\t bh = b >> (LONG_BIT/2);\n\t}\n\t/* 1) both ah and bh > 0 : then report overflow */\n\tif (ah != 0 && bh != 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t/* 2) both ah and bh = 0 : then compute a*b and report\n\t overflow if it comes out negative */\n\tif (ah == 0 && bh == 0) {\n\t if ((x=a*b) < 0) {\n\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t\treturn;\n\t }\n\t else {\n\t\t*((long *)op)=s * x;\n\t\tcontinue;\n\t }\n\t}\n\tif (a < b) {\n\t /* Swap */\n\t x = a;\n\t a = b;\n\t b = x;\n\t ah = bh;\n\t /* bh not used beyond this point */\n\t}\n\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if\n\t it's >= 2^31\n\t compute al*bl and report overflow if it's negative\n\t add (ah*bl)<<32 to al*bl and report overflow if\n\t it's negative\n\t (NB b == bl in this case, and we make a = al) */\n\ty = ah*b;\n\tif (y >= (1L << (LONG_BIT/2 - 1))) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\ta &= (1L << (LONG_BIT/2)) - 1;\n\tx = a*b;\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\tx += y << (LONG_BIT/2);\n\tif (x < 0) {\n\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");\n\t return;\n\t}\n\t*((long *)op)=s*x;\n }\n}\nstatic void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2);\n }\n}\nstatic void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2);\n }\n}\nstatic void INT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2);\n }\n}\nstatic void LONG_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2);\n }\n}\nstatic void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2);\n }\n}\nstatic void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2);\n }\n}\nstatic void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((signed char *)i2);\n }\n}\nstatic void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((short *)i2);\n }\n}\nstatic void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((int *)i2);\n }\n}\nstatic void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((long *)i2);\n }\n}\nstatic void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((float *)i2);\n }\n}\nstatic void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i= *((double *)i2);\n }\n}\nstatic void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);\n }\n}\nstatic void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);\n }\n}\nstatic void INT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);\n }\n}\nstatic void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);\n }\n}\nstatic void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);\n }\n}\nstatic void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);\n }\n}\nstatic void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((unsigned char *)i2);\n }\n}\nstatic void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((signed char *)i2);\n }\n}\nstatic void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((short *)i2);\n }\n}\nstatic void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((int *)i2);\n }\n}\nstatic void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {\n int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];\n char *i1=args[0], *i2=args[1], *op=args[2];\n for(i=0; i> *((long *)i2);\n }\n}\n\nstatic PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };\nstatic PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };\nstatic PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };\nstatic PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };\nstatic PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };\nstatic PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };\nstatic PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, };\nstatic PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, };\nstatic PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, };\nstatic PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, };\nstatic PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};\nstatic PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};\nstatic PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };\nstatic PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };\nstatic PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };\nstatic PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };\nstatic PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };\nstatic PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };\nstatic PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };\nstatic PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };\nstatic PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };\nstatic PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };\nstatic PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };\nstatic PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };\nstatic PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };\nstatic PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };\nstatic void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};\nstatic void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};\nstatic void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };\nstatic void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };\nstatic void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };\nstatic void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };\nstatic void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };\nstatic void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };\nstatic void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };\nstatic void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };\nstatic void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };\nstatic void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };\nstatic void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };\nstatic void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };\nstatic void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };\nstatic void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };\nstatic void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };\nstatic void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };\nstatic void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };\nstatic void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };\nstatic void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };\nstatic void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };\nstatic void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };\nstatic void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };\nstatic void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };\nstatic char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_LONG, PyArray_UBYTE, PyArray_UBYTE, PyArray_LONG, PyArray_SBYTE, PyArray_SBYTE, PyArray_LONG, PyArray_SHORT, PyArray_SHORT, PyArray_LONG, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_LONG, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_LONG, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_LONG};\nstatic char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_LONG, PyArray_SBYTE, PyArray_SBYTE, PyArray_LONG, PyArray_SHORT, PyArray_SHORT, PyArray_LONG, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_LONG, };\nstatic char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, };\nstatic char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };\nstatic void InitOperators(PyObject *dictionary) {\n PyObject *f;\n\n add_data[9] =(void *)PyNumber_Add;\n subtract_data[9] = (void *)PyNumber_Subtract;\n multiply_data[7] = (void *)c_prod;\n multiply_data[8] = (void *)c_prod;\n multiply_data[9] = (void *)PyNumber_Multiply;\n divide_data[7] = (void *)c_quot_fast;\n divide_data[8] = (void *)c_quot_fast;\n divide_data[9] = (void *)PyNumber_Divide;\n divide_safe_data[7] = (void *)c_quot;\n divide_safe_data[8] = (void *)c_quot;\n divide_safe_data[9] = (void *)PyNumber_Divide;\n conjugate_data[9] = (void *)\"conjugate\";\n remainder_data[5] = (void *)fmod;\n remainder_data[6] = (void *)fmod;\n remainder_data[7] = (void *)PyNumber_Remainder;\n power_data[5] = (void *)pow;\n power_data[6] = (void *)pow;\n power_data[7] = (void *)c_pow;\n power_data[8] = (void *)c_pow;\n power_data[9] = (void *)PyNumber_Power;\n absolute_data[8] = (void *)PyNumber_Absolute;\n negative_data[8] = (void *)PyNumber_Negative;\n bitwise_and_data[5] = (void *)PyNumber_And;\n bitwise_or_data[5] = (void *)PyNumber_Or;\n bitwise_xor_data[5] = (void *)PyNumber_Xor;\n invert_data[5] = (void *)PyNumber_Invert;\n left_shift_data[5] = (void *)PyNumber_Lshift;\n right_shift_data[5] = (void *)PyNumber_Rshift;\n\n\n add_functions[9] = PyUFunc_OO_O;\n subtract_functions[9] = PyUFunc_OO_O;\n multiply_functions[7] = PyUFunc_FF_F_As_DD_D;\n multiply_functions[8] = PyUFunc_DD_D;\n multiply_functions[9] = PyUFunc_OO_O;\n divide_functions[7] = PyUFunc_FF_F_As_DD_D;\n divide_functions[8] = PyUFunc_DD_D;\n divide_functions[9] = PyUFunc_OO_O;\n divide_safe_functions[7] = PyUFunc_FF_F_As_DD_D;\n divide_safe_functions[8] = PyUFunc_DD_D;\n divide_safe_functions[9] = PyUFunc_OO_O;\n conjugate_functions[9] = PyUFunc_O_O_method;\n remainder_functions[5] = PyUFunc_ff_f_As_dd_d;\n remainder_functions[6] = PyUFunc_dd_d;\n remainder_functions[7] = PyUFunc_OO_O;\n power_functions[5] = PyUFunc_ff_f_As_dd_d;\n power_functions[6] = PyUFunc_dd_d;\n power_functions[7] = PyUFunc_FF_F_As_DD_D;\n power_functions[8] = PyUFunc_DD_D;\n power_functions[9] = PyUFunc_OO_O;\n absolute_functions[8] = PyUFunc_O_O;\n negative_functions[8] = PyUFunc_O_O;\n bitwise_and_functions[5] = PyUFunc_OO_O;\n bitwise_or_functions[5] = PyUFunc_OO_O;\n bitwise_xor_functions[5] = PyUFunc_OO_O;\n invert_functions[5] = PyUFunc_O_O;\n left_shift_functions[5] = PyUFunc_OO_O;\n right_shift_functions[5] = PyUFunc_OO_O;\n arccos_functions[0] = PyUFunc_f_f_As_d_d;\n arccos_functions[1] = PyUFunc_d_d;\n arccos_functions[2] = PyUFunc_F_F_As_D_D;\n arccos_functions[3] = PyUFunc_D_D;\n arccos_functions[4] = PyUFunc_O_O_method;\n ceil_functions[0] = PyUFunc_f_f_As_d_d;\n ceil_functions[1] = PyUFunc_d_d;\n ceil_functions[2] = PyUFunc_O_O_method;\n arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;\n arctan2_functions[1] = PyUFunc_dd_d;\n arctan2_functions[2] = PyUFunc_O_O_method;\n\n f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10, \n\t\t\t\t2, 1, PyUFunc_Zero, \"add\", \n\t\t\t\t\"Add the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"add\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\", \n\t\t\t\t\"Subtract the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"subtract\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\", \n\t\t\t\t\"Multiply the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"multiply\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\", \n\t\t\t\t\"Divide the arguments elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"divide\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\", \n\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);\n PyDict_SetItemString(dictionary, \"divide_safe\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures, \n\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\", \n\t\t\t\t\"returns conjugate of each element\", 0);\n PyDict_SetItemString(dictionary, \"conjugate\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures, \n\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\", \n\t\t\t\t\"returns remainder of division elementwise\", 0);\n PyDict_SetItemString(dictionary, \"remainder\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures, \n\t\t\t\t10, 2, 1, PyUFunc_One, \"power\", \n\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"power\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\", \n\t\t\t\t\"returns absolute value of each element\", 0);\n PyDict_SetItemString(dictionary, \"absolute\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures, \n\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\", \n\t\t\t\t\"negative(x) == -x elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"negative\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_None, \"greater\", \n\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);\n PyDict_SetItemString(dictionary, \"greater\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_None, \"greater_equal\", \n\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"greater_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_None, \"less\", \n\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_None, \"less_equal\", \n\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"less_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\", \n\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures, \n\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\", \n\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"not_equal\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_One, \"logical_and\", \n\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_Zero, \"logical_or\", \n\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_None, \"logical_xor\", \n\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);\n PyDict_SetItemString(dictionary, \"logical_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures, \n\t\t\t\t7, 1, 1, PyUFunc_None, \"logical_not\", \n\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);\n PyDict_SetItemString(dictionary, \"logical_not\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, divide_safe_signatures, \n\t\t\t\t7, 2, 1, PyUFunc_None, \"maximum\", \n\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"maximum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, divide_safe_signatures,\n\t\t\t\t7, 2, 1, PyUFunc_None, \"minimum\", \n\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"minimum\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\", \n\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_and\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\", \n\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_or\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\", \n\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);\n PyDict_SetItemString(dictionary, \"bitwise_xor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures, \n\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\", \n\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);\n PyDict_SetItemString(dictionary, \"invert\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\", \n\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"left_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures, \n\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\", \n\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"right_shift\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\", \n\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\", \n\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\", \n\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",\n\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"arctanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",\n\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"arccosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",\n\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"arcsinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\", \n\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cos\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\", \n\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);\n PyDict_SetItemString(dictionary, \"cosh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\", \n\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);\n PyDict_SetItemString(dictionary, \"exp\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log\", \n\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\", \n\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);\n PyDict_SetItemString(dictionary, \"log10\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\", \n\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);\n PyDict_SetItemString(dictionary, \"sin\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\", \n\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);\n PyDict_SetItemString(dictionary, \"sinh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",\n\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);\n PyDict_SetItemString(dictionary, \"sqrt\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\", \n\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tan\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures, \n\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\", \n\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);\n PyDict_SetItemString(dictionary, \"tanh\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\", \n\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);\n PyDict_SetItemString(dictionary, \"ceil\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\", \n\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);\n\n PyDict_SetItemString(dictionary, \"fabs\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures, \n\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\", \n\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);\n PyDict_SetItemString(dictionary, \"floor\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\", \n\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);\n PyDict_SetItemString(dictionary, \"arctan2\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\", \n\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);\n PyDict_SetItemString(dictionary, \"fmod\", f);\n Py_DECREF(f);\n f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures, \n\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\", \n\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);\n PyDict_SetItemString(dictionary, \"hypot\", f);\n Py_DECREF(f);\n}\n\n\n/* Initialization function for the module (*must* be called initArray) */\n\nstatic struct PyMethodDef methods[] = {\n {NULL,\t\tNULL, 0}\t\t/* sentinel */\n};\n\nDL_EXPORT(void) initfastumath() {\n PyObject *m, *d, *s, *f1, *f2;\n \n /* Create the module and add the functions */\n m = Py_InitModule(\"fastumath\", methods); \n\n /* Import the array and ufunc objects */\n import_array();\n import_ufunc();\n\n /* Add some symbolic constants to the module */\n d = PyModule_GetDict(m);\n\n s = PyString_FromString(\"1.0\");\n PyDict_SetItemString(d, \"__version__\", s);\n Py_DECREF(s);\n\n /* Load the ufunc operators into the array module's namespace */\n InitOperators(d); \n\n PyDict_SetItemString(d, \"pi\", s = PyFloat_FromDouble(atan(1.0) * 4.0));\n Py_DECREF(s);\n PyDict_SetItemString(d, \"e\", s = PyFloat_FromDouble(exp(1.0)));\n Py_DECREF(s);\n\n\n /* Temporarily set \"invert\" to \"conjugate\" in the dictionary so the call\n to SetNumericOps will make ~ do complex conjugation */\n\n f1 = PyDict_GetItemString(d, \"conjugate\"); /* Borrowed reference */\n /* f2 = PyDict_GetItemString(d, \"invert\"); */ /* Borrowed reference */\n /* Py_INCREF(f2);*//*so we must incref it or it will be destroyed on next line*/\n /* PyDict_SetItemString(d, \"invert\", f1);*/ /* Set invert to this reference so \n that ~ will mean conjugation */\n /* Setup the array object's numerical structures */\n PyArray_SetNumericOps(d);\n\n /* Reset dictionary so that \"invert\" will mean bitwise invert */\n /* PyDict_SetItemString(d, \"invert\", f2); \n Py_DECREF(f2) */\n PyDict_SetItemString(d, \"conj\", f1); /* shorthand for conjugate */\n \n /* Check for errors */\n if (PyErr_Occurred())\n\tPy_FatalError(\"can't initialize module fast_umath\");\n}\n\n", + "source_code_before": null, + "methods": [ + { + "name": "acosh", + "long_name": "acosh( double x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "x" + ], + "start_line": 44, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "asinh", + "long_name": "asinh( double xx)", + "filename": "fastumathmodule.c", + "nloc": 14, + "complexity": 2, + "token_count": 59, + "parameters": [ + "xx" + ], + "start_line": 49, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "atanh", + "long_name": "atanh( double x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 25, + "parameters": [ + "x" + ], + "start_line": 64, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "hypot", + "long_name": "hypot( double x , double y)", + "filename": "fastumathmodule.c", + "nloc": 17, + "complexity": 3, + "token_count": 78, + "parameters": [ + "x", + "y" + ], + "start_line": 75, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "c_quot_fast", + "long_name": "c_quot_fast( Py_complex a , Py_complex b)", + "filename": "fastumathmodule.c", + "nloc": 24, + "complexity": 6, + "token_count": 236, + "parameters": [ + "a", + "b" + ], + "start_line": 118, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "c_sqrt", + "long_name": "c_sqrt( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 24, + "complexity": 5, + "token_count": 138, + "parameters": [ + "x" + ], + "start_line": 164, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "c_log", + "long_name": "c_log( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 8, + "complexity": 1, + "token_count": 51, + "parameters": [ + "x" + ], + "start_line": 189, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "c_prodi", + "long_name": "c_prodi( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 30, + "parameters": [ + "x" + ], + "start_line": 198, + "end_line": 204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_acos", + "long_name": "c_acos( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 5, + "complexity": 1, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 206, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "c_acosh", + "long_name": "c_acosh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "x" + ], + "start_line": 212, + "end_line": 216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "c_asin", + "long_name": "c_asin( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 5, + "complexity": 1, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 218, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "c_asinh", + "long_name": "c_asinh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 34, + "parameters": [ + "x" + ], + "start_line": 224, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "c_atan", + "long_name": "c_atan( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "x" + ], + "start_line": 229, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "c_atanh", + "long_name": "c_atanh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "x" + ], + "start_line": 234, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "c_cos", + "long_name": "c_cos( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 50, + "parameters": [ + "x" + ], + "start_line": 239, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_cosh", + "long_name": "c_cosh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 247, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_exp", + "long_name": "c_exp( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 8, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 255, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "c_log10", + "long_name": "c_log10( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 8, + "complexity": 1, + "token_count": 56, + "parameters": [ + "x" + ], + "start_line": 264, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "c_sin", + "long_name": "c_sin( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 273, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_sinh", + "long_name": "c_sinh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 281, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_tan", + "long_name": "c_tan( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 19, + "complexity": 1, + "token_count": 137, + "parameters": [ + "x" + ], + "start_line": 289, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "c_tanh", + "long_name": "c_tanh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 19, + "complexity": 1, + "token_count": 136, + "parameters": [ + "x" + ], + "start_line": 309, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "powll", + "long_name": "powll( long x , long n , int nbits)", + "filename": "fastumathmodule.c", + "nloc": 20, + "complexity": 7, + "token_count": 129, + "parameters": [ + "x", + "n", + "nbits" + ], + "start_line": 329, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_add", + "long_name": "UBYTE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 351, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_add", + "long_name": "SBYTE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 358, + "end_line": 364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_add", + "long_name": "SHORT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 365, + "end_line": 371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_add", + "long_name": "INT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 372, + "end_line": 378, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_add", + "long_name": "LONG_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 379, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_add", + "long_name": "FLOAT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 386, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_add", + "long_name": "DOUBLE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 393, + "end_line": 399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_add", + "long_name": "CFLOAT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 400, + "end_line": 406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_add", + "long_name": "CDOUBLE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 407, + "end_line": 413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_subtract", + "long_name": "UBYTE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 414, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_subtract", + "long_name": "SBYTE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 421, + "end_line": 427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_subtract", + "long_name": "SHORT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 428, + "end_line": 434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_subtract", + "long_name": "INT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 435, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_subtract", + "long_name": "LONG_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 442, + "end_line": 448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_subtract", + "long_name": "FLOAT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 449, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_subtract", + "long_name": "DOUBLE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 456, + "end_line": 462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_subtract", + "long_name": "CFLOAT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 463, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_subtract", + "long_name": "CDOUBLE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 470, + "end_line": 476, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_multiply", + "long_name": "UBYTE_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 174, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 477, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_multiply", + "long_name": "SBYTE_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 13, + "complexity": 4, + "token_count": 176, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 490, + "end_line": 502, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "SHORT_multiply", + "long_name": "SHORT_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 90, + "complexity": 22, + "token_count": 581, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 503, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "INT_multiply", + "long_name": "INT_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 90, + "complexity": 22, + "token_count": 581, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 608, + "end_line": 712, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "LONG_multiply", + "long_name": "LONG_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 90, + "complexity": 22, + "token_count": 581, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 713, + "end_line": 817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_multiply", + "long_name": "FLOAT_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 818, + "end_line": 824, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_multiply", + "long_name": "DOUBLE_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 825, + "end_line": 831, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_divide", + "long_name": "UBYTE_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 832, + "end_line": 838, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_divide", + "long_name": "SBYTE_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 839, + "end_line": 845, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_divide", + "long_name": "SHORT_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 846, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_divide", + "long_name": "INT_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 853, + "end_line": 859, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_divide", + "long_name": "LONG_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 860, + "end_line": 866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_divide", + "long_name": "FLOAT_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 867, + "end_line": 873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_divide", + "long_name": "DOUBLE_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 874, + "end_line": 880, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_divide_safe", + "long_name": "UBYTE_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 881, + "end_line": 887, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_divide_safe", + "long_name": "SBYTE_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 888, + "end_line": 894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_divide_safe", + "long_name": "SHORT_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 895, + "end_line": 901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_divide_safe", + "long_name": "INT_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 902, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_divide_safe", + "long_name": "LONG_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 909, + "end_line": 915, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_divide_safe", + "long_name": "FLOAT_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 916, + "end_line": 922, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_divide_safe", + "long_name": "DOUBLE_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 923, + "end_line": 929, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_conjugate", + "long_name": "UBYTE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 930, + "end_line": 931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_conjugate", + "long_name": "SBYTE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 932, + "end_line": 933, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_conjugate", + "long_name": "SHORT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 934, + "end_line": 935, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_conjugate", + "long_name": "INT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 936, + "end_line": 937, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_conjugate", + "long_name": "LONG_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 938, + "end_line": 939, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_conjugate", + "long_name": "FLOAT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 940, + "end_line": 941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_conjugate", + "long_name": "DOUBLE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 942, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_conjugate", + "long_name": "CFLOAT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 115, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 944, + "end_line": 945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_conjugate", + "long_name": "CDOUBLE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 115, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 946, + "end_line": 947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_remainder", + "long_name": "UBYTE_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 948, + "end_line": 954, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_remainder", + "long_name": "SBYTE_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 955, + "end_line": 961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_remainder", + "long_name": "SHORT_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 962, + "end_line": 968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_remainder", + "long_name": "INT_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 969, + "end_line": 975, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_remainder", + "long_name": "LONG_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 976, + "end_line": 982, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_power", + "long_name": "UBYTE_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 142, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 983, + "end_line": 989, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_power", + "long_name": "SBYTE_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 142, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 990, + "end_line": 996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_power", + "long_name": "SHORT_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 140, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 997, + "end_line": 1003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_power", + "long_name": "INT_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1004, + "end_line": 1010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_power", + "long_name": "LONG_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1011, + "end_line": 1017, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_absolute", + "long_name": "SBYTE_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 113, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1018, + "end_line": 1019, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_absolute", + "long_name": "SHORT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1020, + "end_line": 1021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_absolute", + "long_name": "INT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1022, + "end_line": 1023, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_absolute", + "long_name": "LONG_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1024, + "end_line": 1025, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_absolute", + "long_name": "FLOAT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1026, + "end_line": 1027, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_absolute", + "long_name": "DOUBLE_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1028, + "end_line": 1029, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_absolute", + "long_name": "CFLOAT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 129, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1030, + "end_line": 1031, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_absolute", + "long_name": "CDOUBLE_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 126, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1032, + "end_line": 1033, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_negative", + "long_name": "SBYTE_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 91, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1034, + "end_line": 1035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_negative", + "long_name": "SHORT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1036, + "end_line": 1037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_negative", + "long_name": "INT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1038, + "end_line": 1039, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_negative", + "long_name": "LONG_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1040, + "end_line": 1041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_negative", + "long_name": "FLOAT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1042, + "end_line": 1043, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_negative", + "long_name": "DOUBLE_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1044, + "end_line": 1045, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_negative", + "long_name": "CFLOAT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 116, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1046, + "end_line": 1047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_negative", + "long_name": "CDOUBLE_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 116, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1048, + "end_line": 1049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_greater", + "long_name": "UBYTE_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1050, + "end_line": 1056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_greater", + "long_name": "SBYTE_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1057, + "end_line": 1063, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_greater", + "long_name": "SHORT_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1064, + "end_line": 1070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_greater", + "long_name": "INT_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1071, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_greater", + "long_name": "LONG_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1078, + "end_line": 1084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_greater", + "long_name": "FLOAT_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1085, + "end_line": 1091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_greater", + "long_name": "DOUBLE_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1092, + "end_line": 1098, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_greater_equal", + "long_name": "UBYTE_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1099, + "end_line": 1105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_greater_equal", + "long_name": "SBYTE_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1106, + "end_line": 1112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_greater_equal", + "long_name": "SHORT_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1113, + "end_line": 1119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_greater_equal", + "long_name": "INT_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1120, + "end_line": 1126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_greater_equal", + "long_name": "LONG_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1127, + "end_line": 1133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_greater_equal", + "long_name": "FLOAT_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1134, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_greater_equal", + "long_name": "DOUBLE_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1141, + "end_line": 1147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_less", + "long_name": "UBYTE_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1148, + "end_line": 1154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_less", + "long_name": "SBYTE_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1155, + "end_line": 1161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_less", + "long_name": "SHORT_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1162, + "end_line": 1168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_less", + "long_name": "INT_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1169, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_less", + "long_name": "LONG_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1176, + "end_line": 1182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_less", + "long_name": "FLOAT_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1183, + "end_line": 1189, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_less", + "long_name": "DOUBLE_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1190, + "end_line": 1196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_less_equal", + "long_name": "UBYTE_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1197, + "end_line": 1203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_less_equal", + "long_name": "SBYTE_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1204, + "end_line": 1210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_less_equal", + "long_name": "SHORT_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1211, + "end_line": 1217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_less_equal", + "long_name": "INT_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1218, + "end_line": 1224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_less_equal", + "long_name": "LONG_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1225, + "end_line": 1231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_less_equal", + "long_name": "FLOAT_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1232, + "end_line": 1238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_less_equal", + "long_name": "DOUBLE_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1239, + "end_line": 1245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CHAR_equal", + "long_name": "CHAR_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1246, + "end_line": 1252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_equal", + "long_name": "UBYTE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1253, + "end_line": 1259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_equal", + "long_name": "SBYTE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1260, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_equal", + "long_name": "SHORT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1267, + "end_line": 1273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_equal", + "long_name": "INT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1274, + "end_line": 1280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_equal", + "long_name": "LONG_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1281, + "end_line": 1287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_equal", + "long_name": "FLOAT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1288, + "end_line": 1294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_equal", + "long_name": "DOUBLE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1295, + "end_line": 1301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_equal", + "long_name": "CFLOAT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1302, + "end_line": 1308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_equal", + "long_name": "CDOUBLE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1309, + "end_line": 1315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "OBJECT_equal", + "long_name": "OBJECT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1316, + "end_line": 1322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CHAR_not_equal", + "long_name": "CHAR_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1323, + "end_line": 1329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_not_equal", + "long_name": "UBYTE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1330, + "end_line": 1336, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_not_equal", + "long_name": "SBYTE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1337, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_not_equal", + "long_name": "SHORT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1344, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_not_equal", + "long_name": "INT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1351, + "end_line": 1357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_not_equal", + "long_name": "LONG_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1358, + "end_line": 1364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_not_equal", + "long_name": "FLOAT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1365, + "end_line": 1371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_not_equal", + "long_name": "DOUBLE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1372, + "end_line": 1378, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_not_equal", + "long_name": "CFLOAT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1379, + "end_line": 1385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_not_equal", + "long_name": "CDOUBLE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1386, + "end_line": 1392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "OBJECT_not_equal", + "long_name": "OBJECT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1393, + "end_line": 1399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_and", + "long_name": "UBYTE_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1400, + "end_line": 1406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_and", + "long_name": "SBYTE_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1407, + "end_line": 1413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_and", + "long_name": "SHORT_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1414, + "end_line": 1420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_and", + "long_name": "INT_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1421, + "end_line": 1427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_and", + "long_name": "LONG_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1428, + "end_line": 1434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_and", + "long_name": "FLOAT_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 135, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1435, + "end_line": 1441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_and", + "long_name": "DOUBLE_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 135, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1442, + "end_line": 1448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_or", + "long_name": "UBYTE_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1449, + "end_line": 1455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_or", + "long_name": "SBYTE_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1456, + "end_line": 1462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_or", + "long_name": "SHORT_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1463, + "end_line": 1469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_or", + "long_name": "INT_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1470, + "end_line": 1476, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_or", + "long_name": "LONG_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1477, + "end_line": 1483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_or", + "long_name": "FLOAT_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 135, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1484, + "end_line": 1490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_or", + "long_name": "DOUBLE_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1491, + "end_line": 1497, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_xor", + "long_name": "UBYTE_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 158, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1498, + "end_line": 1504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_xor", + "long_name": "SBYTE_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 158, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1505, + "end_line": 1511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_xor", + "long_name": "SHORT_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1512, + "end_line": 1518, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_xor", + "long_name": "INT_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1519, + "end_line": 1525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_xor", + "long_name": "LONG_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1526, + "end_line": 1532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_xor", + "long_name": "FLOAT_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 158, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1533, + "end_line": 1539, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_xor", + "long_name": "DOUBLE_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1540, + "end_line": 1546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_not", + "long_name": "UBYTE_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 91, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1547, + "end_line": 1548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_not", + "long_name": "SBYTE_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 91, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1549, + "end_line": 1550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_not", + "long_name": "SHORT_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1551, + "end_line": 1552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_not", + "long_name": "INT_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1553, + "end_line": 1554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_not", + "long_name": "LONG_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1555, + "end_line": 1556, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_not", + "long_name": "FLOAT_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 94, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1557, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_not", + "long_name": "DOUBLE_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1559, + "end_line": 1560, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_maximum", + "long_name": "UBYTE_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1561, + "end_line": 1567, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_maximum", + "long_name": "SBYTE_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1568, + "end_line": 1574, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_maximum", + "long_name": "SHORT_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1575, + "end_line": 1581, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_maximum", + "long_name": "INT_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1582, + "end_line": 1588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_maximum", + "long_name": "LONG_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1589, + "end_line": 1595, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_maximum", + "long_name": "FLOAT_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1596, + "end_line": 1602, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_maximum", + "long_name": "DOUBLE_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1603, + "end_line": 1609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_minimum", + "long_name": "UBYTE_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1610, + "end_line": 1616, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_minimum", + "long_name": "SBYTE_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1617, + "end_line": 1623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_minimum", + "long_name": "SHORT_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1624, + "end_line": 1630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_minimum", + "long_name": "INT_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1631, + "end_line": 1637, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_minimum", + "long_name": "LONG_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1638, + "end_line": 1644, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_minimum", + "long_name": "FLOAT_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1645, + "end_line": 1651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_minimum", + "long_name": "DOUBLE_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1652, + "end_line": 1658, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_bitwise_and", + "long_name": "UBYTE_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1659, + "end_line": 1665, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_bitwise_and", + "long_name": "SBYTE_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1666, + "end_line": 1672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_bitwise_and", + "long_name": "SHORT_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1673, + "end_line": 1679, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_bitwise_and", + "long_name": "INT_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1680, + "end_line": 1686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_bitwise_and", + "long_name": "LONG_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1687, + "end_line": 1693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_bitwise_or", + "long_name": "UBYTE_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1694, + "end_line": 1700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_bitwise_or", + "long_name": "SBYTE_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1701, + "end_line": 1707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_bitwise_or", + "long_name": "SHORT_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1708, + "end_line": 1714, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_bitwise_or", + "long_name": "INT_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1715, + "end_line": 1721, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_bitwise_or", + "long_name": "LONG_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1722, + "end_line": 1728, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_bitwise_xor", + "long_name": "UBYTE_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1729, + "end_line": 1735, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_bitwise_xor", + "long_name": "SBYTE_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1736, + "end_line": 1742, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_bitwise_xor", + "long_name": "SHORT_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1743, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_bitwise_xor", + "long_name": "INT_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1750, + "end_line": 1756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_bitwise_xor", + "long_name": "LONG_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1757, + "end_line": 1763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_invert", + "long_name": "UBYTE_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1764, + "end_line": 1765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_invert", + "long_name": "SBYTE_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1766, + "end_line": 1767, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_invert", + "long_name": "SHORT_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1768, + "end_line": 1769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_invert", + "long_name": "INT_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1770, + "end_line": 1771, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_invert", + "long_name": "LONG_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1772, + "end_line": 1773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_left_shift", + "long_name": "UBYTE_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1774, + "end_line": 1780, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_left_shift", + "long_name": "SBYTE_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1781, + "end_line": 1787, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_left_shift", + "long_name": "SHORT_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1788, + "end_line": 1794, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_left_shift", + "long_name": "INT_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1795, + "end_line": 1801, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_left_shift", + "long_name": "LONG_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1802, + "end_line": 1808, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_right_shift", + "long_name": "UBYTE_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1809, + "end_line": 1815, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_right_shift", + "long_name": "SBYTE_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1816, + "end_line": 1822, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_right_shift", + "long_name": "SHORT_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1823, + "end_line": 1829, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_right_shift", + "long_name": "INT_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1830, + "end_line": 1836, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_right_shift", + "long_name": "LONG_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1837, + "end_line": 1843, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "InitOperators", + "long_name": "InitOperators( PyObject * dictionary)", + "filename": "fastumathmodule.c", + "nloc": 320, + "complexity": 1, + "token_count": 2543, + "parameters": [ + "dictionary" + ], + "start_line": 1929, + "end_line": 2253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 325, + "top_nesting_level": 0 + }, + { + "name": "initfastumath", + "long_name": "initfastumath()", + "filename": "fastumathmodule.c", + "nloc": 20, + "complexity": 2, + "token_count": 150, + "parameters": [], + "start_line": 2262, + "end_line": 2307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "DOUBLE_not_equal", + "long_name": "DOUBLE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1372, + "end_line": 1378, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_less_equal", + "long_name": "SBYTE_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1204, + "end_line": 1210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_and", + "long_name": "SHORT_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1414, + "end_line": 1420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_xor", + "long_name": "DOUBLE_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1540, + "end_line": 1546, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_maximum", + "long_name": "INT_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1582, + "end_line": 1588, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_minimum", + "long_name": "INT_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1631, + "end_line": 1637, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "atanh", + "long_name": "atanh( double x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 25, + "parameters": [ + "x" + ], + "start_line": 64, + "end_line": 67, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "c_acosh", + "long_name": "c_acosh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 5, + "complexity": 1, + "token_count": 36, + "parameters": [ + "x" + ], + "start_line": 212, + "end_line": 216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_not_equal", + "long_name": "UBYTE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1330, + "end_line": 1336, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_conjugate", + "long_name": "DOUBLE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 942, + "end_line": 943, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_maximum", + "long_name": "LONG_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1589, + "end_line": 1595, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_xor", + "long_name": "LONG_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1526, + "end_line": 1532, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_divide", + "long_name": "UBYTE_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 832, + "end_line": 838, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_bitwise_xor", + "long_name": "SBYTE_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1736, + "end_line": 1742, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_greater", + "long_name": "SHORT_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1064, + "end_line": 1070, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_equal", + "long_name": "CDOUBLE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1309, + "end_line": 1315, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_conjugate", + "long_name": "SBYTE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 932, + "end_line": 933, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_equal", + "long_name": "SHORT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1267, + "end_line": 1273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_divide", + "long_name": "SHORT_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 846, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_less_equal", + "long_name": "UBYTE_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1197, + "end_line": 1203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_asinh", + "long_name": "c_asinh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 34, + "parameters": [ + "x" + ], + "start_line": 224, + "end_line": 227, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "INT_subtract", + "long_name": "INT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 435, + "end_line": 441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_minimum", + "long_name": "UBYTE_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1610, + "end_line": 1616, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_right_shift", + "long_name": "INT_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1830, + "end_line": 1836, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_bitwise_xor", + "long_name": "SHORT_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1743, + "end_line": 1749, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_right_shift", + "long_name": "SBYTE_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1816, + "end_line": 1822, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_or", + "long_name": "INT_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1470, + "end_line": 1476, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_add", + "long_name": "INT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 372, + "end_line": 378, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_minimum", + "long_name": "LONG_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1638, + "end_line": 1644, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_not_equal", + "long_name": "LONG_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1358, + "end_line": 1364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_xor", + "long_name": "SBYTE_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 158, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1505, + "end_line": 1511, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_negative", + "long_name": "DOUBLE_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1044, + "end_line": 1045, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_invert", + "long_name": "LONG_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1772, + "end_line": 1773, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_and", + "long_name": "LONG_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1428, + "end_line": 1434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_bitwise_xor", + "long_name": "INT_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1750, + "end_line": 1756, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_invert", + "long_name": "UBYTE_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1764, + "end_line": 1765, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CHAR_not_equal", + "long_name": "CHAR_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1323, + "end_line": 1329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_bitwise_or", + "long_name": "SBYTE_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1701, + "end_line": 1707, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_greater_equal", + "long_name": "INT_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1120, + "end_line": 1126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_tan", + "long_name": "c_tan( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 19, + "complexity": 1, + "token_count": 137, + "parameters": [ + "x" + ], + "start_line": 289, + "end_line": 307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_not", + "long_name": "FLOAT_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 94, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1557, + "end_line": 1558, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_minimum", + "long_name": "SBYTE_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1617, + "end_line": 1623, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_multiply", + "long_name": "FLOAT_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 818, + "end_line": 824, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_left_shift", + "long_name": "SBYTE_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1781, + "end_line": 1787, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_bitwise_xor", + "long_name": "LONG_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1757, + "end_line": 1763, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_negative", + "long_name": "SBYTE_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 91, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1034, + "end_line": 1035, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_or", + "long_name": "LONG_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1477, + "end_line": 1483, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_conjugate", + "long_name": "UBYTE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 930, + "end_line": 931, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "c_quot_fast", + "long_name": "c_quot_fast( Py_complex a , Py_complex b)", + "filename": "fastumathmodule.c", + "nloc": 24, + "complexity": 6, + "token_count": 236, + "parameters": [ + "a", + "b" + ], + "start_line": 118, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 45, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_divide_safe", + "long_name": "UBYTE_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 881, + "end_line": 887, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_atan", + "long_name": "c_atan( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "x" + ], + "start_line": 229, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_divide_safe", + "long_name": "SBYTE_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 888, + "end_line": 894, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_greater_equal", + "long_name": "UBYTE_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1099, + "end_line": 1105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_xor", + "long_name": "INT_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1519, + "end_line": 1525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_cos", + "long_name": "c_cos( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 50, + "parameters": [ + "x" + ], + "start_line": 239, + "end_line": 245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_divide_safe", + "long_name": "LONG_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 909, + "end_line": 915, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_bitwise_and", + "long_name": "INT_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1680, + "end_line": 1686, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_greater", + "long_name": "DOUBLE_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1092, + "end_line": 1098, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_subtract", + "long_name": "UBYTE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 414, + "end_line": 420, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_less_equal", + "long_name": "DOUBLE_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1239, + "end_line": 1245, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "initfastumath", + "long_name": "initfastumath()", + "filename": "fastumathmodule.c", + "nloc": 20, + "complexity": 2, + "token_count": 150, + "parameters": [], + "start_line": 2262, + "end_line": 2307, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 46, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_maximum", + "long_name": "UBYTE_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1561, + "end_line": 1567, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_negative", + "long_name": "SHORT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1036, + "end_line": 1037, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "hypot", + "long_name": "hypot( double x , double y)", + "filename": "fastumathmodule.c", + "nloc": 17, + "complexity": 3, + "token_count": 78, + "parameters": [ + "x", + "y" + ], + "start_line": 75, + "end_line": 92, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "SHORT_not_equal", + "long_name": "SHORT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1344, + "end_line": 1350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_multiply", + "long_name": "LONG_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 90, + "complexity": 22, + "token_count": 581, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 713, + "end_line": 817, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "LONG_negative", + "long_name": "LONG_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1040, + "end_line": 1041, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_greater", + "long_name": "LONG_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1078, + "end_line": 1084, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_and", + "long_name": "FLOAT_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 135, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1435, + "end_line": 1441, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_not", + "long_name": "INT_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1553, + "end_line": 1554, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_absolute", + "long_name": "SBYTE_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 113, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1018, + "end_line": 1019, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_equal", + "long_name": "DOUBLE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1295, + "end_line": 1301, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_equal", + "long_name": "CFLOAT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1302, + "end_line": 1308, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_divide", + "long_name": "INT_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 853, + "end_line": 859, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_divide_safe", + "long_name": "INT_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 902, + "end_line": 908, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_sinh", + "long_name": "c_sinh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 281, + "end_line": 287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_greater_equal", + "long_name": "FLOAT_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1134, + "end_line": 1140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_or", + "long_name": "SBYTE_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1456, + "end_line": 1462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_negative", + "long_name": "INT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1038, + "end_line": 1039, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_absolute", + "long_name": "DOUBLE_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1028, + "end_line": 1029, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_and", + "long_name": "DOUBLE_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 135, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1442, + "end_line": 1448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_right_shift", + "long_name": "LONG_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1837, + "end_line": 1843, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_less_equal", + "long_name": "SHORT_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1211, + "end_line": 1217, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_equal", + "long_name": "UBYTE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1253, + "end_line": 1259, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_sin", + "long_name": "c_sin( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 273, + "end_line": 279, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "asinh", + "long_name": "asinh( double xx)", + "filename": "fastumathmodule.c", + "nloc": 14, + "complexity": 2, + "token_count": 59, + "parameters": [ + "xx" + ], + "start_line": 49, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_bitwise_and", + "long_name": "SBYTE_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1666, + "end_line": 1672, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_power", + "long_name": "LONG_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1011, + "end_line": 1017, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_subtract", + "long_name": "LONG_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 442, + "end_line": 448, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_negative", + "long_name": "FLOAT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1042, + "end_line": 1043, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_greater", + "long_name": "SBYTE_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1057, + "end_line": 1063, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_maximum", + "long_name": "DOUBLE_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1603, + "end_line": 1609, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_remainder", + "long_name": "UBYTE_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 948, + "end_line": 954, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_or", + "long_name": "DOUBLE_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1491, + "end_line": 1497, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_prodi", + "long_name": "c_prodi( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 30, + "parameters": [ + "x" + ], + "start_line": 198, + "end_line": 204, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_exp", + "long_name": "c_exp( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 8, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 255, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "c_cosh", + "long_name": "c_cosh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 1, + "token_count": 49, + "parameters": [ + "x" + ], + "start_line": 247, + "end_line": 253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_left_shift", + "long_name": "INT_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1795, + "end_line": 1801, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_subtract", + "long_name": "SBYTE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 421, + "end_line": 427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_divide_safe", + "long_name": "DOUBLE_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 923, + "end_line": 929, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_equal", + "long_name": "LONG_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1281, + "end_line": 1287, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "OBJECT_equal", + "long_name": "OBJECT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1316, + "end_line": 1322, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_or", + "long_name": "SHORT_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1463, + "end_line": 1469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_not_equal", + "long_name": "SBYTE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1337, + "end_line": 1343, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_invert", + "long_name": "SHORT_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1768, + "end_line": 1769, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_logical_not", + "long_name": "LONG_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1555, + "end_line": 1556, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_greater_equal", + "long_name": "SBYTE_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1106, + "end_line": 1112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_absolute", + "long_name": "INT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1022, + "end_line": 1023, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_less", + "long_name": "UBYTE_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1148, + "end_line": 1154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_logical_and", + "long_name": "INT_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1421, + "end_line": 1427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_greater", + "long_name": "FLOAT_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1085, + "end_line": 1091, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_left_shift", + "long_name": "UBYTE_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1774, + "end_line": 1780, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_power", + "long_name": "SHORT_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 140, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 997, + "end_line": 1003, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_minimum", + "long_name": "DOUBLE_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1652, + "end_line": 1658, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_add", + "long_name": "CFLOAT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 400, + "end_line": 406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_bitwise_or", + "long_name": "LONG_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1722, + "end_line": 1728, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_greater", + "long_name": "UBYTE_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1050, + "end_line": 1056, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_not_equal", + "long_name": "CDOUBLE_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1386, + "end_line": 1392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_minimum", + "long_name": "FLOAT_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1645, + "end_line": 1651, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_subtract", + "long_name": "FLOAT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 449, + "end_line": 455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_bitwise_and", + "long_name": "SHORT_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1673, + "end_line": 1679, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_conjugate", + "long_name": "FLOAT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 940, + "end_line": 941, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "c_tanh", + "long_name": "c_tanh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 19, + "complexity": 1, + "token_count": 136, + "parameters": [ + "x" + ], + "start_line": 309, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 19, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_conjugate", + "long_name": "CDOUBLE_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 115, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 946, + "end_line": 947, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_add", + "long_name": "SHORT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 365, + "end_line": 371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_less", + "long_name": "FLOAT_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1183, + "end_line": 1189, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_subtract", + "long_name": "CDOUBLE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 470, + "end_line": 476, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_negative", + "long_name": "CDOUBLE_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 116, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1048, + "end_line": 1049, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_less", + "long_name": "SBYTE_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1155, + "end_line": 1161, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_subtract", + "long_name": "CFLOAT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 463, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_subtract", + "long_name": "DOUBLE_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 456, + "end_line": 462, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_maximum", + "long_name": "SBYTE_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1568, + "end_line": 1574, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_power", + "long_name": "UBYTE_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 142, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 983, + "end_line": 989, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_less", + "long_name": "SHORT_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1162, + "end_line": 1168, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_logical_not", + "long_name": "DOUBLE_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1559, + "end_line": 1560, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_less_equal", + "long_name": "INT_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1218, + "end_line": 1224, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_greater_equal", + "long_name": "LONG_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1127, + "end_line": 1133, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "powll", + "long_name": "powll( long x , long n , int nbits)", + "filename": "fastumathmodule.c", + "nloc": 20, + "complexity": 7, + "token_count": 129, + "parameters": [ + "x", + "n", + "nbits" + ], + "start_line": 329, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "INT_equal", + "long_name": "INT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1274, + "end_line": 1280, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_bitwise_or", + "long_name": "UBYTE_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1694, + "end_line": 1700, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_left_shift", + "long_name": "SHORT_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1788, + "end_line": 1794, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CHAR_equal", + "long_name": "CHAR_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1246, + "end_line": 1252, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_absolute", + "long_name": "FLOAT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1026, + "end_line": 1027, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_add", + "long_name": "LONG_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 379, + "end_line": 385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_absolute", + "long_name": "LONG_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1024, + "end_line": 1025, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_equal", + "long_name": "SBYTE_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 132, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1260, + "end_line": 1266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_not", + "long_name": "SHORT_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 89, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1551, + "end_line": 1552, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "LONG_conjugate", + "long_name": "LONG_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 938, + "end_line": 939, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_or", + "long_name": "UBYTE_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1449, + "end_line": 1455, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_add", + "long_name": "UBYTE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 351, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_divide", + "long_name": "DOUBLE_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 874, + "end_line": 880, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_less_equal", + "long_name": "LONG_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1225, + "end_line": 1231, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_bitwise_and", + "long_name": "LONG_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1687, + "end_line": 1693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_sqrt", + "long_name": "c_sqrt( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 24, + "complexity": 5, + "token_count": 138, + "parameters": [ + "x" + ], + "start_line": 164, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 24, + "top_nesting_level": 0 + }, + { + "name": "INT_power", + "long_name": "INT_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1004, + "end_line": 1010, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_subtract", + "long_name": "SHORT_subtract( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 428, + "end_line": 434, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_not_equal", + "long_name": "CFLOAT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 160, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1379, + "end_line": 1385, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_and", + "long_name": "SBYTE_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1407, + "end_line": 1413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_divide_safe", + "long_name": "SHORT_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 895, + "end_line": 901, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_log", + "long_name": "c_log( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 8, + "complexity": 1, + "token_count": 51, + "parameters": [ + "x" + ], + "start_line": 189, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "acosh", + "long_name": "acosh( double x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 28, + "parameters": [ + "x" + ], + "start_line": 44, + "end_line": 47, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_add", + "long_name": "SBYTE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 358, + "end_line": 364, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_add", + "long_name": "CDOUBLE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 169, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 407, + "end_line": 413, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CDOUBLE_absolute", + "long_name": "CDOUBLE_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 126, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1032, + "end_line": 1033, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_less", + "long_name": "INT_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1169, + "end_line": 1175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_add", + "long_name": "FLOAT_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 386, + "end_line": 392, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_remainder", + "long_name": "LONG_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 976, + "end_line": 982, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_remainder", + "long_name": "SBYTE_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 955, + "end_line": 961, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_maximum", + "long_name": "FLOAT_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1596, + "end_line": 1602, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_xor", + "long_name": "FLOAT_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 158, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1533, + "end_line": 1539, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "OBJECT_not_equal", + "long_name": "OBJECT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 137, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1393, + "end_line": 1399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_bitwise_and", + "long_name": "UBYTE_bitwise_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1659, + "end_line": 1665, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_left_shift", + "long_name": "LONG_left_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1802, + "end_line": 1808, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_invert", + "long_name": "SBYTE_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 90, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1766, + "end_line": 1767, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_minimum", + "long_name": "SHORT_minimum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1624, + "end_line": 1630, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_add", + "long_name": "DOUBLE_add( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 393, + "end_line": 399, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_not", + "long_name": "UBYTE_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 91, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1547, + "end_line": 1548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_conjugate", + "long_name": "CFLOAT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 115, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 944, + "end_line": 945, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_greater_equal", + "long_name": "DOUBLE_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1141, + "end_line": 1147, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_logical_not", + "long_name": "SBYTE_logical_not( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 91, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1549, + "end_line": 1550, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_greater", + "long_name": "INT_greater( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1071, + "end_line": 1077, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_not_equal", + "long_name": "FLOAT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1365, + "end_line": 1371, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_bitwise_or", + "long_name": "SHORT_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1708, + "end_line": 1714, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "LONG_divide", + "long_name": "LONG_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 860, + "end_line": 866, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_divide", + "long_name": "FLOAT_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 867, + "end_line": 873, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_remainder", + "long_name": "SHORT_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 962, + "end_line": 968, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_absolute", + "long_name": "CFLOAT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 129, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1030, + "end_line": 1031, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_divide", + "long_name": "SBYTE_divide( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 154, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 839, + "end_line": 845, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_less", + "long_name": "DOUBLE_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1190, + "end_line": 1196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "InitOperators", + "long_name": "InitOperators( PyObject * dictionary)", + "filename": "fastumathmodule.c", + "nloc": 320, + "complexity": 1, + "token_count": 2543, + "parameters": [ + "dictionary" + ], + "start_line": 1929, + "end_line": 2253, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 325, + "top_nesting_level": 0 + }, + { + "name": "DOUBLE_multiply", + "long_name": "DOUBLE_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 825, + "end_line": 831, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_equal", + "long_name": "FLOAT_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1288, + "end_line": 1294, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_right_shift", + "long_name": "SHORT_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 131, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1823, + "end_line": 1829, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_conjugate", + "long_name": "SHORT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 934, + "end_line": 935, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_bitwise_or", + "long_name": "INT_bitwise_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1715, + "end_line": 1721, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "CFLOAT_negative", + "long_name": "CFLOAT_negative( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 116, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1046, + "end_line": 1047, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "c_acos", + "long_name": "c_acos( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 5, + "complexity": 1, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 206, + "end_line": 210, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "INT_multiply", + "long_name": "INT_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 90, + "complexity": 22, + "token_count": 581, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 608, + "end_line": 712, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "LONG_less", + "long_name": "LONG_less( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1176, + "end_line": 1182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "INT_remainder", + "long_name": "INT_remainder( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 969, + "end_line": 975, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_atanh", + "long_name": "c_atanh( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 4, + "complexity": 1, + "token_count": 33, + "parameters": [ + "x" + ], + "start_line": 234, + "end_line": 237, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_logical_or", + "long_name": "FLOAT_logical_or( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 135, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1484, + "end_line": 1490, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_xor", + "long_name": "UBYTE_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 158, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1498, + "end_line": 1504, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_multiply", + "long_name": "SBYTE_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 13, + "complexity": 4, + "token_count": 176, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 490, + "end_line": 502, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_bitwise_xor", + "long_name": "UBYTE_bitwise_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1729, + "end_line": 1735, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_multiply", + "long_name": "UBYTE_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 13, + "complexity": 3, + "token_count": 174, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 477, + "end_line": 489, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "INT_conjugate", + "long_name": "INT_conjugate( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 936, + "end_line": 937, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "INT_invert", + "long_name": "INT_invert( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 2, + "token_count": 88, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1770, + "end_line": 1771, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "SHORT_multiply", + "long_name": "SHORT_multiply( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 90, + "complexity": 22, + "token_count": 581, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 503, + "end_line": 607, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 105, + "top_nesting_level": 0 + }, + { + "name": "SBYTE_power", + "long_name": "SBYTE_power( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 142, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 990, + "end_line": 996, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_divide_safe", + "long_name": "FLOAT_divide_safe( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 150, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 916, + "end_line": 922, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_maximum", + "long_name": "SHORT_maximum( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 148, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1575, + "end_line": 1581, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_asin", + "long_name": "c_asin( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 5, + "complexity": 1, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 218, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "INT_not_equal", + "long_name": "INT_not_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1351, + "end_line": 1357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_logical_xor", + "long_name": "SHORT_logical_xor( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 5, + "token_count": 153, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1512, + "end_line": 1518, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_greater_equal", + "long_name": "SHORT_greater_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1113, + "end_line": 1119, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "SHORT_absolute", + "long_name": "SHORT_absolute( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 2, + "complexity": 3, + "token_count": 109, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1020, + "end_line": 1021, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_logical_and", + "long_name": "UBYTE_logical_and( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 3, + "token_count": 133, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1400, + "end_line": 1406, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "UBYTE_right_shift", + "long_name": "UBYTE_right_shift( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 134, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1809, + "end_line": 1815, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "c_log10", + "long_name": "c_log10( Py_complex x)", + "filename": "fastumathmodule.c", + "nloc": 8, + "complexity": 1, + "token_count": 56, + "parameters": [ + "x" + ], + "start_line": 264, + "end_line": 271, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "FLOAT_less_equal", + "long_name": "FLOAT_less_equal( char ** args , int * dimensions , int * steps , * func)", + "filename": "fastumathmodule.c", + "nloc": 7, + "complexity": 2, + "token_count": 130, + "parameters": [ + "args", + "dimensions", + "steps", + "func" + ], + "start_line": 1232, + "end_line": 1238, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "nloc": 2122, + "complexity": 570, + "token_count": 34901, + "diff_parsed": { + "added": [ + "", + "#include \"Python.h\"", + "#include \"Numeric/arrayobject.h\"", + "#include \"Numeric/ufuncobject.h\"", + "#include \"abstract.h\"", + "#include ", + "", + "/* Fast umath module whose functions do not check for range and domain errors.", + "", + " Replacement for umath", + " */", + "", + "", + "#ifndef CHAR_BIT", + "#define CHAR_BIT 8", + "#endif", + "", + "#ifndef LONG_BIT", + "#define LONG_BIT (CHAR_BIT * sizeof(long))", + "#endif", + "", + "#ifndef INT_BIT", + "#define INT_BIT (CHAR_BIT * sizeof(int))", + "#endif", + "", + "#ifndef SHORT_BIT", + "#define SHORT_BIT (CHAR_BIT * sizeof(short))", + "#endif", + "", + "/* A whole slew of basic math functions are provided by Konrad Hinsen. */", + "", + "#if !defined(__STDC__) && !defined(_MSC_VER)", + "extern double fmod (double, double);", + "extern double frexp (double, int *);", + "extern double ldexp (double, int);", + "extern double modf (double, double *);", + "#endif", + "", + "#ifndef M_PI", + "#define M_PI 3.14159265359", + "#endif", + "", + "#if !defined(HAVE_INVERSE_HYPERBOLIC)", + "static double acosh(double x)", + "{", + " return log(x + sqrt((x-1.0)*(x+1.0)));", + "}", + "", + "static double asinh(double xx)", + "{", + " double x;", + " int sign;", + " if (x < 0.0) {", + "\tsign = -1;", + "\tx = -xx;", + " }", + " else {", + "\tsign = 1;", + "\tx = xx;", + " }", + " return sign*log(x + sqrt(x*x+1.0));", + "}", + "", + "static double atanh(double x)", + "{", + " return 0.5*log((1.0+x)/(1.0-x));", + "}", + "#endif", + "", + "#if defined(HAVE_HYPOT)", + "#if !defined(NeXT) && !defined(_MSC_VER)", + "extern double hypot(double, double);", + "#endif", + "#else", + "double hypot(double x, double y)", + "{", + " double yx;", + "", + " x = fabs(x);", + " y = fabs(y);", + " if (x < y) {", + "\tdouble temp = x;", + "\tx = y;", + "\ty = temp;", + " }", + " if (x == 0.)", + "\treturn 0.;", + " else {", + "\tyx = y/x;", + "\treturn x*sqrt(1.+yx*yx);", + " }", + "}", + "#endif", + "", + "#ifdef i860", + "/* Cray APP has bogus definition of HUGE_VAL in */", + "#undef HUGE_VAL", + "#endif", + "", + "#ifdef HUGE_VAL", + "#define CHECK(x) if (errno != 0) ; \telse if (-HUGE_VAL <= (x) && (x) <= HUGE_VAL) ; \telse errno = ERANGE", + "#else", + "#define CHECK(x) /* Don't know how to check */", + "#endif", + "", + "", + "", + "/* First, the C functions that do the real work */", + "", + "/* constants */", + "static Py_complex c_1 = {1., 0.};", + "static Py_complex c_half = {0.5, 0.};", + "static Py_complex c_i = {0., 1.};", + "static Py_complex c_i2 = {0., 0.5};", + "static Py_complex c_mi = {0., -1.};", + "static Py_complex c_pi2 = {M_PI/2., 0.};", + "", + "static Py_complex c_quot_fast(Py_complex a, Py_complex b)", + "{", + " /******************************************************************/", + "", + " /* This algorithm is better, and is pretty obvious: first divide the", + " * numerators and denominator by whichever of {b.real, b.imag} has", + " * larger magnitude. The earliest reference I found was to CACM", + " * Algorithm 116 (Complex Division, Robert L. Smith, Stanford", + " * University). As usual, though, we're still ignoring all IEEE", + " * endcases.", + " */", + " Py_complex r; /* the result */", + "", + " const double abs_breal = b.real < 0 ? -b.real : b.real;", + " const double abs_bimag = b.imag < 0 ? -b.imag : b.imag;", + "", + " if ((b.real == 0.0) && (b.imag == 0.0)) {", + "\tr.real = a.real / b.real;", + "\tr.imag = a.imag / b.imag;", + "/* \tif (a.real == 0.0) {r.real = a.real/b.real;} */", + "/* \telse if (a.real < 0.0) {r.real = -1.0/0.0;} */", + "/* \telse if (a.real > 0.0) {r.real = 1.0/0.0;} */", + "", + "/* \tif (a.imag == 0.0) {r.imag = a.imag/b.imag;} */", + "/* \telse if (a.imag < 0.0) {r.imag = -1.0/0.0;} */", + "/* \telse if (a.imag > 0.0) {r.imag = 1.0/0.0;} */", + "\treturn r;", + " }", + "", + " if (abs_breal >= abs_bimag) {", + "\t/* divide tops and bottom by b.real */", + "\tconst double ratio = b.imag / b.real;", + "\tconst double denom = b.real + b.imag * ratio;", + "\tr.real = (a.real + a.imag * ratio) / denom;", + "\tr.imag = (a.imag - a.real * ratio) / denom;", + " }", + " else {", + "\t/* divide tops and bottom by b.imag */", + "\tconst double ratio = b.real / b.imag;", + "\tconst double denom = b.real * ratio + b.imag;", + "\tr.real = (a.real * ratio + a.imag) / denom;", + "\tr.imag = (a.imag * ratio - a.real) / denom;", + " }", + " return r;", + "}", + "", + "static Py_complex c_sqrt(Py_complex x)", + "{", + " Py_complex r;", + " double s,d;", + " if (x.real == 0. && x.imag == 0.)", + "\tr = x;", + " else {", + "\ts = sqrt(0.5*(fabs(x.real) + hypot(x.real,x.imag)));", + "\td = 0.5*x.imag/s;", + "\tif (x.real > 0.) {", + "\t r.real = s;", + "\t r.imag = d;", + "\t}", + "\telse if (x.imag >= 0.) {", + "\t r.real = d;", + "\t r.imag = s;", + "\t}", + "\telse {", + "\t r.real = -d;", + "\t r.imag = -s;", + "\t}", + " }", + " return r;", + "}", + "", + "static Py_complex c_log(Py_complex x)", + "{", + " Py_complex r;", + " double l = hypot(x.real,x.imag);", + " r.imag = atan2(x.imag, x.real);", + " r.real = log(l);", + " return r;", + "}", + "", + "static Py_complex c_prodi(Py_complex x)", + "{", + " Py_complex r;", + " r.real = -x.imag;", + " r.imag = x.real;", + " return r;", + "}", + "", + "static Py_complex c_acos(Py_complex x)", + "{", + " return c_neg(c_prodi(c_log(c_sum(x,c_prod(c_i,", + "\t\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x))))))));", + "}", + "", + "static Py_complex c_acosh(Py_complex x)", + "{", + " return c_log(c_sum(x,c_prod(c_i,", + "\t\t\t\tc_sqrt(c_diff(c_1,c_prod(x,x))))));", + "}", + "", + "static Py_complex c_asin(Py_complex x)", + "{", + " return c_neg(c_prodi(c_log(c_sum(c_prod(c_i,x),", + "\t\t\t\t c_sqrt(c_diff(c_1,c_prod(x,x)))))));", + "}", + "", + "static Py_complex c_asinh(Py_complex x)", + "{", + " return c_neg(c_log(c_diff(c_sqrt(c_sum(c_1,c_prod(x,x))),x)));", + "}", + "", + "static Py_complex c_atan(Py_complex x)", + "{", + " return c_prod(c_i2,c_log(c_quot_fast(c_sum(c_i,x),c_diff(c_i,x))));", + "}", + "", + "static Py_complex c_atanh(Py_complex x)", + "{", + " return c_prod(c_half,c_log(c_quot_fast(c_sum(c_1,x),c_diff(c_1,x))));", + "}", + "", + "static Py_complex c_cos(Py_complex x)", + "{", + " Py_complex r;", + " r.real = cos(x.real)*cosh(x.imag);", + " r.imag = -sin(x.real)*sinh(x.imag);", + " return r;", + "}", + "", + "static Py_complex c_cosh(Py_complex x)", + "{", + " Py_complex r;", + " r.real = cos(x.imag)*cosh(x.real);", + " r.imag = sin(x.imag)*sinh(x.real);", + " return r;", + "}", + "", + "static Py_complex c_exp(Py_complex x)", + "{", + " Py_complex r;", + " double l = exp(x.real);", + " r.real = l*cos(x.imag);", + " r.imag = l*sin(x.imag);", + " return r;", + "}", + "", + "static Py_complex c_log10(Py_complex x)", + "{", + " Py_complex r;", + " double l = hypot(x.real,x.imag);", + " r.imag = atan2(x.imag, x.real)/log(10.);", + " r.real = log10(l);", + " return r;", + "}", + "", + "static Py_complex c_sin(Py_complex x)", + "{", + " Py_complex r;", + " r.real = sin(x.real)*cosh(x.imag);", + " r.imag = cos(x.real)*sinh(x.imag);", + " return r;", + "}", + "", + "static Py_complex c_sinh(Py_complex x)", + "{", + " Py_complex r;", + " r.real = cos(x.imag)*sinh(x.real);", + " r.imag = sin(x.imag)*cosh(x.real);", + " return r;", + "}", + "", + "static Py_complex c_tan(Py_complex x)", + "{", + " Py_complex r;", + " double sr,cr,shi,chi;", + " double rs,is,rc,ic;", + " double d;", + " sr = sin(x.real);", + " cr = cos(x.real);", + " shi = sinh(x.imag);", + " chi = cosh(x.imag);", + " rs = sr*chi;", + " is = cr*shi;", + " rc = cr*chi;", + " ic = -sr*shi;", + " d = rc*rc + ic*ic;", + " r.real = (rs*rc+is*ic)/d;", + " r.imag = (is*rc-rs*ic)/d;", + " return r;", + "}", + "", + "static Py_complex c_tanh(Py_complex x)", + "{", + " Py_complex r;", + " double si,ci,shr,chr;", + " double rs,is,rc,ic;", + " double d;", + " si = sin(x.imag);", + " ci = cos(x.imag);", + " shr = sinh(x.real);", + " chr = cosh(x.real);", + " rs = ci*shr;", + " is = si*chr;", + " rc = ci*chr;", + " ic = si*shr;", + " d = rc*rc + ic*ic;", + " r.real = (rs*rc+is*ic)/d;", + " r.imag = (is*rc-rs*ic)/d;", + " return r;", + "}", + "", + "static long powll(long x, long n, int nbits)", + " /* Overflow check: overflow will occur if log2(abs(x)) * n > nbits. */", + "{", + " long r = 1;", + " long p = x;", + " double logtwox;", + " long mask = 1;", + " if (n < 0) PyErr_SetString(PyExc_ValueError, \"Integer to a negative power\");", + " if (x != 0) {", + "\tlogtwox = log10 (fabs ( (double) x))/log10 ( (double) 2.0);", + "\tif (logtwox * (double) n > (double) nbits)", + "\t PyErr_SetString(PyExc_ArithmeticError, \"Integer overflow in power.\");", + " }", + " while (mask > 0 && n >= mask) {", + "\tif (n & mask)", + "\t r *= p;", + "\tmask <<= 1;", + "\tp *= p;", + " }", + " return r;", + "}", + "", + "static void UBYTE_add(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i 255) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t*((unsigned char *)op)=(unsigned char) x;", + " }", + "}", + "static void SBYTE_multiply(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " int x;", + " for(i=0; i 127 || x < -128) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t*((signed char *)op)=(signed char) x;", + " }", + "}", + "static void SHORT_multiply(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " short a, b, ah, bh, x, y;", + " int s;", + " for(i=0; i> (SHORT_BIT/2);", + "\tbh = b >> (SHORT_BIT/2);", + "\t/* Quick test for common case: two small positive shorts */", + "\tif (ah == 0 && bh == 0) {", + "\t if ((x=a*b) < 0) {", + "\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\treturn;", + "\t }", + "\t else {", + "\t\t*((short *)op)=x;", + "\t\tcontinue;", + "\t }", + "\t}", + "\t/* Arrange that a >= b >= 0 */", + "\tif (a < 0) {", + "\t a = -a;", + "\t if (a < 0) {", + "\t\t/* Largest negative */", + "\t\tif (b == 0 || b == 1) {", + "\t\t *((short *)op)=a*b;", + "\t\t continue;", + "\t\t}", + "\t\telse {", + "\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\t return;", + "\t\t}", + "\t }", + "\t s = -s;", + "\t ah = a >> (SHORT_BIT/2);", + "\t}", + "\tif (b < 0) {", + "\t b = -b;", + "\t if (b < 0) {", + "\t\t/* Largest negative */", + "\t\tif (a == 0 || a == 1) {", + "\t\t *((short *)op)=a*b;", + "\t\t continue;", + "\t\t}", + "\t\telse {", + "\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\t return;", + "\t\t}", + "\t }", + "\t s = -s;", + "\t bh = b >> (SHORT_BIT/2);", + "\t}", + "\t/* 1) both ah and bh > 0 : then report overflow */", + "\tif (ah != 0 && bh != 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t/* 2) both ah and bh = 0 : then compute a*b and report", + "\t overflow if it comes out negative */", + "\tif (ah == 0 && bh == 0) {", + "\t if ((x=a*b) < 0) {", + "\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\treturn;", + "\t }", + "\t else {", + "\t\t*((short *)op)=s * x;", + "\t\tcontinue;", + "\t }", + "\t}", + "\tif (a < b) {", + "\t /* Swap */", + "\t x = a;", + "\t a = b;", + "\t b = x;", + "\t ah = bh;", + "\t /* bh not used beyond this point */", + "\t}", + "\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if", + "\t it's >= 2^31", + "\t compute al*bl and report overflow if it's negative", + "\t add (ah*bl)<<32 to al*bl and report overflow if", + "\t it's negative", + "\t (NB b == bl in this case, and we make a = al) */", + "\ty = ah*b;", + "\tif (y >= (1 << (SHORT_BIT/2 - 1))) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\ta &= (1 << (SHORT_BIT/2)) - 1;", + "\tx = a*b;", + "\tif (x < 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\tx += y << (SHORT_BIT/2);", + "\tif (x < 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t*((short *)op)=s*x;", + " }", + "}", + "static void INT_multiply(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " int a, b, ah, bh, x, y;", + " int s;", + " for(i=0; i> (INT_BIT/2);", + "\tbh = b >> (INT_BIT/2);", + "\t/* Quick test for common case: two small positive ints */", + "\tif (ah == 0 && bh == 0) {", + "\t if ((x=a*b) < 0) {", + "\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\treturn;", + "\t }", + "\t else {", + "\t\t*((int *)op)=x;", + "\t\tcontinue;", + "\t }", + "\t}", + "\t/* Arrange that a >= b >= 0 */", + "\tif (a < 0) {", + "\t a = -a;", + "\t if (a < 0) {", + "\t\t/* Largest negative */", + "\t\tif (b == 0 || b == 1) {", + "\t\t *((int *)op)=a*b;", + "\t\t continue;", + "\t\t}", + "\t\telse {", + "\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\t return;", + "\t\t}", + "\t }", + "\t s = -s;", + "\t ah = a >> (INT_BIT/2);", + "\t}", + "\tif (b < 0) {", + "\t b = -b;", + "\t if (b < 0) {", + "\t\t/* Largest negative */", + "\t\tif (a == 0 || a == 1) {", + "\t\t *((int *)op)=a*b;", + "\t\t continue;", + "\t\t}", + "\t\telse {", + "\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\t return;", + "\t\t}", + "\t }", + "\t s = -s;", + "\t bh = b >> (INT_BIT/2);", + "\t}", + "\t/* 1) both ah and bh > 0 : then report overflow */", + "\tif (ah != 0 && bh != 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t/* 2) both ah and bh = 0 : then compute a*b and report", + "\t overflow if it comes out negative */", + "\tif (ah == 0 && bh == 0) {", + "\t if ((x=a*b) < 0) {", + "\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\treturn;", + "\t }", + "\t else {", + "\t\t*((int *)op)=s * x;", + "\t\tcontinue;", + "\t }", + "\t}", + "\tif (a < b) {", + "\t /* Swap */", + "\t x = a;", + "\t a = b;", + "\t b = x;", + "\t ah = bh;", + "\t /* bh not used beyond this point */", + "\t}", + "\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if", + "\t it's >= 2^31", + "\t compute al*bl and report overflow if it's negative", + "\t add (ah*bl)<<32 to al*bl and report overflow if", + "\t it's negative", + "\t (NB b == bl in this case, and we make a = al) */", + "\ty = ah*b;", + "\tif (y >= (1 << (INT_BIT/2 - 1))) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\ta &= (1 << (INT_BIT/2)) - 1;", + "\tx = a*b;", + "\tif (x < 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\tx += y << (INT_BIT/2);", + "\tif (x < 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t*((int *)op)=s*x;", + " }", + "}", + "static void LONG_multiply(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " long a, b, ah, bh, x, y;", + " int s;", + " for(i=0; i> (LONG_BIT/2);", + "\tbh = b >> (LONG_BIT/2);", + "\t/* Quick test for common case: two small positive ints */", + "\tif (ah == 0 && bh == 0) {", + "\t if ((x=a*b) < 0) {", + "\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\treturn;", + "\t }", + "\t else {", + "\t\t*((long *)op)=x;", + "\t\tcontinue;", + "\t }", + "\t}", + "\t/* Arrange that a >= b >= 0 */", + "\tif (a < 0) {", + "\t a = -a;", + "\t if (a < 0) {", + "\t\t/* Largest negative */", + "\t\tif (b == 0 || b == 1) {", + "\t\t *((long *)op)=a*b;", + "\t\t continue;", + "\t\t}", + "\t\telse {", + "\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\t return;", + "\t\t}", + "\t }", + "\t s = -s;", + "\t ah = a >> (LONG_BIT/2);", + "\t}", + "\tif (b < 0) {", + "\t b = -b;", + "\t if (b < 0) {", + "\t\t/* Largest negative */", + "\t\tif (a == 0 || a == 1) {", + "\t\t *((long *)op)=a*b;", + "\t\t continue;", + "\t\t}", + "\t\telse {", + "\t\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\t return;", + "\t\t}", + "\t }", + "\t s = -s;", + "\t bh = b >> (LONG_BIT/2);", + "\t}", + "\t/* 1) both ah and bh > 0 : then report overflow */", + "\tif (ah != 0 && bh != 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t/* 2) both ah and bh = 0 : then compute a*b and report", + "\t overflow if it comes out negative */", + "\tif (ah == 0 && bh == 0) {", + "\t if ((x=a*b) < 0) {", + "\t\tPyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t\treturn;", + "\t }", + "\t else {", + "\t\t*((long *)op)=s * x;", + "\t\tcontinue;", + "\t }", + "\t}", + "\tif (a < b) {", + "\t /* Swap */", + "\t x = a;", + "\t a = b;", + "\t b = x;", + "\t ah = bh;", + "\t /* bh not used beyond this point */", + "\t}", + "\t/* 3) ah > 0 and bh = 0 : compute ah*bl and report overflow if", + "\t it's >= 2^31", + "\t compute al*bl and report overflow if it's negative", + "\t add (ah*bl)<<32 to al*bl and report overflow if", + "\t it's negative", + "\t (NB b == bl in this case, and we make a = al) */", + "\ty = ah*b;", + "\tif (y >= (1L << (LONG_BIT/2 - 1))) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\ta &= (1L << (LONG_BIT/2)) - 1;", + "\tx = a*b;", + "\tif (x < 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\tx += y << (LONG_BIT/2);", + "\tif (x < 0) {", + "\t PyErr_SetString (PyExc_ArithmeticError, \"Integer overflow in multiply.\");", + "\t return;", + "\t}", + "\t*((long *)op)=s*x;", + " }", + "}", + "static void FLOAT_multiply(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((unsigned char *)i2);", + " }", + "}", + "static void SBYTE_greater(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((signed char *)i2);", + " }", + "}", + "static void SHORT_greater(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((short *)i2);", + " }", + "}", + "static void INT_greater(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((int *)i2);", + " }", + "}", + "static void LONG_greater(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((long *)i2);", + " }", + "}", + "static void FLOAT_greater(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((float *)i2);", + " }", + "}", + "static void DOUBLE_greater(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((double *)i2);", + " }", + "}", + "static void UBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i= *((unsigned char *)i2);", + " }", + "}", + "static void SBYTE_greater_equal(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i= *((signed char *)i2);", + " }", + "}", + "static void SHORT_greater_equal(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i= *((short *)i2);", + " }", + "}", + "static void INT_greater_equal(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i= *((int *)i2);", + " }", + "}", + "static void LONG_greater_equal(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i= *((long *)i2);", + " }", + "}", + "static void FLOAT_greater_equal(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i= *((float *)i2);", + " }", + "}", + "static void DOUBLE_greater_equal(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i= *((double *)i2);", + " }", + "}", + "static void UBYTE_less(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((unsigned char *)i2) ? *((unsigned char *)i1) : *((unsigned char *)i2);", + " }", + "}", + "static void SBYTE_maximum(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((signed char *)i2) ? *((signed char *)i1) : *((signed char *)i2);", + " }", + "}", + "static void SHORT_maximum(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((short *)i2) ? *((short *)i1) : *((short *)i2);", + " }", + "}", + "static void INT_maximum(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((int *)i2) ? *((int *)i1) : *((int *)i2);", + " }", + "}", + "static void LONG_maximum(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((long *)i2) ? *((long *)i1) : *((long *)i2);", + " }", + "}", + "static void FLOAT_maximum(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((float *)i2) ? *((float *)i1) : *((float *)i2);", + " }", + "}", + "static void DOUBLE_maximum(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i *((double *)i2) ? *((double *)i1) : *((double *)i2);", + " }", + "}", + "static void UBYTE_minimum(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i> *((unsigned char *)i2);", + " }", + "}", + "static void SBYTE_right_shift(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i> *((signed char *)i2);", + " }", + "}", + "static void SHORT_right_shift(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i> *((short *)i2);", + " }", + "}", + "static void INT_right_shift(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i> *((int *)i2);", + " }", + "}", + "static void LONG_right_shift(char **args, int *dimensions, int *steps, void *func) {", + " int i, is1=steps[0],is2=steps[1],os=steps[2], n=dimensions[0];", + " char *i1=args[0], *i2=args[1], *op=args[2];", + " for(i=0; i> *((long *)i2);", + " }", + "}", + "", + "static PyUFuncGenericFunction add_functions[] = { UBYTE_add, SBYTE_add, SHORT_add, INT_add, LONG_add, FLOAT_add, DOUBLE_add, CFLOAT_add, CDOUBLE_add, NULL, };", + "static PyUFuncGenericFunction subtract_functions[] = { UBYTE_subtract, SBYTE_subtract, SHORT_subtract, INT_subtract, LONG_subtract, FLOAT_subtract, DOUBLE_subtract, CFLOAT_subtract, CDOUBLE_subtract, NULL, };", + "static PyUFuncGenericFunction multiply_functions[] = { UBYTE_multiply, SBYTE_multiply, SHORT_multiply, INT_multiply, LONG_multiply, FLOAT_multiply, DOUBLE_multiply, NULL, NULL, NULL, };", + "static PyUFuncGenericFunction divide_functions[] = { UBYTE_divide, SBYTE_divide, SHORT_divide, INT_divide, LONG_divide, FLOAT_divide, DOUBLE_divide, NULL, NULL, NULL, };", + "static PyUFuncGenericFunction divide_safe_functions[] = { UBYTE_divide_safe, SBYTE_divide_safe, SHORT_divide_safe, INT_divide_safe, LONG_divide_safe, FLOAT_divide_safe, DOUBLE_divide_safe, };", + "static PyUFuncGenericFunction conjugate_functions[] = { UBYTE_conjugate, SBYTE_conjugate, SHORT_conjugate, INT_conjugate, LONG_conjugate, FLOAT_conjugate, DOUBLE_conjugate, CFLOAT_conjugate, CDOUBLE_conjugate, NULL, };", + "static PyUFuncGenericFunction remainder_functions[] = { UBYTE_remainder, SBYTE_remainder, SHORT_remainder, INT_remainder, LONG_remainder, NULL, NULL, NULL, };", + "static PyUFuncGenericFunction power_functions[] = { UBYTE_power, SBYTE_power, SHORT_power, INT_power, LONG_power, NULL, NULL, NULL, NULL, NULL, };", + "static PyUFuncGenericFunction absolute_functions[] = { SBYTE_absolute, SHORT_absolute, INT_absolute, LONG_absolute, FLOAT_absolute, DOUBLE_absolute, CFLOAT_absolute, CDOUBLE_absolute, NULL, };", + "static PyUFuncGenericFunction negative_functions[] = { SBYTE_negative, SHORT_negative, INT_negative, LONG_negative, FLOAT_negative, DOUBLE_negative, CFLOAT_negative, CDOUBLE_negative, NULL, };", + "static PyUFuncGenericFunction greater_functions[] = { UBYTE_greater, SBYTE_greater, SHORT_greater, INT_greater, LONG_greater, FLOAT_greater, DOUBLE_greater, };", + "static PyUFuncGenericFunction greater_equal_functions[] = { UBYTE_greater_equal, SBYTE_greater_equal, SHORT_greater_equal, INT_greater_equal, LONG_greater_equal, FLOAT_greater_equal, DOUBLE_greater_equal, };", + "static PyUFuncGenericFunction less_functions[] = { UBYTE_less, SBYTE_less, SHORT_less, INT_less, LONG_less, FLOAT_less, DOUBLE_less, };", + "static PyUFuncGenericFunction less_equal_functions[] = { UBYTE_less_equal, SBYTE_less_equal, SHORT_less_equal, INT_less_equal, LONG_less_equal, FLOAT_less_equal, DOUBLE_less_equal, };", + "static PyUFuncGenericFunction equal_functions[] = { CHAR_equal, UBYTE_equal, SBYTE_equal, SHORT_equal, INT_equal, LONG_equal, FLOAT_equal, DOUBLE_equal, CFLOAT_equal, CDOUBLE_equal, OBJECT_equal};", + "static PyUFuncGenericFunction not_equal_functions[] = { CHAR_not_equal, UBYTE_not_equal, SBYTE_not_equal, SHORT_not_equal, INT_not_equal, LONG_not_equal, FLOAT_not_equal, DOUBLE_not_equal, CFLOAT_not_equal, CDOUBLE_not_equal, OBJECT_not_equal};", + "static PyUFuncGenericFunction logical_and_functions[] = { UBYTE_logical_and, SBYTE_logical_and, SHORT_logical_and, INT_logical_and, LONG_logical_and, FLOAT_logical_and, DOUBLE_logical_and, };", + "static PyUFuncGenericFunction logical_or_functions[] = { UBYTE_logical_or, SBYTE_logical_or, SHORT_logical_or, INT_logical_or, LONG_logical_or, FLOAT_logical_or, DOUBLE_logical_or, };", + "static PyUFuncGenericFunction logical_xor_functions[] = { UBYTE_logical_xor, SBYTE_logical_xor, SHORT_logical_xor, INT_logical_xor, LONG_logical_xor, FLOAT_logical_xor, DOUBLE_logical_xor, };", + "static PyUFuncGenericFunction logical_not_functions[] = { UBYTE_logical_not, SBYTE_logical_not, SHORT_logical_not, INT_logical_not, LONG_logical_not, FLOAT_logical_not, DOUBLE_logical_not, };", + "static PyUFuncGenericFunction maximum_functions[] = { UBYTE_maximum, SBYTE_maximum, SHORT_maximum, INT_maximum, LONG_maximum, FLOAT_maximum, DOUBLE_maximum, };", + "static PyUFuncGenericFunction minimum_functions[] = { UBYTE_minimum, SBYTE_minimum, SHORT_minimum, INT_minimum, LONG_minimum, FLOAT_minimum, DOUBLE_minimum, };", + "static PyUFuncGenericFunction bitwise_and_functions[] = { UBYTE_bitwise_and, SBYTE_bitwise_and, SHORT_bitwise_and, INT_bitwise_and, LONG_bitwise_and, NULL, };", + "static PyUFuncGenericFunction bitwise_or_functions[] = { UBYTE_bitwise_or, SBYTE_bitwise_or, SHORT_bitwise_or, INT_bitwise_or, LONG_bitwise_or, NULL, };", + "static PyUFuncGenericFunction bitwise_xor_functions[] = { UBYTE_bitwise_xor, SBYTE_bitwise_xor, SHORT_bitwise_xor, INT_bitwise_xor, LONG_bitwise_xor, NULL, };", + "static PyUFuncGenericFunction invert_functions[] = { UBYTE_invert, SBYTE_invert, SHORT_invert, INT_invert, LONG_invert, };", + "static PyUFuncGenericFunction left_shift_functions[] = { UBYTE_left_shift, SBYTE_left_shift, SHORT_left_shift, INT_left_shift, LONG_left_shift, NULL, };", + "static PyUFuncGenericFunction right_shift_functions[] = { UBYTE_right_shift, SBYTE_right_shift, SHORT_right_shift, INT_right_shift, LONG_right_shift, NULL, };", + "static PyUFuncGenericFunction arccos_functions[] = { NULL, NULL, NULL, NULL, NULL, };", + "static PyUFuncGenericFunction ceil_functions[] = { NULL, NULL, NULL, };", + "static PyUFuncGenericFunction arctan2_functions[] = { NULL, NULL, NULL, };", + "static void * add_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * subtract_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * multiply_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * divide_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * divide_safe_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * conjugate_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * remainder_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * power_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * absolute_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * negative_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * equal_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL};", + "static void * bitwise_and_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * bitwise_or_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * bitwise_xor_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * invert_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL,};", + "static void * left_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * right_shift_data[] = { (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, };", + "static void * arccos_data[] = { (void *)acos, (void *)acos, (void *)c_acos, (void *)c_acos, (void *)\"arccos\", };", + "static void * arcsin_data[] = { (void *)asin, (void *)asin, (void *)c_asin, (void *)c_asin, (void *)\"arcsin\", };", + "static void * arctan_data[] = { (void *)atan, (void *)atan, (void *)c_atan, (void *)c_atan, (void *)\"arctan\", };", + "static void * arccosh_data[] = { (void *)acosh, (void *)acosh, (void *)c_acosh, (void *)c_acosh, (void *)\"arccosh\", };", + "static void * arcsinh_data[] = { (void *)asinh, (void *)asinh, (void *)c_asinh, (void *)c_asinh, (void *)\"arcsinh\", };", + "static void * arctanh_data[] = { (void *)atanh, (void *)atanh, (void *)c_atanh, (void *)c_atanh, (void *)\"arctanh\", };", + "static void * cos_data[] = { (void *)cos, (void *)cos, (void *)c_cos, (void *)c_cos, (void *)\"cos\", };", + "static void * cosh_data[] = { (void *)cosh, (void *)cosh, (void *)c_cosh, (void *)c_cosh, (void *)\"cosh\", };", + "static void * exp_data[] = { (void *)exp, (void *)exp, (void *)c_exp, (void *)c_exp, (void *)\"exp\", };", + "static void * log_data[] = { (void *)log, (void *)log, (void *)c_log, (void *)c_log, (void *)\"log\", };", + "static void * log10_data[] = { (void *)log10, (void *)log10, (void *)c_log10, (void *)c_log10, (void *)\"log10\", };", + "static void * sin_data[] = { (void *)sin, (void *)sin, (void *)c_sin, (void *)c_sin, (void *)\"sin\", };", + "static void * sinh_data[] = { (void *)sinh, (void *)sinh, (void *)c_sinh, (void *)c_sinh, (void *)\"sinh\", };", + "static void * sqrt_data[] = { (void *)sqrt, (void *)sqrt, (void *)c_sqrt, (void *)c_sqrt, (void *)\"sqrt\", };", + "static void * tan_data[] = { (void *)tan, (void *)tan, (void *)c_tan, (void *)c_tan, (void *)\"tan\", };", + "static void * tanh_data[] = { (void *)tanh, (void *)tanh, (void *)c_tanh, (void *)c_tanh, (void *)\"tanh\", };", + "static void * ceil_data[] = { (void *)ceil, (void *)ceil, (void *)\"ceil\", };", + "static void * fabs_data[] = { (void *)fabs, (void *)fabs, (void *)\"fabs\", };", + "static void * floor_data[] = { (void *)floor, (void *)floor, (void *)\"floor\", };", + "static void * arctan2_data[] = { (void *)atan2, (void *)atan2, (void *)\"arctan2\", };", + "static void * fmod_data[] = { (void *)fmod, (void *)fmod, (void *)\"fmod\", };", + "static void * hypot_data[] = { (void *)hypot, (void *)hypot, (void *)\"hypot\", };", + "static char add_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };", + "static char divide_safe_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, };", + "static char conjugate_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };", + "static char remainder_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };", + "static char absolute_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_FLOAT, PyArray_CDOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };", + "static char negative_signatures[] = { PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };", + "static char equal_signatures[] = { PyArray_CHAR, PyArray_CHAR, PyArray_LONG, PyArray_UBYTE, PyArray_UBYTE, PyArray_LONG, PyArray_SBYTE, PyArray_SBYTE, PyArray_LONG, PyArray_SHORT, PyArray_SHORT, PyArray_LONG, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_LONG, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_LONG, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_LONG};", + "static char greater_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_LONG, PyArray_SBYTE, PyArray_SBYTE, PyArray_LONG, PyArray_SHORT, PyArray_SHORT, PyArray_LONG, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_LONG, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_LONG, };", + "static char logical_not_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, };", + "static char bitwise_and_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, PyArray_OBJECT, };", + "static char invert_signatures[] = { PyArray_UBYTE, PyArray_UBYTE, PyArray_SBYTE, PyArray_SBYTE, PyArray_SHORT, PyArray_SHORT, PyArray_INT, PyArray_INT, PyArray_LONG, PyArray_LONG, PyArray_OBJECT, PyArray_OBJECT, };", + "static char arccos_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_CFLOAT, PyArray_CFLOAT, PyArray_CDOUBLE, PyArray_CDOUBLE, PyArray_OBJECT, PyArray_OBJECT, };", + "static char ceil_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };", + "static char arctan2_signatures[] = { PyArray_FLOAT, PyArray_FLOAT, PyArray_FLOAT, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_DOUBLE, PyArray_OBJECT, PyArray_OBJECT, };", + "static void InitOperators(PyObject *dictionary) {", + " PyObject *f;", + "", + " add_data[9] =(void *)PyNumber_Add;", + " subtract_data[9] = (void *)PyNumber_Subtract;", + " multiply_data[7] = (void *)c_prod;", + " multiply_data[8] = (void *)c_prod;", + " multiply_data[9] = (void *)PyNumber_Multiply;", + " divide_data[7] = (void *)c_quot_fast;", + " divide_data[8] = (void *)c_quot_fast;", + " divide_data[9] = (void *)PyNumber_Divide;", + " divide_safe_data[7] = (void *)c_quot;", + " divide_safe_data[8] = (void *)c_quot;", + " divide_safe_data[9] = (void *)PyNumber_Divide;", + " conjugate_data[9] = (void *)\"conjugate\";", + " remainder_data[5] = (void *)fmod;", + " remainder_data[6] = (void *)fmod;", + " remainder_data[7] = (void *)PyNumber_Remainder;", + " power_data[5] = (void *)pow;", + " power_data[6] = (void *)pow;", + " power_data[7] = (void *)c_pow;", + " power_data[8] = (void *)c_pow;", + " power_data[9] = (void *)PyNumber_Power;", + " absolute_data[8] = (void *)PyNumber_Absolute;", + " negative_data[8] = (void *)PyNumber_Negative;", + " bitwise_and_data[5] = (void *)PyNumber_And;", + " bitwise_or_data[5] = (void *)PyNumber_Or;", + " bitwise_xor_data[5] = (void *)PyNumber_Xor;", + " invert_data[5] = (void *)PyNumber_Invert;", + " left_shift_data[5] = (void *)PyNumber_Lshift;", + " right_shift_data[5] = (void *)PyNumber_Rshift;", + "", + "", + " add_functions[9] = PyUFunc_OO_O;", + " subtract_functions[9] = PyUFunc_OO_O;", + " multiply_functions[7] = PyUFunc_FF_F_As_DD_D;", + " multiply_functions[8] = PyUFunc_DD_D;", + " multiply_functions[9] = PyUFunc_OO_O;", + " divide_functions[7] = PyUFunc_FF_F_As_DD_D;", + " divide_functions[8] = PyUFunc_DD_D;", + " divide_functions[9] = PyUFunc_OO_O;", + " divide_safe_functions[7] = PyUFunc_FF_F_As_DD_D;", + " divide_safe_functions[8] = PyUFunc_DD_D;", + " divide_safe_functions[9] = PyUFunc_OO_O;", + " conjugate_functions[9] = PyUFunc_O_O_method;", + " remainder_functions[5] = PyUFunc_ff_f_As_dd_d;", + " remainder_functions[6] = PyUFunc_dd_d;", + " remainder_functions[7] = PyUFunc_OO_O;", + " power_functions[5] = PyUFunc_ff_f_As_dd_d;", + " power_functions[6] = PyUFunc_dd_d;", + " power_functions[7] = PyUFunc_FF_F_As_DD_D;", + " power_functions[8] = PyUFunc_DD_D;", + " power_functions[9] = PyUFunc_OO_O;", + " absolute_functions[8] = PyUFunc_O_O;", + " negative_functions[8] = PyUFunc_O_O;", + " bitwise_and_functions[5] = PyUFunc_OO_O;", + " bitwise_or_functions[5] = PyUFunc_OO_O;", + " bitwise_xor_functions[5] = PyUFunc_OO_O;", + " invert_functions[5] = PyUFunc_O_O;", + " left_shift_functions[5] = PyUFunc_OO_O;", + " right_shift_functions[5] = PyUFunc_OO_O;", + " arccos_functions[0] = PyUFunc_f_f_As_d_d;", + " arccos_functions[1] = PyUFunc_d_d;", + " arccos_functions[2] = PyUFunc_F_F_As_D_D;", + " arccos_functions[3] = PyUFunc_D_D;", + " arccos_functions[4] = PyUFunc_O_O_method;", + " ceil_functions[0] = PyUFunc_f_f_As_d_d;", + " ceil_functions[1] = PyUFunc_d_d;", + " ceil_functions[2] = PyUFunc_O_O_method;", + " arctan2_functions[0] = PyUFunc_ff_f_As_dd_d;", + " arctan2_functions[1] = PyUFunc_dd_d;", + " arctan2_functions[2] = PyUFunc_O_O_method;", + "", + " f = PyUFunc_FromFuncAndData(add_functions, add_data, add_signatures, 10,", + "\t\t\t\t2, 1, PyUFunc_Zero, \"add\",", + "\t\t\t\t\"Add the arguments elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"add\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(subtract_functions, subtract_data, add_signatures,", + "\t\t\t\t10, 2, 1, PyUFunc_Zero, \"subtract\",", + "\t\t\t\t\"Subtract the arguments elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"subtract\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(multiply_functions, multiply_data, add_signatures,", + "\t\t\t\t10, 2, 1, PyUFunc_One, \"multiply\",", + "\t\t\t\t\"Multiply the arguments elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"multiply\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(divide_functions, divide_data, add_signatures,", + "\t\t\t\t10, 2, 1, PyUFunc_One, \"divide\",", + "\t\t\t\t\"Divide the arguments elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"divide\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(divide_safe_functions, divide_safe_data, divide_safe_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_One, \"divide_safe\",", + "\t\t\t\t\"Divide elementwise, ZeroDivision exception thrown if necessary.\", 0);", + " PyDict_SetItemString(dictionary, \"divide_safe\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(conjugate_functions, conjugate_data, conjugate_signatures,", + "\t\t\t\t10, 1, 1, PyUFunc_None, \"conjugate\",", + "\t\t\t\t\"returns conjugate of each element\", 0);", + " PyDict_SetItemString(dictionary, \"conjugate\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(remainder_functions, remainder_data, remainder_signatures,", + "\t\t\t\t8, 2, 1, PyUFunc_Zero, \"remainder\",", + "\t\t\t\t\"returns remainder of division elementwise\", 0);", + " PyDict_SetItemString(dictionary, \"remainder\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(power_functions, power_data, add_signatures,", + "\t\t\t\t10, 2, 1, PyUFunc_One, \"power\",", + "\t\t\t\t\"power(x,y) = x**y elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"power\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(absolute_functions, absolute_data, absolute_signatures,", + "\t\t\t\t9, 1, 1, PyUFunc_None, \"absolute\",", + "\t\t\t\t\"returns absolute value of each element\", 0);", + " PyDict_SetItemString(dictionary, \"absolute\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(negative_functions, negative_data, negative_signatures,", + "\t\t\t\t9, 1, 1, PyUFunc_None, \"negative\",", + "\t\t\t\t\"negative(x) == -x elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"negative\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(greater_functions, divide_safe_data, greater_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_None, \"greater\",", + "\t\t\t\t\"greater(x,y) is array of 1's where x > y, 0 otherwise.\",1);", + " PyDict_SetItemString(dictionary, \"greater\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(greater_equal_functions, divide_safe_data, greater_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_None, \"greater_equal\",", + "\t\t\t\t\"greater_equal(x,y) is array of 1's where x >=y, 0 otherwise.\", 0);", + " PyDict_SetItemString(dictionary, \"greater_equal\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(less_functions, divide_safe_data, greater_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_None, \"less\",", + "\t\t\t\t\"less(x,y) is array of 1's where x < y, 0 otherwise.\", 0);", + " PyDict_SetItemString(dictionary, \"less\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(less_equal_functions, divide_safe_data, greater_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_None, \"less_equal\",", + "\t\t\t\t\"less_equal(x,y) is array of 1's where x <= y, 0 otherwise.\", 0);", + " PyDict_SetItemString(dictionary, \"less_equal\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(equal_functions, equal_data, equal_signatures,", + "\t\t\t\t11, 2, 1, PyUFunc_One, \"equal\",", + "\t\t\t\t\"equal(x,y) is array of 1's where x == y, 0 otherwise.\", 0);", + " PyDict_SetItemString(dictionary, \"equal\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(not_equal_functions, equal_data, equal_signatures,", + "\t\t\t\t11, 2, 1, PyUFunc_None, \"not_equal\",", + "\t\t\t\t\"not_equal(x,y) is array of 0's where x == y, 1 otherwise.\", 0);", + " PyDict_SetItemString(dictionary, \"not_equal\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(logical_and_functions, divide_safe_data, divide_safe_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_One, \"logical_and\",", + "\t\t\t\t\"logical_and(x,y) returns array of 1's where x and y both true.\", 0);", + " PyDict_SetItemString(dictionary, \"logical_and\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(logical_or_functions, divide_safe_data, divide_safe_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_Zero, \"logical_or\",", + "\t\t\t\t\"logical_or(x,y) returns array of 1's where x or y or both are true.\", 0);", + " PyDict_SetItemString(dictionary, \"logical_or\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(logical_xor_functions, divide_safe_data, divide_safe_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_None, \"logical_xor\",", + "\t\t\t\t\"logical_xor(x,y) returns array of 1's where exactly one of x or y is true.\", 0);", + " PyDict_SetItemString(dictionary, \"logical_xor\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(logical_not_functions, divide_safe_data, logical_not_signatures,", + "\t\t\t\t7, 1, 1, PyUFunc_None, \"logical_not\",", + "\t\t\t\t\"logical_not(x) returns array of 1's where x is false, 0 otherwise.\", 0);", + " PyDict_SetItemString(dictionary, \"logical_not\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(maximum_functions, divide_safe_data, divide_safe_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_None, \"maximum\",", + "\t\t\t\t\"maximum(x,y) returns maximum of x and y taken elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"maximum\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(minimum_functions, divide_safe_data, divide_safe_signatures,", + "\t\t\t\t7, 2, 1, PyUFunc_None, \"minimum\",", + "\t\t\t\t\"minimum(x,y) returns minimum of x and y taken elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"minimum\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(bitwise_and_functions, bitwise_and_data, bitwise_and_signatures,", + "\t\t\t\t6, 2, 1, PyUFunc_One, \"bitwise_and\",", + "\t\t\t\t\"bitwise_and(x,y) returns array of bitwise-and of respective elements.\", 0);", + " PyDict_SetItemString(dictionary, \"bitwise_and\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(bitwise_or_functions, bitwise_or_data, bitwise_and_signatures,", + "\t\t\t\t6, 2, 1, PyUFunc_Zero, \"bitwise_or\",", + "\t\t\t\t\"bitwise_or(x,y) returns array of bitwise-or of respective elements.\", 0);", + " PyDict_SetItemString(dictionary, \"bitwise_or\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(bitwise_xor_functions, bitwise_xor_data, bitwise_and_signatures,", + "\t\t\t\t6, 2, 1, PyUFunc_None, \"bitwise_xor\",", + "\t\t\t\t\"bitwise_xor(x,y) returns array of bitwise exclusive or of respective elements.\", 0);", + " PyDict_SetItemString(dictionary, \"bitwise_xor\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(invert_functions, invert_data, invert_signatures,", + "\t\t\t\t6, 1, 1, PyUFunc_None, \"invert\",", + "\t\t\t\t\"invert(n) returns array of bit inversion elementwise if n is an integer array.\", 0);", + " PyDict_SetItemString(dictionary, \"invert\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(left_shift_functions, left_shift_data, bitwise_and_signatures,", + "\t\t\t\t6, 2, 1, PyUFunc_None, \"left_shift\",", + "\t\t\t\t\"left_shift(n, m) is n << m elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"left_shift\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(right_shift_functions, right_shift_data, bitwise_and_signatures,", + "\t\t\t\t6, 2, 1, PyUFunc_None, \"right_shift\",", + "\t\t\t\t\"right_shift(n, m) is n >> m elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"right_shift\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, arccos_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"arccos\",", + "\t\t\t\t\"arccos(x) returns array of elementwise inverse cosines.\", 0);", + " PyDict_SetItemString(dictionary, \"arccos\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, arcsin_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsin\",", + "\t\t\t\t\"arcsin(x) returns array of elementwise inverse sines.\", 0);", + " PyDict_SetItemString(dictionary, \"arcsin\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, arctan_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"arctan\",", + "\t\t\t\t\"arctan(x) returns array of elementwise inverse tangents.\", 0);", + " PyDict_SetItemString(dictionary, \"arctan\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, arctanh_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"arctanh\",", + "\t\t\t\t\"arctanh(x) returns array of elementwise inverse hyperbolic tangents.\", 0);", + " PyDict_SetItemString(dictionary, \"arctanh\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, arccosh_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"arccosh\",", + "\t\t\t\t\"arccosh(x) returns array of elementwise inverse hyperbolic cosines.\", 0);", + " PyDict_SetItemString(dictionary, \"arccosh\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, arcsinh_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"arcsinh\",", + "\t\t\t\t\"arcsinh(x) returns array of elementwise inverse hyperbolic sines.\", 0);", + " PyDict_SetItemString(dictionary, \"arcsinh\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, cos_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"cos\",", + "\t\t\t\t\"cos(x) returns array of elementwise cosines.\", 0);", + " PyDict_SetItemString(dictionary, \"cos\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, cosh_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"cosh\",", + "\t\t\t\t\"cosh(x) returns array of elementwise hyberbolic cosines.\", 0);", + " PyDict_SetItemString(dictionary, \"cosh\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, exp_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"exp\",", + "\t\t\t\t\"exp(x) returns array of elementwise e**x.\", 0);", + " PyDict_SetItemString(dictionary, \"exp\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, log_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"log\",", + "\t\t\t\t\"log(x) returns array of elementwise natural logarithms.\", 0);", + " PyDict_SetItemString(dictionary, \"log\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, log10_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"log10\",", + "\t\t\t\t\"log10(x) returns array of elementwise base-10 logarithms.\", 0);", + " PyDict_SetItemString(dictionary, \"log10\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, sin_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"sin\",", + "\t\t\t\t\"sin(x) returns array of elementwise sines.\", 0);", + " PyDict_SetItemString(dictionary, \"sin\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, sinh_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"sinh\",", + "\t\t\t\t\"sinh(x) returns array of elementwise hyperbolic sines.\", 0);", + " PyDict_SetItemString(dictionary, \"sinh\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, sqrt_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"sqrt\",", + "\t\t\t\t\"sqrt(x) returns array of elementwise square roots.\", 0);", + " PyDict_SetItemString(dictionary, \"sqrt\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, tan_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"tan\",", + "\t\t\t\t\"tan(x) returns array of elementwise tangents.\", 0);", + " PyDict_SetItemString(dictionary, \"tan\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arccos_functions, tanh_data, arccos_signatures,", + "\t\t\t\t5, 1, 1, PyUFunc_None, \"tanh\",", + "\t\t\t\t\"tanh(x) returns array of elementwise hyperbolic tangents.\", 0);", + " PyDict_SetItemString(dictionary, \"tanh\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(ceil_functions, ceil_data, ceil_signatures,", + "\t\t\t\t3, 1, 1, PyUFunc_None, \"ceil\",", + "\t\t\t\t\"ceil(x) returns array of elementwise least whole number >= x.\", 0);", + " PyDict_SetItemString(dictionary, \"ceil\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(ceil_functions, fabs_data, ceil_signatures,", + "\t\t\t\t3, 1, 1, PyUFunc_None, \"fabs\",", + "\t\t\t\t\"fabs(x) returns array of elementwise absolute values, 32 bit if x is.\", 0);", + "", + " PyDict_SetItemString(dictionary, \"fabs\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(ceil_functions, floor_data, ceil_signatures,", + "\t\t\t\t3, 1, 1, PyUFunc_None, \"floor\",", + "\t\t\t\t\"floor(x) returns array of elementwise least whole number <= x.\", 0);", + " PyDict_SetItemString(dictionary, \"floor\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arctan2_functions, arctan2_data, arctan2_signatures,", + "\t\t\t\t3, 2, 1, PyUFunc_None, \"arctan2\",", + "\t\t\t\t\"arctan2(x,y) is a safe and correct tan(x/y).\", 0);", + " PyDict_SetItemString(dictionary, \"arctan2\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arctan2_functions, fmod_data, arctan2_signatures,", + "\t\t\t\t3, 2, 1, PyUFunc_None, \"fmod\",", + "\t\t\t\t\"fmod(x,y) is remainder(x,y)\", 0);", + " PyDict_SetItemString(dictionary, \"fmod\", f);", + " Py_DECREF(f);", + " f = PyUFunc_FromFuncAndData(arctan2_functions, hypot_data, arctan2_signatures,", + "\t\t\t\t3, 2, 1, PyUFunc_None, \"hypot\",", + "\t\t\t\t\"hypot(x,y) = sqrt(x**2 + y**2), elementwise.\", 0);", + " PyDict_SetItemString(dictionary, \"hypot\", f);", + " Py_DECREF(f);", + "}", + "", + "", + "/* Initialization function for the module (*must* be called initArray) */", + "", + "static struct PyMethodDef methods[] = {", + " {NULL,\t\tNULL, 0}\t\t/* sentinel */", + "};", + "", + "DL_EXPORT(void) initfastumath() {", + " PyObject *m, *d, *s, *f1, *f2;", + "", + " /* Create the module and add the functions */", + " m = Py_InitModule(\"fastumath\", methods);", + "", + " /* Import the array and ufunc objects */", + " import_array();", + " import_ufunc();", + "", + " /* Add some symbolic constants to the module */", + " d = PyModule_GetDict(m);", + "", + " s = PyString_FromString(\"1.0\");", + " PyDict_SetItemString(d, \"__version__\", s);", + " Py_DECREF(s);", + "", + " /* Load the ufunc operators into the array module's namespace */", + " InitOperators(d);", + "", + " PyDict_SetItemString(d, \"pi\", s = PyFloat_FromDouble(atan(1.0) * 4.0));", + " Py_DECREF(s);", + " PyDict_SetItemString(d, \"e\", s = PyFloat_FromDouble(exp(1.0)));", + " Py_DECREF(s);", + "", + "", + " /* Temporarily set \"invert\" to \"conjugate\" in the dictionary so the call", + " to SetNumericOps will make ~ do complex conjugation */", + "", + " f1 = PyDict_GetItemString(d, \"conjugate\"); /* Borrowed reference */", + " /* f2 = PyDict_GetItemString(d, \"invert\"); */ /* Borrowed reference */", + " /* Py_INCREF(f2);*//*so we must incref it or it will be destroyed on next line*/", + " /* PyDict_SetItemString(d, \"invert\", f1);*/ /* Set invert to this reference so", + " that ~ will mean conjugation */", + " /* Setup the array object's numerical structures */", + " PyArray_SetNumericOps(d);", + "", + " /* Reset dictionary so that \"invert\" will mean bitwise invert */", + " /* PyDict_SetItemString(d, \"invert\", f2);", + " Py_DECREF(f2) */", + " PyDict_SetItemString(d, \"conj\", f1); /* shorthand for conjugate */", + "", + " /* Check for errors */", + " if (PyErr_Occurred())", + "\tPy_FatalError(\"can't initialize module fast_umath\");", + "}", + "" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "14983d9c60649993fac02c6a9b4212a333ac858a", + "msg": "More progress in finishing cephes to include specfun.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-03-31T07:04:21+00:00", + "author_timezone": 0, + "committer_date": "2002-03-31T07:04:21+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "341048691467bd651cae6ee4704f79ca27c0e499" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 4, + "insertions": 3, + "lines": 7, + "files": 1, + "dmm_unit_size": 0.0, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": "scipy_base/utility.py", + "new_path": "scipy_base/utility.py", + "filename": "utility.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -350,10 +350,9 @@ def objload(file, allglobals):\n fid.close()\n \n def isscalar(num):\n- ascalar = 0.0\n- for type in ScalarType:\n- ascalar += isinstance(num, type)\n- return ascalar\n+ if isinstance(num, ArrayType):\n+ return len(num.shape) == 0 and num.typecode() != 'O'\n+ return type(num) in ScalarType\n \n def all_mat(args):\n return map(Matrix.Matrix,args)\n", + "added_lines": 3, + "deleted_lines": 4, + "source_code": "import Numeric\nimport types\nimport cPickle\nimport sys\nimport scipy\n\nfrom Numeric import *\nfrom fastumath import *\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\n__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n 'dsplit','array_kind','array_precision','array_type','common_type',\n 'trim_zeros','cast']\n\n\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoInt = lambda x: Numeric.array(x, Numeric.Int)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\ntoComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n\ncast = {Numeric.Character: toChar,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\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 complex\n number, then the stop is not inclusive.\n\n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n part of it's magnitude is interpreted as specifying the number of points to\n create between the start and stop values, where the stop value\n IS INCLUSIVE.\n\n Example:\n\n >>> grid = nd_grid()\n >>> grid[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 >>> grid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n \"\"\"\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 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\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\ngrid = nd_grid()\n\nclass concatenator:\n \"\"\"An object which 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 = linspace(start, stop, num=size, 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\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\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\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 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\ndef r1array(x):\n \"\"\"Ensure x is at least 1-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n x = [x]\n elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n x.shape = (1,)\n return Numeric.asarray(x)\n\ndef r2array(x):\n \"\"\"Ensure x is at least 2-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n return Numeric.asarray([[x]])\n else:\n temp = Numeric.asarray(x)\n if len(temp.shape) == 1:\n if temp.shape[0] == 0:\n temp.shape = (0,) + temp.shape\n else:\n temp.shape = (1,) + temp.shape\n return temp\n\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'i' : 'integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\ndef who(vardict=None):\n \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n \"\"\"\n if vardict is None:\n print \"Pass in a dictionary: who(globals())\"\n return\n sta = []\n cache = {}\n for name in vardict.keys():\n if isinstance(vardict[name],Numeric.ArrayType):\n var = vardict[name]\n idv = id(var)\n if idv in cache.keys():\n namestr = name + \" (%s)\" % cache[idv]\n original=0\n else:\n cache[idv] = name\n namestr = name\n original=1\n shapestr = \" x \".join(map(str, var.shape))\n bytestr = str(var.itemsize()*Numeric.product(var.shape))\n sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n\n maxname = 0\n maxshape = 0\n maxbyte = 0\n totalbytes = 0\n for k in range(len(sta)):\n val = sta[k]\n if maxname < len(val[0]):\n maxname = len(val[0])\n if maxshape < len(val[1]):\n maxshape = len(val[1])\n if maxbyte < len(val[2]):\n maxbyte = len(val[2])\n if val[4]:\n totalbytes += int(val[2])\n\n max = Numeric.maximum\n if len(sta) > 0:\n sp1 = max(10,maxname)\n sp2 = max(10,maxshape)\n sp3 = max(10,maxbyte)\n prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n \n for k in range(len(sta)):\n val = sta[k]\n print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n val[1], ' '*(sp2-len(val[1])+5),\n val[2], ' '*(sp3-len(val[2])+5),\n val[3])\n print \"\\nUpper bound on total bytes = %d\" % totalbytes\n return\n \ndef objsave(file, allglobals, *args):\n \"\"\"Pickle the part of a dictionary containing the argument list\n into file string.\n\n Syntax: objsave(file, globals(), obj1, obj2, ... )\n \"\"\"\n fid = open(file,'w')\n savedict = {}\n for key in allglobals.keys():\n inarglist = 0\n for obj in args:\n if allglobals[key] is obj:\n inarglist = 1\n break\n if inarglist:\n savedict[key] = obj\n cPickle.dump(savedict,fid,1)\n fid.close()\n \ndef objload(file, allglobals):\n \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n\n Syntax: objload(file, globals())\n \"\"\"\n fid = open(file,'r')\n savedict = cPickle.load(fid)\n allglobals.update(savedict)\n fid.close()\n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n \n# Selector function\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\ndef atleast_1d(tup):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force a sequence of arrays to each be at least 1D. If an array\n in the sequence is 0D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 1D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_2d(tup):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force a sequence of arrays to each be at least 2D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_3d(tup):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force a sequence of arrays to each be at least 3D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n 1xNx1 array of values where N is the orginal length of the array.\n If the array is 2D, the array is converted to a single MxNx1\n array of values where MxN is the orginal shape of the array.\n Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_2d(tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_1d(tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,atleast_2d(tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(atleast_3d(tup),2)\n\ndef replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n \n# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\ndef trim_zeros(filt,trim='fb'):\n \"\"\"Trim the leading and trailing zeros from a 1D array.\n \n Example:\n\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 \"\"\"\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\n \n##def test(level=10):\n## from scipy_test import module_test\n## module_test(__name__,__file__,level=level)\n\n##def test_suite(level=1):\n## from scipy_test import module_test_suite\n## return module_test_suite(__name__,__file__,level=level)\n\n\n\n\n", + "source_code_before": "import Numeric\nimport types\nimport cPickle\nimport sys\nimport scipy\n\nfrom Numeric import *\nfrom fastumath import *\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\n__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n 'dsplit','array_kind','array_precision','array_type','common_type',\n 'trim_zeros','cast']\n\n\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoInt = lambda x: Numeric.array(x, Numeric.Int)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\ntoComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n\ncast = {Numeric.Character: toChar,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\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 complex\n number, then the stop is not inclusive.\n\n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n part of it's magnitude is interpreted as specifying the number of points to\n create between the start and stop values, where the stop value\n IS INCLUSIVE.\n\n Example:\n\n >>> grid = nd_grid()\n >>> grid[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 >>> grid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n \"\"\"\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 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\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\ngrid = nd_grid()\n\nclass concatenator:\n \"\"\"An object which 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 = linspace(start, stop, num=size, 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\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\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\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 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\ndef r1array(x):\n \"\"\"Ensure x is at least 1-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n x = [x]\n elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n x.shape = (1,)\n return Numeric.asarray(x)\n\ndef r2array(x):\n \"\"\"Ensure x is at least 2-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n return Numeric.asarray([[x]])\n else:\n temp = Numeric.asarray(x)\n if len(temp.shape) == 1:\n if temp.shape[0] == 0:\n temp.shape = (0,) + temp.shape\n else:\n temp.shape = (1,) + temp.shape\n return temp\n\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'i' : 'integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\ndef who(vardict=None):\n \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n \"\"\"\n if vardict is None:\n print \"Pass in a dictionary: who(globals())\"\n return\n sta = []\n cache = {}\n for name in vardict.keys():\n if isinstance(vardict[name],Numeric.ArrayType):\n var = vardict[name]\n idv = id(var)\n if idv in cache.keys():\n namestr = name + \" (%s)\" % cache[idv]\n original=0\n else:\n cache[idv] = name\n namestr = name\n original=1\n shapestr = \" x \".join(map(str, var.shape))\n bytestr = str(var.itemsize()*Numeric.product(var.shape))\n sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n\n maxname = 0\n maxshape = 0\n maxbyte = 0\n totalbytes = 0\n for k in range(len(sta)):\n val = sta[k]\n if maxname < len(val[0]):\n maxname = len(val[0])\n if maxshape < len(val[1]):\n maxshape = len(val[1])\n if maxbyte < len(val[2]):\n maxbyte = len(val[2])\n if val[4]:\n totalbytes += int(val[2])\n\n max = Numeric.maximum\n if len(sta) > 0:\n sp1 = max(10,maxname)\n sp2 = max(10,maxshape)\n sp3 = max(10,maxbyte)\n prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n \n for k in range(len(sta)):\n val = sta[k]\n print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n val[1], ' '*(sp2-len(val[1])+5),\n val[2], ' '*(sp3-len(val[2])+5),\n val[3])\n print \"\\nUpper bound on total bytes = %d\" % totalbytes\n return\n \ndef objsave(file, allglobals, *args):\n \"\"\"Pickle the part of a dictionary containing the argument list\n into file string.\n\n Syntax: objsave(file, globals(), obj1, obj2, ... )\n \"\"\"\n fid = open(file,'w')\n savedict = {}\n for key in allglobals.keys():\n inarglist = 0\n for obj in args:\n if allglobals[key] is obj:\n inarglist = 1\n break\n if inarglist:\n savedict[key] = obj\n cPickle.dump(savedict,fid,1)\n fid.close()\n \ndef objload(file, allglobals):\n \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n\n Syntax: objload(file, globals())\n \"\"\"\n fid = open(file,'r')\n savedict = cPickle.load(fid)\n allglobals.update(savedict)\n fid.close()\n\ndef isscalar(num):\n ascalar = 0.0\n for type in ScalarType:\n ascalar += isinstance(num, type)\n return ascalar\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n \n# Selector function\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\ndef atleast_1d(tup):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force a sequence of arrays to each be at least 1D. If an array\n in the sequence is 0D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 1D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_2d(tup):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force a sequence of arrays to each be at least 2D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_3d(tup):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force a sequence of arrays to each be at least 3D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n 1xNx1 array of values where N is the orginal length of the array.\n If the array is 2D, the array is converted to a single MxNx1\n array of values where MxN is the orginal shape of the array.\n Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_2d(tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_1d(tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,atleast_2d(tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(atleast_3d(tup),2)\n\ndef replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n \n# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\ndef trim_zeros(filt,trim='fb'):\n \"\"\"Trim the leading and trailing zeros from a 1D array.\n \n Example:\n\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 \"\"\"\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\n \n##def test(level=10):\n## from scipy_test import module_test\n## module_test(__name__,__file__,level=level)\n\n##def test_suite(level=1):\n## from scipy_test import module_test_suite\n## return module_test_suite(__name__,__file__,level=level)\n\n\n\n\n", + "methods": [ + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 71, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 114, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "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": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 125, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 31, + "complexity": 11, + "token_count": 253, + "parameters": [ + "self", + "key" + ], + "start_line": 127, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 159, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 162, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 195, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 202, + "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": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 204, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 213, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 226, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 235, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 263, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 268, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 323, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 342, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 352, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 357, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 363, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 411, + "end_line": 427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 429, + "end_line": 446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 448, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 471, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 501, + "end_line": 525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 527, + "end_line": 547, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 549, + "end_line": 575, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 577, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 585, + "end_line": 647, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 649, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 692, + "end_line": 731, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 733, + "end_line": 771, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 773, + "end_line": 808, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 817, + "end_line": 824, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 826, + "end_line": 846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 71, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 114, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "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": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 125, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 31, + "complexity": 11, + "token_count": 253, + "parameters": [ + "self", + "key" + ], + "start_line": 127, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 159, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 162, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 195, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 202, + "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": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 204, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 213, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 226, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 235, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 263, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 268, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 323, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 342, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 25, + "parameters": [ + "num" + ], + "start_line": 352, + "end_line": 356, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 358, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 364, + "end_line": 410, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 412, + "end_line": 428, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 430, + "end_line": 447, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 449, + "end_line": 470, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 472, + "end_line": 500, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 502, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 528, + "end_line": 548, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 550, + "end_line": 576, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 578, + "end_line": 584, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 586, + "end_line": 648, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 650, + "end_line": 691, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 693, + "end_line": 732, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 734, + "end_line": 772, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 774, + "end_line": 809, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 818, + "end_line": 825, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 827, + "end_line": 847, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 352, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + } + ], + "nloc": 404, + "complexity": 122, + "token_count": 3124, + "diff_parsed": { + "added": [ + " if isinstance(num, ArrayType):", + " return len(num.shape) == 0 and num.typecode() != 'O'", + " return type(num) in ScalarType" + ], + "deleted": [ + " ascalar = 0.0", + " for type in ScalarType:", + " ascalar += isinstance(num, type)", + " return ascalar" + ] + } + } + ] + }, + { + "hash": "1af787593b1620c950eed9464810852a7f10b7e1", + "msg": "added limits.py to scipy_base. It looks like Travis O. began this process, but didn't quite get to checking it in. I used the 1.13 version from the attic in scipy (the latest version there). Hope that is the right one.", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-01T13:35:36+00:00", + "author_timezone": 0, + "committer_date": "2002-04-01T13:35:36+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "14983d9c60649993fac02c6a9b4212a333ac858a" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 0, + "insertions": 80, + "lines": 80, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 1.0, + "modified_files": [ + { + "old_path": null, + "new_path": "scipy_base/limits.py", + "filename": "limits.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,80 @@\n+\"\"\" This really needs some work...\n+\n+ Calculate machine limits for Float32 and Float64.\n+ Actually, max and min are hard coded - and wrong!\n+ They are close, however.\n+\n+\"\"\"\n+\n+import Numeric\n+\n+toChar = lambda x: Numeric.array(x, Numeric.Character)\n+toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\n+toInt16 = lambda x: Numeric.array(x, Numeric.Int16)\n+toInt32 = lambda x: Numeric.array(x, Numeric.Int32)\n+toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\n+toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\n+\n+#cast[Float32] = toFloat32\n+#cast[Float64] = toFloat64\n+\n+def epsilon(typecode):\n+ if typecode == Numeric.Float32: cast = toFloat32\n+ elif typecode == Numeric.Float64: cast = toFloat64\n+ one = cast(1.0)\n+ x = cast(1.0)\n+ while one+x > one:\n+ x = x * cast(.5)\n+ x = x * cast(2.0)\n+ return x\n+\n+def tiny(typecode):\n+ if typecode == Numeric.Float32: cast = toFloat32\n+ if typecode == Numeric.Float64: cast = toFloat64\n+ zero = cast(0.0)\n+ d1 = cast(1.0)\n+ d2 = cast(1.0)\n+ while d1 > zero:\n+ d2 = d1\n+ d1 = d1 * cast(.5)\n+ return d2\n+\n+ \n+\n+float_epsilon = epsilon(Numeric.Float32)\n+float_tiny = tiny(Numeric.Float32)\n+#not correct\n+float_min = -3.402823e38\n+float_max = 3.402823e38\n+float_precision = 6\n+float_resolution = 10.0**(-float_precision)\n+\n+# hard coded - taken from Norbert's Fortran code.\n+# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n+# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n+# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n+# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n+# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n+# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\n+double_epsilon = epsilon(Numeric.Float64)\n+double_tiny = tiny(Numeric.Float64)\n+\n+# not quite right...\n+double_min = -1.797683134862318e308\n+double_max = 1.797683134862318e308\n+double_precision = 15\n+double_resolution = 10.0**(-double_precision)\n+\n+def test(level=10):\n+ from scipy_test import module_test\n+ module_test(__name__,__file__,level=level)\n+\n+def test_suite(level=1):\n+ from scipy_test import module_test_suite\n+ return module_test_suite(__name__,__file__,level=level)\n+\n+if __name__ == '__main__':\n+ print 'float epsilon:',float_epsilon\n+ print 'float tiny:',float_tiny\n+ print 'double epsilon:',double_epsilon\n+ print 'double tiny:',double_tiny\n", + "added_lines": 80, + "deleted_lines": 0, + "source_code": "\"\"\" This really needs some work...\n\n Calculate machine limits for Float32 and Float64.\n Actually, max and min are hard coded - and wrong!\n They are close, however.\n\n\"\"\"\n\nimport Numeric\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\n\n#cast[Float32] = toFloat32\n#cast[Float64] = toFloat64\n\ndef epsilon(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n elif typecode == Numeric.Float64: cast = toFloat64\n one = cast(1.0)\n x = cast(1.0)\n while one+x > one:\n x = x * cast(.5)\n x = x * cast(2.0)\n return x\n\ndef tiny(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n if typecode == Numeric.Float64: cast = toFloat64\n zero = cast(0.0)\n d1 = cast(1.0)\n d2 = cast(1.0)\n while d1 > zero:\n d2 = d1\n d1 = d1 * cast(.5)\n return d2\n\n \n\nfloat_epsilon = epsilon(Numeric.Float32)\nfloat_tiny = tiny(Numeric.Float32)\n#not correct\nfloat_min = -3.402823e38\nfloat_max = 3.402823e38\nfloat_precision = 6\nfloat_resolution = 10.0**(-float_precision)\n\n# hard coded - taken from Norbert's Fortran code.\n# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\ndouble_epsilon = epsilon(Numeric.Float64)\ndouble_tiny = tiny(Numeric.Float64)\n\n# not quite right...\ndouble_min = -1.797683134862318e308\ndouble_max = 1.797683134862318e308\ndouble_precision = 15\ndouble_resolution = 10.0**(-double_precision)\n\ndef test(level=10):\n from scipy_test import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": null, + "methods": [ + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 21, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 31, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "level" + ], + "start_line": 72, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "level" + ], + "start_line": 72, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 31, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 21, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + } + ], + "nloc": 56, + "complexity": 10, + "token_count": 378, + "diff_parsed": { + "added": [ + "\"\"\" This really needs some work...", + "", + " Calculate machine limits for Float32 and Float64.", + " Actually, max and min are hard coded - and wrong!", + " They are close, however.", + "", + "\"\"\"", + "", + "import Numeric", + "", + "toChar = lambda x: Numeric.array(x, Numeric.Character)", + "toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte", + "toInt16 = lambda x: Numeric.array(x, Numeric.Int16)", + "toInt32 = lambda x: Numeric.array(x, Numeric.Int32)", + "toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)", + "toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)", + "", + "#cast[Float32] = toFloat32", + "#cast[Float64] = toFloat64", + "", + "def epsilon(typecode):", + " if typecode == Numeric.Float32: cast = toFloat32", + " elif typecode == Numeric.Float64: cast = toFloat64", + " one = cast(1.0)", + " x = cast(1.0)", + " while one+x > one:", + " x = x * cast(.5)", + " x = x * cast(2.0)", + " return x", + "", + "def tiny(typecode):", + " if typecode == Numeric.Float32: cast = toFloat32", + " if typecode == Numeric.Float64: cast = toFloat64", + " zero = cast(0.0)", + " d1 = cast(1.0)", + " d2 = cast(1.0)", + " while d1 > zero:", + " d2 = d1", + " d1 = d1 * cast(.5)", + " return d2", + "", + "", + "", + "float_epsilon = epsilon(Numeric.Float32)", + "float_tiny = tiny(Numeric.Float32)", + "#not correct", + "float_min = -3.402823e38", + "float_max = 3.402823e38", + "float_precision = 6", + "float_resolution = 10.0**(-float_precision)", + "", + "# hard coded - taken from Norbert's Fortran code.", + "# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)", + "# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15", + "# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307", + "# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16", + "# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308", + "# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308", + "double_epsilon = epsilon(Numeric.Float64)", + "double_tiny = tiny(Numeric.Float64)", + "", + "# not quite right...", + "double_min = -1.797683134862318e308", + "double_max = 1.797683134862318e308", + "double_precision = 15", + "double_resolution = 10.0**(-double_precision)", + "", + "def test(level=10):", + " from scipy_test import module_test", + " module_test(__name__,__file__,level=level)", + "", + "def test_suite(level=1):", + " from scipy_test import module_test_suite", + " return module_test_suite(__name__,__file__,level=level)", + "", + "if __name__ == '__main__':", + " print 'float epsilon:',float_epsilon", + " print 'float tiny:',float_tiny", + " print 'double epsilon:',double_epsilon", + " print 'double tiny:',double_tiny" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "3e03aaf638ebb28c6cfdd91d6c3805fde6e0c44b", + "msg": "moved scipy_test into scipy_base and renamed it. It shouldn't be automatically imported into scipy_base namespace since it is generally only used when testing code.", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-01T13:57:48+00:00", + "author_timezone": 0, + "committer_date": "2002-04-01T13:57:48+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "1af787593b1620c950eed9464810852a7f10b7e1" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 0, + "insertions": 334, + "lines": 334, + "files": 1, + "dmm_unit_size": 0.645320197044335, + "dmm_unit_complexity": 0.7586206896551724, + "dmm_unit_interfacing": 0.3251231527093596, + "modified_files": [ + { + "old_path": null, + "new_path": "scipy_base/testing.py", + "filename": "testing.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,334 @@\n+\n+import os,sys,time\n+import unittest\n+\n+class ScipyTestCase (unittest.TestCase):\n+\n+ def measure(self,code_str,times=1):\n+ frame = sys._getframe(1)\n+ locs,globs = frame.f_locals,frame.f_globals\n+ code = compile(code_str,\n+ 'ScipyTestCase runner for '+self.__class__.__name__,\n+ 'exec')\n+ i = 0\n+ elapsed = time.time()\n+ while i scipy.limits.double_max\n # -Inf -> scipy.limits.double_min\n # complex not handled currently\n- import scipy.limits\n+ import limits\n try:\n t = x.typecode()\n except AttributeError:\n@@ -515,11 +515,11 @@ def complex_cmp(x,y):\n \n \n def test(level=10):\n- from scipy_test import module_test\n+ from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n \n def test_suite(level=1):\n- from scipy_test import module_test_suite\n+ from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n \n \n", + "added_lines": 3, + "deleted_lines": 3, + "source_code": "\"\"\"Contains basic routines of common interest. Always imported first.\n Basically MLab minus the LinearAlgebra-dependent functions.\n\n But max is changed to amax (array max)\n and min is changed to amin (array min)\n so that the builtin max and min are still available.\n\"\"\"\n\n\n__all__ = ['logspace','linspace','round','any','all','fix','mod','fftshift',\n 'ifftshift','fftfreq','cont_ft','toeplitz','hankel','real','imag',\n 'iscomplex','isreal','array_iscomplex','array_isreal','isposinf',\n 'isneginf','nan_to_num','eye','tri','diag','fliplr','flipud',\n 'rot90','tril','triu','amax','amin','ptp','cumsum','prod','cumprod',\n 'diff','squeeze','sinc','angle','unwrap','real_if_close',\n 'sort_complex']\n\nimport Numeric\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 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 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\n#def round(arr):\n# return Numeric.floor(arr+0.5)\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\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 fftshift(x,axes=None):\n \"\"\"Shift the result of an FFT operation.\n\n Return a shifted version of x (useful for obtaining centered spectra).\n This function swaps \"half-spaces\" for all axes listed (defaults to all)\n \"\"\"\n ndim = len(x.shape)\n if axes == None:\n axes = range(ndim)\n y = x\n for k in axes:\n N = x.shape[k]\n p2 = int(Numeric.ceil(N/2.0))\n mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n y = Numeric.take(y,mylist,k)\n return y\n\ndef ifftshift(x,axes=None):\n \"\"\"Reverse the effect of fftshift.\n \"\"\"\n ndim = len(x.shape)\n if axes == None:\n axes = range(ndim)\n y = x\n for k in axes:\n N = x.shape[k]\n p2 = int(Numeric.floor(N/2.0))\n mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n y = Numeric.take(y,mylist,k)\n return y\n\ndef fftfreq(N,sample=1.0):\n \"\"\"FFT sample frequencies\n \n Return the frequency bins in cycles/unit (with zero at the start) given a\n window length N and a sample spacing.\n \"\"\"\n N = int(N)\n sample = float(sample)\n return Numeric.concatenate((Numeric.arange(0,(N-1)/2+1,1,'d'),Numeric.arange(-(N-1)/2,0,1,'d')))/N/sample\n\ndef cont_ft(gn,fr,delta=1.0,n=None):\n \"\"\"Compute the (scaled) DFT of gn at frequencies fr.\n\n If the gn are alias-free samples of a continuous time function then the\n correct value for the spacing, delta, will give the properly scaled,\n continuous Fourier spectrum.\n\n The DFT is obtained when delta=1.0\n \"\"\"\n if n is None:\n n = Numeric.arange(len(gn))\n dT = delta\n trans_kernel = Numeric.exp(-2j*Numeric.pi*fr[:,Numeric.NewAxis]*dT*n)\n return dT*Numeric.dot(trans_kernel,gn)\n\ndef toeplitz(c,r=None):\n \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).\n\n Description:\n\n toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first\n column and r as its first row.\n\n toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). \n\n See also: hankel\n \"\"\"\n if isscalar(c) or isscalar(r):\n return c \n if r is None:\n r = c\n r[0] = Numeric.conjugate(r[0])\n c = Numeric.conjugate(c)\n r,c = map(Numeric.asarray,(r,c))\n r,c = map(Numeric.ravel,(r,c))\n rN,cN = map(len,(r,c))\n if r[0] != c[0]:\n print \"Warning: column and row values don't agree; column value used.\"\n vals = r_[r[rN-1:0:-1], c]\n cols = grid[0:cN]\n rows = grid[rN:0:-1]\n indx = cols[:,Numeric.NewAxis]*Numeric.ones((1,rN)) + \\\n rows[Numeric.NewAxis,:]*Numeric.ones((cN,1)) - 1\n return Numeric.take(vals, indx)\n\n\ndef hankel(c,r=None):\n \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).\n\n Description:\n\n hankel(c,r) is a Hankel matrix whose first column is c and whose\n last row is r.\n\n hankel(c) is a square Hankel matrix whose first column is C.\n Elements below the first anti-diagonal are zero.\n\n See also: toeplitz\n \"\"\"\n if isscalar(c) or isscalar(r):\n return c \n if r is None:\n r = Numeric.zeros(len(c))\n elif r[0] != c[-1]:\n print \"Warning: column and row values don't agree; column value used.\"\n r,c = map(Numeric.asarray,(r,c))\n r,c = map(Numeric.ravel,(r,c))\n rN,cN = map(len,(r,c))\n vals = r_[c, r[1:rN]]\n cols = grid[1:cN+1]\n rows = grid[0:rN]\n indx = cols[:,Numeric.NewAxis]*Numeric.ones((1,rN)) + \\\n rows[Numeric.NewAxis,:]*Numeric.ones((cN,1)) - 1\n return Numeric.take(vals, indx)\n\n\ndef real(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.real\n else:\n return aval\n\ndef imag(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.imag\n else:\n return array(0,aval.typecode())*aval\n\ndef iscomplex(x):\n return imag(x) != Numeric.zeros(asarray(x).shape)\n\ndef isreal(x):\n return imag(x) == Numeric.zeros(asarray(x).shape)\n\ndef array_iscomplex(x):\n return asarray(x).typecode() in ['F', 'D']\n\ndef array_isreal(x):\n return not asarray(x).typecode() in ['F', 'D']\n\ndef isposinf(val):\n # complex not handled currently (and potentially ambiguous)\n return Numeric.logical_and(isinf(val),val > 0)\n\ndef isneginf(val):\n # complex not handled currently (and potentially ambiguous)\n return Numeric.logical_and(isinf(val),val < 0)\n \ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> scipy.limits.double_max\n # -Inf -> scipy.limits.double_min\n # complex not handled currently\n import limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = Numeric.asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,scipy.limits.double_min, 0., scipy.limits.double_max))\n return y\n\n# These are from Numeric\nfrom Numeric import *\nimport Numeric\nimport Matrix\nfrom utility import isscalar\nfrom fastumath import *\n\n\n# Elementary Matrices\n\n# zeros is from matrixmodule in C\n# ones is from Numeric.py\n\n\ndef eye(N, M=None, k=0, typecode=None):\n \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the \n k-th diagonal is all ones, 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 tri(N, M=None, k=0, typecode=None):\n \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all\n the diagonals starting from lower left corner up to the k-th are all ones.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n \n# Matrix manipulation\n\ndef diag(v, k=0):\n \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or\n returns a matrix 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 \ndef fliplr(m):\n \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and\n columns flipped in the left/right direction. Only works with 2-D\n 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 \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and\n rows flipped in 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 \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees\n in the 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 tril(m, k=0):\n \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n out.savespace(svsp)\n return out\n\ndef triu(m, k=0):\n \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n out.savespace(svsp)\n return out\n\n# Data analysis\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\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n a = asarray(a)\n b = asarray(a.shape)\n return reshape (a, tuple (compress (not_equal (b, 1), b)))\n\ndef sinc(x):\n \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.\n \"\"\"\n w = asarray(x*pi)\n return where(x==0, 1.0, sin(w)/w)\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\nimport copy\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwrap(p,discont=pi,axis=-1)\n\n unwraps radian phase p by changing absolute jumps greater than discont to\n 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) 0)\n\ndef isneginf(val):\n # complex not handled currently (and potentially ambiguous)\n return Numeric.logical_and(isinf(val),val < 0)\n \ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> scipy.limits.double_max\n # -Inf -> scipy.limits.double_min\n # complex not handled currently\n import scipy.limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = Numeric.asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,scipy.limits.double_min, 0., scipy.limits.double_max))\n return y\n\n# These are from Numeric\nfrom Numeric import *\nimport Numeric\nimport Matrix\nfrom utility import isscalar\nfrom fastumath import *\n\n\n# Elementary Matrices\n\n# zeros is from matrixmodule in C\n# ones is from Numeric.py\n\n\ndef eye(N, M=None, k=0, typecode=None):\n \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the \n k-th diagonal is all ones, 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 tri(N, M=None, k=0, typecode=None):\n \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all\n the diagonals starting from lower left corner up to the k-th are all ones.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n \n# Matrix manipulation\n\ndef diag(v, k=0):\n \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or\n returns a matrix 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 \ndef fliplr(m):\n \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and\n columns flipped in the left/right direction. Only works with 2-D\n 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 \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and\n rows flipped in 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 \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees\n in the 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 tril(m, k=0):\n \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n out.savespace(svsp)\n return out\n\ndef triu(m, k=0):\n \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n out.savespace(svsp)\n return out\n\n# Data analysis\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\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n a = asarray(a)\n b = asarray(a.shape)\n return reshape (a, tuple (compress (not_equal (b, 1), b)))\n\ndef sinc(x):\n \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.\n \"\"\"\n w = asarray(x*pi)\n return where(x==0, 1.0, sin(w)/w)\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\nimport copy\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwrap(p,discont=pi,axis=-1)\n\n unwraps radian phase p by changing absolute jumps greater than discont to\n 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) one:\n x = x * cast(.5)\n x = x * cast(2.0)\n return x\n\ndef tiny(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n if typecode == Numeric.Float64: cast = toFloat64\n zero = cast(0.0)\n d1 = cast(1.0)\n d2 = cast(1.0)\n while d1 > zero:\n d2 = d1\n d1 = d1 * cast(.5)\n return d2\n\n \n\nfloat_epsilon = epsilon(Numeric.Float32)\nfloat_tiny = tiny(Numeric.Float32)\n#not correct\nfloat_min = -3.402823e38\nfloat_max = 3.402823e38\nfloat_precision = 6\nfloat_resolution = 10.0**(-float_precision)\n\n# hard coded - taken from Norbert's Fortran code.\n# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\ndouble_epsilon = epsilon(Numeric.Float64)\ndouble_tiny = tiny(Numeric.Float64)\n\n# not quite right...\ndouble_min = -1.797683134862318e308\ndouble_max = 1.797683134862318e308\ndouble_precision = 15\ndouble_resolution = 10.0**(-double_precision)\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": "\"\"\" This really needs some work...\n\n Calculate machine limits for Float32 and Float64.\n Actually, max and min are hard coded - and wrong!\n They are close, however.\n\n\"\"\"\n\nimport Numeric\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\n\n#cast[Float32] = toFloat32\n#cast[Float64] = toFloat64\n\ndef epsilon(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n elif typecode == Numeric.Float64: cast = toFloat64\n one = cast(1.0)\n x = cast(1.0)\n while one+x > one:\n x = x * cast(.5)\n x = x * cast(2.0)\n return x\n\ndef tiny(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n if typecode == Numeric.Float64: cast = toFloat64\n zero = cast(0.0)\n d1 = cast(1.0)\n d2 = cast(1.0)\n while d1 > zero:\n d2 = d1\n d1 = d1 * cast(.5)\n return d2\n\n \n\nfloat_epsilon = epsilon(Numeric.Float32)\nfloat_tiny = tiny(Numeric.Float32)\n#not correct\nfloat_min = -3.402823e38\nfloat_max = 3.402823e38\nfloat_precision = 6\nfloat_resolution = 10.0**(-float_precision)\n\n# hard coded - taken from Norbert's Fortran code.\n# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\ndouble_epsilon = epsilon(Numeric.Float64)\ndouble_tiny = tiny(Numeric.Float64)\n\n# not quite right...\ndouble_min = -1.797683134862318e308\ndouble_max = 1.797683134862318e308\ndouble_precision = 15\ndouble_resolution = 10.0**(-double_precision)\n\ndef test(level=10):\n from scipy_test import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_test import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "methods": [ + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 21, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 31, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 72, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 21, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 31, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 21, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 22, + "parameters": [ + "level" + ], + "start_line": 72, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 72, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "nloc": 56, + "complexity": 10, + "token_count": 382, + "diff_parsed": { + "added": [ + " from scipy_base.testing import module_test", + " from scipy_base.testing import module_test_suite" + ], + "deleted": [ + " from scipy_test import module_test", + " from scipy_test import module_test_suite" + ] + } + }, + { + "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": "@@ -3,7 +3,7 @@\n import os\n from glob import glob\n from scipy_distutils.core import Extension\n-from scipy_distutils.misc_util import get_path, default_config_dict\n+from scipy_distutils.misc_util import get_path, default_config_dict,dot_join\n \n def configuration(parent_package=''):\n parent_path = parent_package\n@@ -15,6 +15,10 @@ def configuration(parent_package=''):\n config['packages'].append(parent_package+'scipy_base')\n config['package_dir'][parent_package+'scipy_base'] = local_path\n \n+ config['packages'].append(dot_join(parent_package,'scipy_base.tests'))\n+ test_path = os.path.join(local_path,'tests')\n+ config['package_dir']['scipy_base.tests'] = test_path\n+\n # fastumath module\n sources = ['fastumathmodule.c']\n sources = [os.path.join(local_path,x) for x in sources]\n", + "added_lines": 5, + "deleted_lines": 1, + "source_code": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path, default_config_dict,dot_join\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_base')\n config['package_dir'][parent_package+'scipy_base'] = local_path\n\n config['packages'].append(dot_join(parent_package,'scipy_base.tests'))\n test_path = os.path.join(local_path,'tests')\n config['package_dir']['scipy_base.tests'] = test_path\n\n # fastumath module\n sources = ['fastumathmodule.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base.fastumath',sources,libraries=[])\n config['ext_modules'].append(ext)\n \n\n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", + "source_code_before": "#!/usr/bin/env python\n\nimport os\nfrom glob import glob\nfrom scipy_distutils.core import Extension\nfrom scipy_distutils.misc_util import get_path, default_config_dict\n\ndef configuration(parent_package=''):\n parent_path = parent_package\n if parent_package:\n parent_package += '.'\n local_path = get_path(__name__)\n\n config = default_config_dict()\n config['packages'].append(parent_package+'scipy_base')\n config['package_dir'][parent_package+'scipy_base'] = local_path\n\n # fastumath module\n sources = ['fastumathmodule.c']\n sources = [os.path.join(local_path,x) for x in sources]\n ext = Extension('scipy_base.fastumath',sources,libraries=[])\n config['ext_modules'].append(ext)\n \n\n return config\n\nif __name__ == '__main__': \n from scipy_distutils.core import setup\n setup(**configuration())\n", + "methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' )", + "filename": "setup_scipy_base.py", + "nloc": 16, + "complexity": 3, + "token_count": 131, + "parameters": [ + "parent_package" + ], + "start_line": 8, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' )", + "filename": "setup_scipy_base.py", + "nloc": 13, + "complexity": 3, + "token_count": 96, + "parameters": [ + "parent_package" + ], + "start_line": 8, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "configuration", + "long_name": "configuration( parent_package = '' )", + "filename": "setup_scipy_base.py", + "nloc": 16, + "complexity": 3, + "token_count": 131, + "parameters": [ + "parent_package" + ], + "start_line": 8, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + } + ], + "nloc": 23, + "complexity": 3, + "token_count": 172, + "diff_parsed": { + "added": [ + "from scipy_distutils.misc_util import get_path, default_config_dict,dot_join", + " config['packages'].append(dot_join(parent_package,'scipy_base.tests'))", + " test_path = os.path.join(local_path,'tests')", + " config['package_dir']['scipy_base.tests'] = test_path", + "" + ], + "deleted": [ + "from scipy_distutils.misc_util import get_path, default_config_dict" + ] + } + }, + { + "old_path": "scipy_base/utility.py", + "new_path": "scipy_base/utility.py", + "filename": "utility.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,6 @@\n import types\n import cPickle\n import sys\n-import scipy\n \n from Numeric import *\n from fastumath import *\n@@ -480,6 +479,7 @@ def vstack(tup):\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n+ >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n@@ -510,6 +510,7 @@ def hstack(tup):\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n+ >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n@@ -535,6 +536,7 @@ def column_stack(tup):\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n+ >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n@@ -559,6 +561,7 @@ def dstack(tup):\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n+ >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n@@ -714,6 +717,7 @@ def hsplit(ary,indices_or_sections):\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n+ >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n@@ -761,8 +765,10 @@ def vsplit(ary,indices_or_sections):\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n+ import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n+ >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n@@ -827,10 +833,10 @@ def trim_zeros(filt,trim='fb'):\n \"\"\"Trim the leading and trailing zeros from a 1D array.\n \n Example:\n-\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+ >>> 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 \"\"\"\n first = 0\n@@ -847,11 +853,11 @@ def trim_zeros(filt,trim='fb'):\n \n \n ##def test(level=10):\n-## from scipy_test import module_test\n+## from scipy_base.testing import module_test\n ## module_test(__name__,__file__,level=level)\n \n ##def test_suite(level=1):\n-## from scipy_test import module_test_suite\n+## from scipy_base.testing import module_test_suite\n ## return module_test_suite(__name__,__file__,level=level)\n \n \n", + "added_lines": 13, + "deleted_lines": 7, + "source_code": "import Numeric\nimport types\nimport cPickle\nimport sys\n\nfrom Numeric import *\nfrom fastumath import *\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\n__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n 'dsplit','array_kind','array_precision','array_type','common_type',\n 'trim_zeros','cast']\n\n\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoInt = lambda x: Numeric.array(x, Numeric.Int)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\ntoComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n\ncast = {Numeric.Character: toChar,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\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 complex\n number, then the stop is not inclusive.\n\n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n part of it's magnitude is interpreted as specifying the number of points to\n create between the start and stop values, where the stop value\n IS INCLUSIVE.\n\n Example:\n\n >>> grid = nd_grid()\n >>> grid[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 >>> grid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n \"\"\"\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 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\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\ngrid = nd_grid()\n\nclass concatenator:\n \"\"\"An object which 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 = linspace(start, stop, num=size, 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\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\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\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 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\ndef r1array(x):\n \"\"\"Ensure x is at least 1-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n x = [x]\n elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n x.shape = (1,)\n return Numeric.asarray(x)\n\ndef r2array(x):\n \"\"\"Ensure x is at least 2-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n return Numeric.asarray([[x]])\n else:\n temp = Numeric.asarray(x)\n if len(temp.shape) == 1:\n if temp.shape[0] == 0:\n temp.shape = (0,) + temp.shape\n else:\n temp.shape = (1,) + temp.shape\n return temp\n\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'i' : 'integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\ndef who(vardict=None):\n \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n \"\"\"\n if vardict is None:\n print \"Pass in a dictionary: who(globals())\"\n return\n sta = []\n cache = {}\n for name in vardict.keys():\n if isinstance(vardict[name],Numeric.ArrayType):\n var = vardict[name]\n idv = id(var)\n if idv in cache.keys():\n namestr = name + \" (%s)\" % cache[idv]\n original=0\n else:\n cache[idv] = name\n namestr = name\n original=1\n shapestr = \" x \".join(map(str, var.shape))\n bytestr = str(var.itemsize()*Numeric.product(var.shape))\n sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n\n maxname = 0\n maxshape = 0\n maxbyte = 0\n totalbytes = 0\n for k in range(len(sta)):\n val = sta[k]\n if maxname < len(val[0]):\n maxname = len(val[0])\n if maxshape < len(val[1]):\n maxshape = len(val[1])\n if maxbyte < len(val[2]):\n maxbyte = len(val[2])\n if val[4]:\n totalbytes += int(val[2])\n\n max = Numeric.maximum\n if len(sta) > 0:\n sp1 = max(10,maxname)\n sp2 = max(10,maxshape)\n sp3 = max(10,maxbyte)\n prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n \n for k in range(len(sta)):\n val = sta[k]\n print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n val[1], ' '*(sp2-len(val[1])+5),\n val[2], ' '*(sp3-len(val[2])+5),\n val[3])\n print \"\\nUpper bound on total bytes = %d\" % totalbytes\n return\n \ndef objsave(file, allglobals, *args):\n \"\"\"Pickle the part of a dictionary containing the argument list\n into file string.\n\n Syntax: objsave(file, globals(), obj1, obj2, ... )\n \"\"\"\n fid = open(file,'w')\n savedict = {}\n for key in allglobals.keys():\n inarglist = 0\n for obj in args:\n if allglobals[key] is obj:\n inarglist = 1\n break\n if inarglist:\n savedict[key] = obj\n cPickle.dump(savedict,fid,1)\n fid.close()\n \ndef objload(file, allglobals):\n \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n\n Syntax: objload(file, globals())\n \"\"\"\n fid = open(file,'r')\n savedict = cPickle.load(fid)\n allglobals.update(savedict)\n fid.close()\n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n \n# Selector function\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\ndef atleast_1d(tup):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force a sequence of arrays to each be at least 1D. If an array\n in the sequence is 0D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 1D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_2d(tup):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force a sequence of arrays to each be at least 2D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_3d(tup):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force a sequence of arrays to each be at least 3D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n 1xNx1 array of values where N is the orginal length of the array.\n If the array is 2D, the array is converted to a single MxNx1\n array of values where MxN is the orginal shape of the array.\n Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_2d(tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_1d(tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,atleast_2d(tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(atleast_3d(tup),2)\n\ndef replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n \n# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\ndef trim_zeros(filt,trim='fb'):\n \"\"\"Trim the leading and trailing zeros from a 1D array.\n \n Example:\n >>> 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 \"\"\"\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\n \n##def test(level=10):\n## from scipy_base.testing import module_test\n## module_test(__name__,__file__,level=level)\n\n##def test_suite(level=1):\n## from scipy_base.testing import module_test_suite\n## return module_test_suite(__name__,__file__,level=level)\n\n\n\n\n", + "source_code_before": "import Numeric\nimport types\nimport cPickle\nimport sys\nimport scipy\n\nfrom Numeric import *\nfrom fastumath import *\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\n__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n 'dsplit','array_kind','array_precision','array_type','common_type',\n 'trim_zeros','cast']\n\n\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoInt = lambda x: Numeric.array(x, Numeric.Int)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\ntoComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n\ncast = {Numeric.Character: toChar,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\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 complex\n number, then the stop is not inclusive.\n\n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n part of it's magnitude is interpreted as specifying the number of points to\n create between the start and stop values, where the stop value\n IS INCLUSIVE.\n\n Example:\n\n >>> grid = nd_grid()\n >>> grid[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 >>> grid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n \"\"\"\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 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\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\ngrid = nd_grid()\n\nclass concatenator:\n \"\"\"An object which 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 = linspace(start, stop, num=size, 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\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\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\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 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\ndef r1array(x):\n \"\"\"Ensure x is at least 1-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n x = [x]\n elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n x.shape = (1,)\n return Numeric.asarray(x)\n\ndef r2array(x):\n \"\"\"Ensure x is at least 2-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n return Numeric.asarray([[x]])\n else:\n temp = Numeric.asarray(x)\n if len(temp.shape) == 1:\n if temp.shape[0] == 0:\n temp.shape = (0,) + temp.shape\n else:\n temp.shape = (1,) + temp.shape\n return temp\n\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'i' : 'integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\ndef who(vardict=None):\n \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n \"\"\"\n if vardict is None:\n print \"Pass in a dictionary: who(globals())\"\n return\n sta = []\n cache = {}\n for name in vardict.keys():\n if isinstance(vardict[name],Numeric.ArrayType):\n var = vardict[name]\n idv = id(var)\n if idv in cache.keys():\n namestr = name + \" (%s)\" % cache[idv]\n original=0\n else:\n cache[idv] = name\n namestr = name\n original=1\n shapestr = \" x \".join(map(str, var.shape))\n bytestr = str(var.itemsize()*Numeric.product(var.shape))\n sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n\n maxname = 0\n maxshape = 0\n maxbyte = 0\n totalbytes = 0\n for k in range(len(sta)):\n val = sta[k]\n if maxname < len(val[0]):\n maxname = len(val[0])\n if maxshape < len(val[1]):\n maxshape = len(val[1])\n if maxbyte < len(val[2]):\n maxbyte = len(val[2])\n if val[4]:\n totalbytes += int(val[2])\n\n max = Numeric.maximum\n if len(sta) > 0:\n sp1 = max(10,maxname)\n sp2 = max(10,maxshape)\n sp3 = max(10,maxbyte)\n prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n \n for k in range(len(sta)):\n val = sta[k]\n print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n val[1], ' '*(sp2-len(val[1])+5),\n val[2], ' '*(sp3-len(val[2])+5),\n val[3])\n print \"\\nUpper bound on total bytes = %d\" % totalbytes\n return\n \ndef objsave(file, allglobals, *args):\n \"\"\"Pickle the part of a dictionary containing the argument list\n into file string.\n\n Syntax: objsave(file, globals(), obj1, obj2, ... )\n \"\"\"\n fid = open(file,'w')\n savedict = {}\n for key in allglobals.keys():\n inarglist = 0\n for obj in args:\n if allglobals[key] is obj:\n inarglist = 1\n break\n if inarglist:\n savedict[key] = obj\n cPickle.dump(savedict,fid,1)\n fid.close()\n \ndef objload(file, allglobals):\n \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n\n Syntax: objload(file, globals())\n \"\"\"\n fid = open(file,'r')\n savedict = cPickle.load(fid)\n allglobals.update(savedict)\n fid.close()\n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n \n# Selector function\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\ndef atleast_1d(tup):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force a sequence of arrays to each be at least 1D. If an array\n in the sequence is 0D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 1D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_2d(tup):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force a sequence of arrays to each be at least 2D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_3d(tup):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force a sequence of arrays to each be at least 3D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n 1xNx1 array of values where N is the orginal length of the array.\n If the array is 2D, the array is converted to a single MxNx1\n array of values where MxN is the orginal shape of the array.\n Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_2d(tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_1d(tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,atleast_2d(tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(atleast_3d(tup),2)\n\ndef replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n \n# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\ndef trim_zeros(filt,trim='fb'):\n \"\"\"Trim the leading and trailing zeros from a 1D array.\n \n Example:\n\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 \"\"\"\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\n \n##def test(level=10):\n## from scipy_test import module_test\n## module_test(__name__,__file__,level=level)\n\n##def test_suite(level=1):\n## from scipy_test import module_test_suite\n## return module_test_suite(__name__,__file__,level=level)\n\n\n\n\n", + "methods": [ + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 70, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 113, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 116, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 124, + "end_line": 125, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 31, + "complexity": 11, + "token_count": 253, + "parameters": [ + "self", + "key" + ], + "start_line": 126, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 158, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 161, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 194, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 200, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , start , stop )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 203, + "end_line": 206, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 212, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 225, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 234, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 262, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 267, + "end_line": 320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 322, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 341, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 351, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 356, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 362, + "end_line": 408, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 410, + "end_line": 426, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 428, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 447, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 470, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 501, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 528, + "end_line": 549, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 551, + "end_line": 578, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 580, + "end_line": 586, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 588, + "end_line": 650, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 652, + "end_line": 693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 695, + "end_line": 735, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 737, + "end_line": 777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 779, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 823, + "end_line": 830, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 832, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 71, + "end_line": 112, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 114, + "end_line": 115, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "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": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 125, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 31, + "complexity": 11, + "token_count": 253, + "parameters": [ + "self", + "key" + ], + "start_line": 127, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 159, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 162, + "end_line": 163, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 195, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 201, + "end_line": 202, + "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": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 204, + "end_line": 207, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 213, + "end_line": 223, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 226, + "end_line": 233, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 235, + "end_line": 247, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 263, + "end_line": 266, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 268, + "end_line": 321, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 323, + "end_line": 340, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 342, + "end_line": 350, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 352, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 357, + "end_line": 358, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 363, + "end_line": 409, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 411, + "end_line": 427, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 429, + "end_line": 446, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 448, + "end_line": 469, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 471, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 501, + "end_line": 525, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 527, + "end_line": 547, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 549, + "end_line": 575, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 577, + "end_line": 583, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 585, + "end_line": 647, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 649, + "end_line": 690, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 692, + "end_line": 731, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 40, + "top_nesting_level": 0 + }, + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 733, + "end_line": 771, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 39, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 773, + "end_line": 808, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 817, + "end_line": 824, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 826, + "end_line": 846, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 737, + "end_line": 777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 551, + "end_line": 578, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 832, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 695, + "end_line": 735, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 528, + "end_line": 549, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 501, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 470, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + } + ], + "nloc": 403, + "complexity": 122, + "token_count": 3122, + "diff_parsed": { + "added": [ + " >>> import scipy", + " >>> import scipy", + " >>> import scipy", + " >>> import scipy", + " >>> import scipy", + " import scipy", + " >>> scipy.vsplit(a)", + " >>> import scipy", + " >>> a = array((0,0,0,1,2,3,2,1,0))", + " >>> scipy.trim_zeros(a)", + " array([1, 2, 3, 2, 1])", + "## from scipy_base.testing import module_test", + "## from scipy_base.testing import module_test_suite" + ], + "deleted": [ + "import scipy", + "", + " >>> a = array((0,0,0,1,2,3,2,1,0))", + " >>> scipy.trim_zeros(a)", + " array([1, 2, 3, 2, 1])", + "## from scipy_test import module_test", + "## from scipy_test import module_test_suite" + ] + } + } + ] + }, + { + "hash": "c3823840a169558363ca66041114ac337492f6fc", + "msg": "More special functions. Cleaned up use of limits. Added __all__ to limits.", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-04-01T19:33:48+00:00", + "author_timezone": 0, + "committer_date": "2002-04-01T19:33:48+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "42cec8382b625c970ad8d65c3d23af229bbfd86e" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 10, + "insertions": 6, + "lines": 16, + "files": 2, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy_base/limits.py", + "new_path": "scipy_base/limits.py", + "filename": "limits.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -7,16 +7,12 @@\n \"\"\"\n \n import Numeric\n+from utility import toFloat32, toFloat64\n \n-toChar = lambda x: Numeric.array(x, Numeric.Character)\n-toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\n-toInt16 = lambda x: Numeric.array(x, Numeric.Int16)\n-toInt32 = lambda x: Numeric.array(x, Numeric.Int32)\n-toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\n-toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\n-\n-#cast[Float32] = toFloat32\n-#cast[Float64] = toFloat64\n+__all__ = ['epsilon','tiny','float_epsilon','float_tiny','float_min',\n+ 'float_max','float_precision','float_resolution',\n+ 'double_epsilon','double_tiny','double_min','double_max',\n+ 'double_precision','double_resolution']\n \n def epsilon(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n", + "added_lines": 5, + "deleted_lines": 9, + "source_code": "\"\"\" This really needs some work...\n\n Calculate machine limits for Float32 and Float64.\n Actually, max and min are hard coded - and wrong!\n They are close, however.\n\n\"\"\"\n\nimport Numeric\nfrom utility import toFloat32, toFloat64\n\n__all__ = ['epsilon','tiny','float_epsilon','float_tiny','float_min',\n 'float_max','float_precision','float_resolution',\n 'double_epsilon','double_tiny','double_min','double_max',\n 'double_precision','double_resolution']\n\ndef epsilon(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n elif typecode == Numeric.Float64: cast = toFloat64\n one = cast(1.0)\n x = cast(1.0)\n while one+x > one:\n x = x * cast(.5)\n x = x * cast(2.0)\n return x\n\ndef tiny(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n if typecode == Numeric.Float64: cast = toFloat64\n zero = cast(0.0)\n d1 = cast(1.0)\n d2 = cast(1.0)\n while d1 > zero:\n d2 = d1\n d1 = d1 * cast(.5)\n return d2\n\n \n\nfloat_epsilon = epsilon(Numeric.Float32)\nfloat_tiny = tiny(Numeric.Float32)\n#not correct\nfloat_min = -3.402823e38\nfloat_max = 3.402823e38\nfloat_precision = 6\nfloat_resolution = 10.0**(-float_precision)\n\n# hard coded - taken from Norbert's Fortran code.\n# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\ndouble_epsilon = epsilon(Numeric.Float64)\ndouble_tiny = tiny(Numeric.Float64)\n\n# not quite right...\ndouble_min = -1.797683134862318e308\ndouble_max = 1.797683134862318e308\ndouble_precision = 15\ndouble_resolution = 10.0**(-double_precision)\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": "\"\"\" This really needs some work...\n\n Calculate machine limits for Float32 and Float64.\n Actually, max and min are hard coded - and wrong!\n They are close, however.\n\n\"\"\"\n\nimport Numeric\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\n\n#cast[Float32] = toFloat32\n#cast[Float64] = toFloat64\n\ndef epsilon(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n elif typecode == Numeric.Float64: cast = toFloat64\n one = cast(1.0)\n x = cast(1.0)\n while one+x > one:\n x = x * cast(.5)\n x = x * cast(2.0)\n return x\n\ndef tiny(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n if typecode == Numeric.Float64: cast = toFloat64\n zero = cast(0.0)\n d1 = cast(1.0)\n d2 = cast(1.0)\n while d1 > zero:\n d2 = d1\n d1 = d1 * cast(.5)\n return d2\n\n \n\nfloat_epsilon = epsilon(Numeric.Float32)\nfloat_tiny = tiny(Numeric.Float32)\n#not correct\nfloat_min = -3.402823e38\nfloat_max = 3.402823e38\nfloat_precision = 6\nfloat_resolution = 10.0**(-float_precision)\n\n# hard coded - taken from Norbert's Fortran code.\n# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\ndouble_epsilon = epsilon(Numeric.Float64)\ndouble_tiny = tiny(Numeric.Float64)\n\n# not quite right...\ndouble_min = -1.797683134862318e308\ndouble_max = 1.797683134862318e308\ndouble_precision = 15\ndouble_resolution = 10.0**(-double_precision)\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "methods": [ + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 17, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 27, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 64, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 21, + "end_line": 29, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 31, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 72, + "end_line": 74, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 55, + "complexity": 10, + "token_count": 329, + "diff_parsed": { + "added": [ + "from utility import toFloat32, toFloat64", + "__all__ = ['epsilon','tiny','float_epsilon','float_tiny','float_min',", + " 'float_max','float_precision','float_resolution',", + " 'double_epsilon','double_tiny','double_min','double_max',", + " 'double_precision','double_resolution']" + ], + "deleted": [ + "toChar = lambda x: Numeric.array(x, Numeric.Character)", + "toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte", + "toInt16 = lambda x: Numeric.array(x, Numeric.Int16)", + "toInt32 = lambda x: Numeric.array(x, Numeric.Int32)", + "toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)", + "toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)", + "", + "#cast[Float32] = toFloat32", + "#cast[Float64] = toFloat64" + ] + } + }, + { + "old_path": "scipy_base/scimath.py", + "new_path": "scipy_base/scimath.py", + "filename": "scimath.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -3,7 +3,7 @@\n different than the input under certain conditions.\n \"\"\"\n \n-__all__ = ['sqrt', 'log', 'log10', 'power', 'arccos', 'arcsin', 'arctanh']\n+__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']\n \n from convenience import any, isreal\n import fastumath\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions whose output is\ndifferent than the input under certain conditions.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']\n\nfrom convenience import any, isreal\nimport fastumath\nimport Numeric\nfrom fastumath import *\ntoextend = fastumath.__dict__.keys()\nfor key in toextend:\n if key not in __all__ and key[0] != '_':\n __all__.append(key)\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,s):\n \"\"\" logn(n,s) -- Take log base n of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(s)/fastumath.log(n)\n\ndef log2(s):\n \"\"\" log2(s) -- Take log base 2 of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(s)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n\n\n", + "source_code_before": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions whose output is\ndifferent than the input under certain conditions.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log10', 'power', 'arccos', 'arcsin', 'arctanh']\n\nfrom convenience import any, isreal\nimport fastumath\nimport Numeric\nfrom fastumath import *\ntoextend = fastumath.__dict__.keys()\nfor key in toextend:\n if key not in __all__ and key[0] != '_':\n __all__.append(key)\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,s):\n \"\"\" logn(n,s) -- Take log base n of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(s)/fastumath.log(n)\n\ndef log2(s):\n \"\"\" log2(s) -- Take log base 2 of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(s)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n\n\n", + "methods": [ + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 17, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 29, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , s )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "s" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( s )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "s" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 60, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 72, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 17, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 29, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , s )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "s" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( s )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "s" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 60, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 72, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 65, + "complexity": 31, + "token_count": 517, + "diff_parsed": { + "added": [ + "__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']" + ], + "deleted": [ + "__all__ = ['sqrt', 'log', 'log10', 'power', 'arccos', 'arcsin', 'arctanh']" + ] + } + } + ] + }, + { + "hash": "5082215ea3a74cc66a0da9e80094ec503d6ef185", + "msg": "Applying David M. Cooke's patch with some modifications", + "author": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "committer": { + "name": "Pearu Peterson", + "email": "pearu.peterson@gmail.com" + }, + "author_date": "2002-04-01T23:28:37+00:00", + "author_timezone": 0, + "committer_date": "2002-04-01T23:28:37+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "c3823840a169558363ca66041114ac337492f6fc" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 127, + "insertions": 198, + "lines": 325, + "files": 2, + "dmm_unit_size": 0.5555555555555556, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 0.0, + "modified_files": [ + { + "old_path": null, + "new_path": "scipy_distutils/sample_site.cfg", + "filename": "sample_site.cfg", + "extension": "cfg", + "change_type": "ADD", + "diff": "@@ -0,0 +1,36 @@\n+#\n+# This is a sample file of site.cfg that should be in scipy_distutils\n+# directory. If it has different name than site.cfg (e.g. sample_site.cfg)\n+# then you must rename it to site.cfg. Otherwise it has no effect.\n+#\n+# Default values are defined in scipy_distutils/system_info.py\n+# file and here shown in comments. Feel free to uncomment and modify\n+# the corresponding values to your system needs.\n+#\n+\n+[DEFAULT]\n+# lib_dir = /usr/local/lib:/opt/lib:/usr/lib\n+# include_dir = /usr/local/include:/opt/include:/usr/include\n+\n+# Use static libraries in preference to shared ones:\n+# static_first = 1\n+\n+[atlas]\n+# system_info.py searches atlas and lapack from the following paths\n+# lib_dir:DEFAULT/atlas*:DEFAULT/ATLAS*:DEFAULT\n+# where DEFAULT refers to lib_dir defined in [DEFAULT] section and\n+lib_dir = /usr/lib/3dnow # Debian Sid\n+\n+# For overriding the names of the atlas libraries:\n+# atlas_libs = f77blas, cblas, atlas\n+# lapack_libs = lapack\n+\n+\n+[fftw]\n+fftw_libs = fftw, rfftw\n+fftw_opt_libs = fftw_threaded, rfftw_threaded\n+# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n+\n+[x11]\n+# lib_dir = /usr/X11R6/lib\n+# include_dir = /usr/X11R6/include\n", + "added_lines": 36, + "deleted_lines": 0, + "source_code": "#\n# This is a sample file of site.cfg that should be in scipy_distutils\n# directory. If it has different name than site.cfg (e.g. sample_site.cfg)\n# then you must rename it to site.cfg. Otherwise it has no effect.\n#\n# Default values are defined in scipy_distutils/system_info.py\n# file and here shown in comments. Feel free to uncomment and modify\n# the corresponding values to your system needs.\n#\n\n[DEFAULT]\n# lib_dir = /usr/local/lib:/opt/lib:/usr/lib\n# include_dir = /usr/local/include:/opt/include:/usr/include\n\n# Use static libraries in preference to shared ones:\n# static_first = 1\n\n[atlas]\n# system_info.py searches atlas and lapack from the following paths\n# lib_dir:DEFAULT/atlas*:DEFAULT/ATLAS*:DEFAULT\n# where DEFAULT refers to lib_dir defined in [DEFAULT] section and\nlib_dir = /usr/lib/3dnow # Debian Sid\n\n# For overriding the names of the atlas libraries:\n# atlas_libs = f77blas, cblas, atlas\n# lapack_libs = lapack\n\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[x11]\n# lib_dir = /usr/X11R6/lib\n# include_dir = /usr/X11R6/include\n", + "source_code_before": null, + "methods": [], + "methods_before": [], + "changed_methods": [], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [ + "#", + "# This is a sample file of site.cfg that should be in scipy_distutils", + "# directory. If it has different name than site.cfg (e.g. sample_site.cfg)", + "# then you must rename it to site.cfg. Otherwise it has no effect.", + "#", + "# Default values are defined in scipy_distutils/system_info.py", + "# file and here shown in comments. Feel free to uncomment and modify", + "# the corresponding values to your system needs.", + "#", + "", + "[DEFAULT]", + "# lib_dir = /usr/local/lib:/opt/lib:/usr/lib", + "# include_dir = /usr/local/include:/opt/include:/usr/include", + "", + "# Use static libraries in preference to shared ones:", + "# static_first = 1", + "", + "[atlas]", + "# system_info.py searches atlas and lapack from the following paths", + "# lib_dir:DEFAULT/atlas*:DEFAULT/ATLAS*:DEFAULT", + "# where DEFAULT refers to lib_dir defined in [DEFAULT] section and", + "lib_dir = /usr/lib/3dnow # Debian Sid", + "", + "# For overriding the names of the atlas libraries:", + "# atlas_libs = f77blas, cblas, atlas", + "# lapack_libs = lapack", + "", + "", + "[fftw]", + "fftw_libs = fftw, rfftw", + "fftw_opt_libs = fftw_threaded, rfftw_threaded", + "# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs", + "", + "[x11]", + "# lib_dir = /usr/X11R6/lib", + "# include_dir = /usr/X11R6/include" + ], + "deleted": [] + } + }, + { + "old_path": "scipy_distutils/system_info.py", + "new_path": "scipy_distutils/system_info.py", + "filename": "system_info.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -7,9 +7,6 @@\n atlas_info\n fftw_info\n x11_info\n-The following environment variables are used if defined:\n- ATLAS - path to ATLAS library\n- FFTW - path to FFTW library\n \n Usage:\n info_dict = get_info()\n@@ -20,32 +17,72 @@\n asked resource is not available (or system_info could not find it).\n \n Global parameters:\n- prefixes - a list of prefixes for scanning the location of\n- resources.\n system_info.static_first - a flag for indicating that static\n libraries are searched first than shared ones.\n system_info.verbose - show the results if set.\n \n-Author:\n+The file 'site.cfg' in the same directory as this module is read\n+for configuration options. The format is that used by ConfigParser (i.e.,\n+Windows .INI style). The section DEFAULT has options that are the default\n+for each section. The available sections are fftw, atlas, and x11. Appropiate\n+defaults are used if nothing is specified.\n+\n+Example:\n+----------\n+[DEFAULT]\n+lib_dir = /usr/lib:/usr/local/lib:/opt/lib\n+include_dir = /usr/include:/usr/local/include:/opt/include\n+# use static libraries in preference to shared ones\n+static_first = 1\n+\n+[fftw]\n+fftw_libs = fftw, rfftw\n+fftw_opt_libs = fftw_threaded, rfftw_threaded\n+# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n+\n+[atlas]\n+lib_dir = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n+# for overriding the names of the atlas libraries\n+atlas_libs = f77blas, cblas, atlas\n+lapack_libs = lapack\n+\n+[x11]\n+lib_dir = /usr/X11R6/lib\n+include_dir = /usr/X11R6/include\n+----------\n+\n+Authors:\n Pearu Peterson , February 2002\n+ David M. Cooke , April 2002\n Permission to use, modify, and distribute this software is given under the\n terms of the LGPL. See http://www.fsf.org\n NO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n \"\"\"\n \n-import sys,os,re,types,pprint\n+import sys,os,re,types\n from distutils.errors import DistutilsError\n from glob import glob\n+import ConfigParser\n \n from distutils.sysconfig import get_config_vars\n \n if sys.platform == 'win32':\n- prefixes = ['C:\\\\'] # XXX: what is prefix in win32?\n+ default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n+ default_include_dirs = []\n+ default_x11_lib_dirs = []\n+ default_x11_include_dirs = []\n else:\n- prefixes = ['/usr','/usr/local','/opt']\n-if sys.prefix not in prefixes:\n- prefixes.append(sys.prefix)\n-prefixes = filter(os.path.isdir,prefixes) # XXX: Is this ok on win32? Is 'C:' dir?\n+ default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n+ default_include_dirs = ['/usr/local/include',\n+ '/opt/include', '/usr/include']\n+ default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n+ default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n+\n+if os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n+ default_lib_dirs.append(os.path.join(sys.prefix, 'lib'))\n+ default_include_dirs.append(os.path.join(sys.prefix, 'include'))\n+default_lib_dirs = filter(os.path.isdir, default_lib_dirs)\n+default_include_dirs = filter(os.path.isdir, default_include_dirs)\n \n so_ext = get_config_vars('SO')[0] or ''\n \n@@ -89,16 +126,31 @@ class system_info:\n \n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n+ section = 'DEFAULT'\n \n static_first = 1\n verbose = 1\n need_refresh = 1\n saved_results = {}\n- \n- def __init__ (self):\n+\n+ def __init__ (self,\n+ default_lib_dirs=default_lib_dirs,\n+ default_include_dirs=default_include_dirs,\n+ ):\n self.__class__.info = {}\n #self.__class__.need_refresh = not self.info\n self.local_prefixes = []\n+ defaults = {}\n+ defaults['lib_dir'] = ':'.join(default_lib_dirs)\n+ defaults['include_dir'] = ':'.join(default_include_dirs)\n+ defaults['static_first'] = '1'\n+ self.cp = ConfigParser.ConfigParser(defaults)\n+ cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n+ 'site.cfg')\n+ self.cp.read([cf])\n+ if not self.cp.has_section(self.section):\n+ self.cp.add_section(self.section)\n+ self.static_first = self.cp.getboolean(self.section, 'static_first')\n \n def set_info(self,**info):\n #self.__class__.info = info\n@@ -114,15 +166,8 @@ def get_info(self):\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n- for n in ['calc_info','calc_info_debian']:\n- calc_info = getattr(self,n,None)\n- if calc_info is None: continue\n- for p in self.local_prefixes + prefixes:\n- if self.verbose:\n- print ' Looking in',p,'...'\n- calc_info(p)\n- if self.has_info(): break\n- if self.has_info(): break\n+ if hasattr(self, 'calc_info'):\n+ self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n@@ -137,8 +182,26 @@ def get_info(self):\n return res\n \n def calc_info_template(self,prefix):\n- \"\"\" Calculate info distionary. \"\"\"\n- \n+ \"\"\" Calculate info dictionary. \"\"\"\n+\n+ def get_paths(self, section, key):\n+ dirs = self.cp.get(section, key).split(':')\n+ default_dirs = self.cp.get('DEFAULT', key).split(':')\n+ dirs.extend(default_dirs)\n+ return [ d for d in dirs if os.path.isdir(d) ]\n+\n+ def get_lib_dirs(self, key='lib_dir'):\n+ return self.get_paths(self.section, key)\n+ def get_include_dirs(self, key='include_dir'):\n+ return self.get_paths(self.section, key)\n+\n+ def get_libs(self, key, default):\n+ try:\n+ libs = self.cp.get(self.section, key)\n+ except ConfigParser.NoOptionError:\n+ return default\n+ return [a.strip() for a in libs.split(',')]\n+\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n@@ -174,41 +237,19 @@ def check_shared_libs(self,lib_dir,libs,opt_libs =[]):\n \n \n class fftw_info(system_info):\n+ section = 'fftw'\n \n def __init__(self):\n system_info.__init__(self)\n- p = os.environ.get('FFTW')\n- if p is not None:\n- p = os.path.abspath(p)\n- if os.path.isdir(p):\n- self.local_prefixes.insert(0,p)\n-\n- def calc_info(self,prefix): \n- lib_dirs = filter(os.path.isdir,\n- combine_paths(prefix,'lib',['fftw*','FFTW*']))\n- if not lib_dirs:\n- lib_dirs = filter(os.path.isdir,\n- combine_paths(prefix,['fftw*','FFTW*'],'lib'))\n- if not lib_dirs:\n- lib_dirs = filter(os.path.isdir,\n- combine_paths(prefix,['lib','fftw*','FFTW*']))\n- \n- if not lib_dirs:\n- lib_dirs = [prefix]\n- incl_dirs = filter(os.path.isdir,\n- combine_paths(prefix,'include',['fftw*','FFTW*']))\n- if not incl_dirs:\n- incl_dirs = filter(os.path.isdir,\n- combine_paths(prefix,['fftw*','FFTW*'],'include'))\n- if not incl_dirs:\n- incl_dirs = filter(os.path.isdir,\n- combine_paths(prefix,['include','fftw*','FFTW*']))\n- if not incl_dirs:\n- incl_dirs = [prefix]\n+\n+ def calc_info(self):\n+ lib_dirs = self.get_lib_dirs()\n+ incl_dirs = self.get_include_dirs()\n incl_dir = None\n \n- libs = ['fftw','rfftw']\n- opt_libs = ['fftw_threads','rfftw_threads']\n+ libs = self.get_libs('fftw_libs', ['fftw','rfftw'])\n+ opt_libs = self.get_libs('fftw_opt_libs',\n+ ['fftw_threads','rfftw_threads'])\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n@@ -230,8 +271,9 @@ def calc_info(self,prefix):\n info = None\n \n if info is None:\n- libs = ['dfftw','drfftw']\n- opt_libs = ['dfftw_threads','drfftw_threads']\n+ libs = self.get_libs('dfftw_libs', ['dfftw', 'drfftw'])\n+ opt_libs = self.get_libs('dfftw_opt_libs',\n+ ['dfftw_threads', 'drfftw_threads'])\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n@@ -251,9 +293,10 @@ def calc_info(self,prefix):\n dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)])\n else:\n info = None\n- \n- libs = ['sfftw','srfftw']\n- opt_libs = ['sfftw_threads','srfftw_threads']\n+\n+ libs = self.get_libs('sfftw_libs', ['sfftw', 'srfftw'])\n+ opt_libs = self.get_libs('sfftw_opt_libs',\n+ ['sfftw_threads', 'srfftw_threads'])\n flag = 0\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n@@ -274,89 +317,81 @@ def calc_info(self,prefix):\n \n \n class atlas_info(system_info):\n+ section = 'atlas'\n \n- def __init__(self):\n- system_info.__init__(self)\n- p = os.environ.get('ATLAS')\n- if p is not None:\n- p = os.path.abspath(p)\n- if os.path.isdir(p):\n- self.local_prefixes.insert(0,p)\n-\n- def calc_info(self, prefix):\n- print combine_paths(prefix,'lib',['atlas*','ATLAS*'])\n- lib_dirs = filter(os.path.isdir,combine_paths(prefix,'lib',\n- ['atlas*','ATLAS*']))\n- if lib_dirs:\n- other_dirs = filter(os.path.isdir,combine_paths(lib_dirs,'*'))\n- other_dirs.extend(filter(os.path.isdir,combine_paths(prefix,'lib')))\n- lib_dirs.extend(other_dirs)\n- else:\n- lib_dirs = filter(os.path.isdir,\n- combine_paths(prefix,['lib','atlas*','ATLAS*']))\n- if not lib_dirs:\n- lib_dirs = [prefix]\n-\n- h = (combine_paths(lib_dirs,'cblas.h') or [None])[0]\n- if not h:\n- h = (combine_paths(lib_dirs,'include','cblas.h') or [None])[0]\n- if h: h = os.path.dirname(h)\n+ def get_paths(self, section, key):\n+ default_dirs = self.cp.get('DEFAULT', key).split(':')\n+ dirs = []\n+ for d in self.cp.get(section, key).split(':') + default_dirs:\n+ dirs.extend([d]+combine_paths(d,['atlas*','ATLAS*']))\n+ return [ d for d in dirs if os.path.isdir(d) ]\n \n- libs = ['lapack','f77blas','cblas','atlas']\n+ def calc_info(self):\n+ lib_dirs = self.get_lib_dirs()\n+ include_dirs = self.get_include_dirs()\n+\n+ h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n+ if h: h = os.path.dirname(h)\n info = None\n+ # lapack must appear before atlas\n+ lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n- r = self.check_libs(d,libs,[])\n- if r is not None:\n- info = r\n+ lapack = self.check_libs(d,lapack_libs,[])\n+ if lapack is not None:\n+ info = lapack \n+ break\n+ else:\n+ return\n+ atlas_libs = self.get_libs('atlas_libs', ['f77blas', 'cblas', 'atlas'])\n+ for d in lib_dirs:\n+ atlas = self.check_libs(d,atlas_libs,[])\n+ if atlas is not None:\n+ dict_append(info, **atlas)\n break\n- if info is None: return\n+ else:\n+ return\n+\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n \n- def calc_info_debian(self,prefix):\n- print 'Trying Debian setup'\n- atlas = self.check_libs(os.path.join(prefix,'lib'),\n- ['cblas','f77blas','atlas'],[])\n- if not atlas: return\n- lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])\n- if not lapack:\n- lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])\n- if not lapack: return\n- info = lapack\n- h = (combine_paths(prefix,'include','cblas.h') or [None])[0]\n- if h: dict_append(info,include_dirs=[os.path.dirname(h)])\n- dict_append(info,**atlas)\n- self.set_info(**info)\n- \n-class blas_info(system_info):\n- # For Fortran or optimized blas, not atlas.\n- pass\n+## class blas_info(system_info):\n+## # For Fortran or optimized blas, not atlas.\n+## pass\n \n \n-class lapack_info(system_info):\n- # For Fortran or optimized lapack, not atlas\n- pass\n+## class lapack_info(system_info):\n+## # For Fortran or optimized lapack, not atlas\n+## pass\n \n \n class x11_info(system_info):\n+ section = 'x11'\n+\n+ def __init__(self):\n+ system_info.__init__(self,\n+ default_lib_dirs=default_x11_lib_dirs,\n+ default_include_dirs=default_x11_include_dirs)\n \n- def calc_info(self, prefix):\n+ def calc_info(self):\n if sys.platform == 'win32':\n return\n- for x11_dir in combine_paths(prefix,['X11R6','X11']):\n- inc_dir = None\n- for d in combine_paths(x11_dir,['include','include/X11']):\n- if combine_paths(d,'X.h'):\n- inc_dir = d\n- break\n- if not d: return\n- lib_dir = combine_paths(x11_dir,'lib')\n- if not lib_dir: return\n- info = self.check_libs(lib_dir[0],['X11'],[])\n- if info is None:\n- continue\n- dict_append(info,include_dirs=[inc_dir])\n- self.set_info(**info)\n+ lib_dirs = self.get_lib_dirs()\n+ include_dirs = self.get_include_dirs()\n+ x11_libs = self.get_libs('x11_libs', ['X11'])\n+ for lib_dir in lib_dirs:\n+ info = self.check_libs(lib_dir, x11_libs, [])\n+ if info is not None:\n+ break\n+ else:\n+ return\n+ inc_dir = None\n+ for d in include_dirs:\n+ if combine_paths(d, 'X11/X.h'):\n+ inc_dir = d\n+ break\n+ if inc_dir is not None:\n+ dict_append(info, include_dirs=[inc_dir])\n+ self.set_info(**info)\n \n def shortest_path(pths):\n pths.sort()\n", + "added_lines": 162, + "deleted_lines": 127, + "source_code": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n fftw_info\n x11_info\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (or system_info could not find it).\n\nGlobal parameters:\n system_info.static_first - a flag for indicating that static\n libraries are searched first than shared ones.\n system_info.verbose - show the results if set.\n\nThe file 'site.cfg' in the same directory as this module is read\nfor configuration options. The format is that used by ConfigParser (i.e.,\nWindows .INI style). The section DEFAULT has options that are the default\nfor each section. The available sections are fftw, atlas, and x11. Appropiate\ndefaults are used if nothing is specified.\n\nExample:\n----------\n[DEFAULT]\nlib_dir = /usr/lib:/usr/local/lib:/opt/lib\ninclude_dir = /usr/include:/usr/local/include:/opt/include\n# use static libraries in preference to shared ones\nstatic_first = 1\n\n[fftw]\nfftw_libs = fftw, rfftw\nfftw_opt_libs = fftw_threaded, rfftw_threaded\n# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs\n\n[atlas]\nlib_dir = /usr/lib/3dnow:/usr/lib/3dnow/atlas\n# for overriding the names of the atlas libraries\natlas_libs = f77blas, cblas, atlas\nlapack_libs = lapack\n\n[x11]\nlib_dir = /usr/X11R6/lib\ninclude_dir = /usr/X11R6/include\n----------\n\nAuthors:\n Pearu Peterson , February 2002\n David M. Cooke , April 2002\nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types\nfrom distutils.errors import DistutilsError\nfrom glob import glob\nimport ConfigParser\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n default_lib_dirs = ['C:\\\\'] # probably not very helpful...\n default_include_dirs = []\n default_x11_lib_dirs = []\n default_x11_include_dirs = []\nelse:\n default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']\n default_include_dirs = ['/usr/local/include',\n '/opt/include', '/usr/include']\n default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']\n default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']\n\nif os.path.join(sys.prefix, 'lib') not in default_lib_dirs:\n default_lib_dirs.append(os.path.join(sys.prefix, 'lib'))\n default_include_dirs.append(os.path.join(sys.prefix, 'include'))\ndefault_lib_dirs = filter(os.path.isdir, default_lib_dirs)\ndefault_include_dirs = filter(os.path.isdir, default_include_dirs)\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info}.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Either install them in /usr/local/lib/atlas or /usr/lib/atlas\n and retry setup.py. One can use also ATLAS environment variable\n to indicate the location of Atlas libraries.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Either install them in /usr/local/lib or /usr/lib and retry setup.py.\n One can use also FFTW environment variable to indicate\n the location of FFTW libraries.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://pfdubois.com/numpy/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n section = 'DEFAULT'\n\n static_first = 1\n verbose = 1\n need_refresh = 1\n saved_results = {}\n\n def __init__ (self,\n default_lib_dirs=default_lib_dirs,\n default_include_dirs=default_include_dirs,\n ):\n self.__class__.info = {}\n #self.__class__.need_refresh = not self.info\n self.local_prefixes = []\n defaults = {}\n defaults['lib_dir'] = ':'.join(default_lib_dirs)\n defaults['include_dir'] = ':'.join(default_include_dirs)\n defaults['static_first'] = '1'\n self.cp = ConfigParser.ConfigParser(defaults)\n cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],\n 'site.cfg')\n self.cp.read([cf])\n if not self.cp.has_section(self.section):\n self.cp.add_section(self.section)\n self.static_first = self.cp.getboolean(self.section, 'static_first')\n\n def set_info(self,**info):\n #self.__class__.info = info\n self.saved_results[self.__class__.__name__] = info\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n if hasattr(self, 'calc_info'):\n self.calc_info()\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n print ' %s = %s'%(k,v)\n print\n return res\n\n def calc_info_template(self,prefix):\n \"\"\" Calculate info dictionary. \"\"\"\n\n def get_paths(self, section, key):\n dirs = self.cp.get(section, key).split(':')\n default_dirs = self.cp.get('DEFAULT', key).split(':')\n dirs.extend(default_dirs)\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def get_lib_dirs(self, key='lib_dir'):\n return self.get_paths(self.section, key)\n def get_include_dirs(self, key='include_dir'):\n return self.get_paths(self.section, key)\n\n def get_libs(self, key, default):\n try:\n libs = self.cp.get(self.section, key)\n except ConfigParser.NoOptionError:\n return default\n return [a.strip() for a in libs.split(',')]\n\n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n mths = [self.check_static_libs,self.check_shared_libs]\n if not self.static_first:\n mths.reverse() # if one prefers shared libraries\n for m in mths:\n info = m(lib_dir,libs,opt_libs)\n if info is not None: return info\n\n def check_static_libs(self,lib_dir,libs,opt_libs =[]):\n #XXX: what are .lib and .dll files under win32?\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs])) == len(libs):\n info = {'libraries':libs,'library_dirs':[lib_dir]}\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs]))\\\n ==len(opt_libs):\n info['libraries'].extend(opt_libs)\n return info\n\n def check_shared_libs(self,lib_dir,libs,opt_libs =[]):\n shared_libs = []\n for l in libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: shared_libs.append(p)\n if len(shared_libs) == len(libs):\n info = {'extra_objects':shared_libs}\n opt_shared_libs = []\n for l in opt_libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: opt_shared_libs.append(p)\n info['extra_objects'].extend(opt_shared_libs)\n return info\n\n\nclass fftw_info(system_info):\n section = 'fftw'\n\n def __init__(self):\n system_info.__init__(self)\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n incl_dirs = self.get_include_dirs()\n incl_dir = None\n\n libs = self.get_libs('fftw_libs', ['fftw','rfftw'])\n opt_libs = self.get_libs('fftw_opt_libs',\n ['fftw_threads','rfftw_threads'])\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['fftw.h','rfftw.h']))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_FFTW_H',1)])\n else:\n info = None\n\n if info is None:\n libs = self.get_libs('dfftw_libs', ['dfftw', 'drfftw'])\n opt_libs = self.get_libs('dfftw_opt_libs',\n ['dfftw_threads', 'drfftw_threads'])\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['dfftw.h','drfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n incl_dirs = [d]\n incl_dir = d\n flag = 1\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)])\n else:\n info = None\n\n libs = self.get_libs('sfftw_libs', ['sfftw', 'srfftw'])\n opt_libs = self.get_libs('sfftw_opt_libs',\n ['sfftw_threads', 'srfftw_threads'])\n flag = 0\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n if info is None: info = r\n else: dict_append(info,**r)\n flag = 1\n break\n if info is not None and flag:\n for d in incl_dirs:\n if len(combine_paths(d,['sfftw.h','srfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n dict_append(info,define_macros=[('SCIPY_SFFTW_H',1)])\n break\n if info is not None:\n self.set_info(**info)\n\n\nclass atlas_info(system_info):\n section = 'atlas'\n\n def get_paths(self, section, key):\n default_dirs = self.cp.get('DEFAULT', key).split(':')\n dirs = []\n for d in self.cp.get(section, key).split(':') + default_dirs:\n dirs.extend([d]+combine_paths(d,['atlas*','ATLAS*']))\n return [ d for d in dirs if os.path.isdir(d) ]\n\n def calc_info(self):\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n\n h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n info = None\n # lapack must appear before atlas\n lapack_libs = self.get_libs('lapack_libs', ['lapack'])\n for d in lib_dirs:\n lapack = self.check_libs(d,lapack_libs,[])\n if lapack is not None:\n info = lapack \n break\n else:\n return\n atlas_libs = self.get_libs('atlas_libs', ['f77blas', 'cblas', 'atlas'])\n for d in lib_dirs:\n atlas = self.check_libs(d,atlas_libs,[])\n if atlas is not None:\n dict_append(info, **atlas)\n break\n else:\n return\n\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n\n## class blas_info(system_info):\n## # For Fortran or optimized blas, not atlas.\n## pass\n\n\n## class lapack_info(system_info):\n## # For Fortran or optimized lapack, not atlas\n## pass\n\n\nclass x11_info(system_info):\n section = 'x11'\n\n def __init__(self):\n system_info.__init__(self,\n default_lib_dirs=default_x11_lib_dirs,\n default_include_dirs=default_x11_include_dirs)\n\n def calc_info(self):\n if sys.platform == 'win32':\n return\n lib_dirs = self.get_lib_dirs()\n include_dirs = self.get_include_dirs()\n x11_libs = self.get_libs('x11_libs', ['X11'])\n for lib_dir in lib_dirs:\n info = self.check_libs(lib_dir, x11_libs, [])\n if info is not None:\n break\n else:\n return\n inc_dir = None\n for d in include_dirs:\n if combine_paths(d, 'X11/X.h'):\n inc_dir = d\n break\n if inc_dir is not None:\n dict_append(info, include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef shortest_path(pths):\n pths.sort()\n if pths: return pths[0]\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", + "source_code_before": "#!/usr/bin/env python\n\"\"\"\nThis file defines a set of system_info classes for getting\ninformation about various resources (libraries, library directories,\ninclude directories, etc.) in the system. Currently, the following\nclasses are available:\n atlas_info\n fftw_info\n x11_info\nThe following environment variables are used if defined:\n ATLAS - path to ATLAS library\n FFTW - path to FFTW library\n\nUsage:\n info_dict = get_info()\n where is a string 'atlas','x11','fftw'.\n\n Returned info_dict is a dictionary which is compatible with\n distutils.setup keyword arguments. If info_dict == {}, then the\n asked resource is not available (or system_info could not find it).\n\nGlobal parameters:\n prefixes - a list of prefixes for scanning the location of\n resources.\n system_info.static_first - a flag for indicating that static\n libraries are searched first than shared ones.\n system_info.verbose - show the results if set.\n\nAuthor:\n Pearu Peterson , February 2002\nPermission to use, modify, and distribute this software is given under the\nterms of the LGPL. See http://www.fsf.org\nNO WARRANTY IS EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.\n\"\"\"\n\nimport sys,os,re,types,pprint\nfrom distutils.errors import DistutilsError\nfrom glob import glob\n\nfrom distutils.sysconfig import get_config_vars\n\nif sys.platform == 'win32':\n prefixes = ['C:\\\\'] # XXX: what is prefix in win32?\nelse:\n prefixes = ['/usr','/usr/local','/opt']\nif sys.prefix not in prefixes:\n prefixes.append(sys.prefix)\nprefixes = filter(os.path.isdir,prefixes) # XXX: Is this ok on win32? Is 'C:' dir?\n\nso_ext = get_config_vars('SO')[0] or ''\n\ndef get_info(name):\n cl = {'atlas':atlas_info,\n 'x11':x11_info,\n 'fftw':fftw_info}.get(name.lower(),system_info)\n return cl().get_info()\n\nclass NotFoundError(DistutilsError):\n \"\"\"Some third-party program or library is not found.\"\"\"\n\nclass AtlasNotFoundError(NotFoundError):\n \"\"\"\n Atlas (http://math-atlas.sourceforge.net/) libraries not found.\n Either install them in /usr/local/lib/atlas or /usr/lib/atlas\n and retry setup.py. One can use also ATLAS environment variable\n to indicate the location of Atlas libraries.\"\"\"\n\nclass FFTWNotFoundError(NotFoundError):\n \"\"\"\n FFTW (http://www.fftw.org/) libraries not found.\n Either install them in /usr/local/lib or /usr/lib and retry setup.py.\n One can use also FFTW environment variable to indicate\n the location of FFTW libraries.\"\"\"\n\nclass F2pyNotFoundError(NotFoundError):\n \"\"\"\n f2py2e (http://cens.ioc.ee/projects/f2py2e/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass NumericNotFoundError(NotFoundError):\n \"\"\"\n Numeric (http://pfdubois.com/numpy/) module not found.\n Get it from above location, install it, and retry setup.py.\"\"\"\n\nclass X11NotFoundError(NotFoundError):\n \"\"\"X11 libraries not found.\"\"\"\n\nclass system_info:\n\n \"\"\" get_info() is the only public method. Don't use others.\n \"\"\"\n\n static_first = 1\n verbose = 1\n need_refresh = 1\n saved_results = {}\n \n def __init__ (self):\n self.__class__.info = {}\n #self.__class__.need_refresh = not self.info\n self.local_prefixes = []\n\n def set_info(self,**info):\n #self.__class__.info = info\n self.saved_results[self.__class__.__name__] = info\n def has_info(self):\n return self.saved_results.has_key(self.__class__.__name__)\n def get_info(self):\n \"\"\" Return a dictonary with items that are compatible\n with scipy_distutils.setup keyword arguments.\n \"\"\"\n flag = 0\n if not self.has_info():\n flag = 1\n if self.verbose:\n print self.__class__.__name__ + ':'\n for n in ['calc_info','calc_info_debian']:\n calc_info = getattr(self,n,None)\n if calc_info is None: continue\n for p in self.local_prefixes + prefixes:\n if self.verbose:\n print ' Looking in',p,'...'\n calc_info(p)\n if self.has_info(): break\n if self.has_info(): break\n if self.verbose:\n if not self.has_info():\n print ' NOT AVAILABLE'\n self.set_info()\n else:\n print ' FOUND:'\n res = self.saved_results.get(self.__class__.__name__)\n if self.verbose and flag:\n for k,v in res.items():\n print ' %s = %s'%(k,v)\n print\n return res\n\n def calc_info_template(self,prefix):\n \"\"\" Calculate info distionary. \"\"\"\n \n def check_libs(self,lib_dir,libs,opt_libs =[]):\n \"\"\" If static or shared libraries are available then return\n their info dictionary. \"\"\"\n mths = [self.check_static_libs,self.check_shared_libs]\n if not self.static_first:\n mths.reverse() # if one prefers shared libraries\n for m in mths:\n info = m(lib_dir,libs,opt_libs)\n if info is not None: return info\n\n def check_static_libs(self,lib_dir,libs,opt_libs =[]):\n #XXX: what are .lib and .dll files under win32?\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs])) == len(libs):\n info = {'libraries':libs,'library_dirs':[lib_dir]}\n if len(combine_paths(lib_dir,['lib'+l+'.a' for l in libs]))\\\n ==len(opt_libs):\n info['libraries'].extend(opt_libs)\n return info\n\n def check_shared_libs(self,lib_dir,libs,opt_libs =[]):\n shared_libs = []\n for l in libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: shared_libs.append(p)\n if len(shared_libs) == len(libs):\n info = {'extra_objects':shared_libs}\n opt_shared_libs = []\n for l in opt_libs:\n p = shortest_path(combine_paths(lib_dir,'lib'+l+so_ext+'*'))\n if p is not None: opt_shared_libs.append(p)\n info['extra_objects'].extend(opt_shared_libs)\n return info\n\n\nclass fftw_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('FFTW')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self,prefix): \n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,'lib',['fftw*','FFTW*']))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'lib'))\n if not lib_dirs:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','fftw*','FFTW*']))\n \n if not lib_dirs:\n lib_dirs = [prefix]\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,'include',['fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['fftw*','FFTW*'],'include'))\n if not incl_dirs:\n incl_dirs = filter(os.path.isdir,\n combine_paths(prefix,['include','fftw*','FFTW*']))\n if not incl_dirs:\n incl_dirs = [prefix]\n incl_dir = None\n\n libs = ['fftw','rfftw']\n opt_libs = ['fftw_threads','rfftw_threads']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['fftw.h','rfftw.h']))==2:\n dict_append(info,include_dirs=[d])\n flag = 1\n incl_dirs = [d]\n incl_dir = d\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_FFTW_H',1)])\n else:\n info = None\n\n if info is None:\n libs = ['dfftw','drfftw']\n opt_libs = ['dfftw_threads','drfftw_threads']\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n info = r\n break\n if info is not None:\n flag = 0\n for d in incl_dirs:\n if len(combine_paths(d,['dfftw.h','drfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n incl_dirs = [d]\n incl_dir = d\n flag = 1\n break\n if flag:\n dict_append(info,define_macros=[('SCIPY_DFFTW_H',1)])\n else:\n info = None\n \n libs = ['sfftw','srfftw']\n opt_libs = ['sfftw_threads','srfftw_threads']\n flag = 0\n for d in lib_dirs:\n r = self.check_libs(d,libs,opt_libs)\n if r is not None:\n if info is None: info = r\n else: dict_append(info,**r)\n flag = 1\n break\n if info is not None and flag:\n for d in incl_dirs:\n if len(combine_paths(d,['sfftw.h','srfftw.h']))==2:\n if incl_dir is None:\n dict_append(info,include_dirs=[d])\n dict_append(info,define_macros=[('SCIPY_SFFTW_H',1)])\n break\n if info is not None:\n self.set_info(**info)\n\n\nclass atlas_info(system_info):\n\n def __init__(self):\n system_info.__init__(self)\n p = os.environ.get('ATLAS')\n if p is not None:\n p = os.path.abspath(p)\n if os.path.isdir(p):\n self.local_prefixes.insert(0,p)\n\n def calc_info(self, prefix):\n print combine_paths(prefix,'lib',['atlas*','ATLAS*'])\n lib_dirs = filter(os.path.isdir,combine_paths(prefix,'lib',\n ['atlas*','ATLAS*']))\n if lib_dirs:\n other_dirs = filter(os.path.isdir,combine_paths(lib_dirs,'*'))\n other_dirs.extend(filter(os.path.isdir,combine_paths(prefix,'lib')))\n lib_dirs.extend(other_dirs)\n else:\n lib_dirs = filter(os.path.isdir,\n combine_paths(prefix,['lib','atlas*','ATLAS*']))\n if not lib_dirs:\n lib_dirs = [prefix]\n\n h = (combine_paths(lib_dirs,'cblas.h') or [None])[0]\n if not h:\n h = (combine_paths(lib_dirs,'include','cblas.h') or [None])[0]\n if h: h = os.path.dirname(h)\n\n libs = ['lapack','f77blas','cblas','atlas']\n info = None\n for d in lib_dirs:\n r = self.check_libs(d,libs,[])\n if r is not None:\n info = r\n break\n if info is None: return\n if h: dict_append(info,include_dirs=[h])\n self.set_info(**info)\n\n def calc_info_debian(self,prefix):\n print 'Trying Debian setup'\n atlas = self.check_libs(os.path.join(prefix,'lib'),\n ['cblas','f77blas','atlas'],[])\n if not atlas: return\n lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])\n if not lapack:\n lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])\n if not lapack: return\n info = lapack\n h = (combine_paths(prefix,'include','cblas.h') or [None])[0]\n if h: dict_append(info,include_dirs=[os.path.dirname(h)])\n dict_append(info,**atlas)\n self.set_info(**info)\n \nclass blas_info(system_info):\n # For Fortran or optimized blas, not atlas.\n pass\n\n\nclass lapack_info(system_info):\n # For Fortran or optimized lapack, not atlas\n pass\n\n\nclass x11_info(system_info):\n\n def calc_info(self, prefix):\n if sys.platform == 'win32':\n return\n for x11_dir in combine_paths(prefix,['X11R6','X11']):\n inc_dir = None\n for d in combine_paths(x11_dir,['include','include/X11']):\n if combine_paths(d,'X.h'):\n inc_dir = d\n break\n if not d: return\n lib_dir = combine_paths(x11_dir,'lib')\n if not lib_dir: return\n info = self.check_libs(lib_dir[0],['X11'],[])\n if info is None:\n continue\n dict_append(info,include_dirs=[inc_dir])\n self.set_info(**info)\n\ndef shortest_path(pths):\n pths.sort()\n if pths: return pths[0]\n\ndef combine_paths(*args):\n \"\"\" Return a list of existing paths composed by all combinations of\n items from arguments.\n \"\"\"\n r = []\n for a in args:\n if not a: continue\n if type(a) is types.StringType:\n a = [a]\n r.append(a)\n args = r\n if not args: return []\n if len(args)==1:\n result = reduce(lambda a,b:a+b,map(glob,args[0]),[])\n elif len (args)==2:\n result = []\n for a0 in args[0]:\n for a1 in args[1]:\n result.extend(glob(os.path.join(a0,a1)))\n else:\n result = combine_paths(*(combine_paths(args[0],args[1])+args[2:]))\n return result\n\ndef dict_append(d,**kws):\n for k,v in kws.items():\n if d.has_key(k):\n d[k].extend(v)\n else:\n d[k] = v\n\ndef show_all():\n import system_info\n import pprint\n match_info = re.compile(r'.*?_info').match\n for n in filter(match_info,dir(system_info)):\n if n in ['system_info','get_info']: continue\n c = getattr(system_info,n)()\n r = c.get_info()\n\nif __name__ == \"__main__\":\n show_all()\n", + "methods": [ + { + "name": "get_info", + "long_name": "get_info( name )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "name" + ], + "start_line": 89, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", + "filename": "system_info.py", + "nloc": 17, + "complexity": 2, + "token_count": 148, + "parameters": [ + "self", + "default_lib_dirs", + "default_include_dirs" + ], + "start_line": 136, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "info" + ], + "start_line": 155, + "end_line": 157, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "has_info", + "long_name": "has_info( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 158, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 20, + "complexity": 9, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 160, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "calc_info_template", + "long_name": "calc_info_template( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 184, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_paths", + "long_name": "get_paths( self , section , key )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 3, + "token_count": 66, + "parameters": [ + "self", + "section", + "key" + ], + "start_line": 187, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "get_lib_dirs", + "long_name": "get_lib_dirs( self , key = 'lib_dir' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "key" + ], + "start_line": 193, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_include_dirs", + "long_name": "get_include_dirs( self , key = 'include_dir' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "key" + ], + "start_line": 195, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_libs", + "long_name": "get_libs( self , key , default )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "key", + "default" + ], + "start_line": 198, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 4, + "token_count": 60, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 205, + "end_line": 213, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_static_libs", + "long_name": "check_static_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 5, + "token_count": 91, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 215, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_shared_libs", + "long_name": "check_shared_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 119, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 224, + "end_line": 236, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "self" + ], + "start_line": 242, + "end_line": 243, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 69, + "complexity": 24, + "token_count": 443, + "parameters": [ + "self" + ], + "start_line": 245, + "end_line": 316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 1 + }, + { + "name": "get_paths", + "long_name": "get_paths( self , section , key )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 4, + "token_count": 87, + "parameters": [ + "self", + "section", + "key" + ], + "start_line": 322, + "end_line": 327, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 24, + "complexity": 8, + "token_count": 168, + "parameters": [ + "self" + ], + "start_line": 329, + "end_line": 355, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 27, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 370, + "end_line": 373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 20, + "complexity": 7, + "token_count": 110, + "parameters": [ + "self" + ], + "start_line": 375, + "end_line": 394, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 1 + }, + { + "name": "shortest_path", + "long_name": "shortest_path( pths )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "pths" + ], + "start_line": 396, + "end_line": 398, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args )", + "filename": "system_info.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "args" + ], + "start_line": 400, + "end_line": 421, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 423, + "end_line": 428, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "show_all", + "long_name": "show_all( )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 3, + "token_count": 59, + "parameters": [], + "start_line": 430, + "end_line": 437, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "get_info", + "long_name": "get_info( name )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 1, + "token_count": 39, + "parameters": [ + "name" + ], + "start_line": 52, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 98, + "end_line": 101, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "set_info", + "long_name": "set_info( self , ** info )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "info" + ], + "start_line": 103, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 1 + }, + { + "name": "has_info", + "long_name": "has_info( self )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self" + ], + "start_line": 106, + "end_line": 107, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 14, + "token_count": 165, + "parameters": [ + "self" + ], + "start_line": 108, + "end_line": 137, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 1 + }, + { + "name": "calc_info_template", + "long_name": "calc_info_template( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 139, + "end_line": 140, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "check_libs", + "long_name": "check_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 4, + "token_count": 60, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 142, + "end_line": 150, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 1 + }, + { + "name": "check_static_libs", + "long_name": "check_static_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 5, + "token_count": 91, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 152, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 1 + }, + { + "name": "check_shared_libs", + "long_name": "check_shared_libs( self , lib_dir , libs , opt_libs = [ ] )", + "filename": "system_info.py", + "nloc": 13, + "complexity": 6, + "token_count": 119, + "parameters": [ + "self", + "lib_dir", + "libs", + "opt_libs" + ], + "start_line": 161, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 178, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 84, + "complexity": 30, + "token_count": 561, + "parameters": [ + "self", + "prefix" + ], + "start_line": 186, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 7, + "complexity": 3, + "token_count": 57, + "parameters": [ + "self" + ], + "start_line": 278, + "end_line": 284, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 27, + "complexity": 11, + "token_count": 244, + "parameters": [ + "self", + "prefix" + ], + "start_line": 286, + "end_line": 314, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 1 + }, + { + "name": "calc_info_debian", + "long_name": "calc_info_debian( self , prefix )", + "filename": "system_info.py", + "nloc": 14, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "prefix" + ], + "start_line": 316, + "end_line": 329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 17, + "complexity": 8, + "token_count": 117, + "parameters": [ + "self", + "prefix" + ], + "start_line": 343, + "end_line": 359, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 1 + }, + { + "name": "shortest_path", + "long_name": "shortest_path( pths )", + "filename": "system_info.py", + "nloc": 3, + "complexity": 2, + "token_count": 18, + "parameters": [ + "pths" + ], + "start_line": 361, + "end_line": 363, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "combine_paths", + "long_name": "combine_paths( * args )", + "filename": "system_info.py", + "nloc": 19, + "complexity": 9, + "token_count": 162, + "parameters": [ + "args" + ], + "start_line": 365, + "end_line": 386, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dict_append", + "long_name": "dict_append( d , ** kws )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 44, + "parameters": [ + "d", + "kws" + ], + "start_line": 388, + "end_line": 393, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "show_all", + "long_name": "show_all( )", + "filename": "system_info.py", + "nloc": 8, + "complexity": 3, + "token_count": 59, + "parameters": [], + "start_line": 395, + "end_line": 402, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "get_include_dirs", + "long_name": "get_include_dirs( self , key = 'include_dir' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "key" + ], + "start_line": 195, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_info_debian", + "long_name": "calc_info_debian( self , prefix )", + "filename": "system_info.py", + "nloc": 14, + "complexity": 6, + "token_count": 157, + "parameters": [ + "self", + "prefix" + ], + "start_line": 316, + "end_line": 329, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , default_lib_dirs = default_lib_dirs , default_include_dirs = default_include_dirs , )", + "filename": "system_info.py", + "nloc": 17, + "complexity": 2, + "token_count": 148, + "parameters": [ + "self", + "default_lib_dirs", + "default_include_dirs" + ], + "start_line": 136, + "end_line": 153, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 1 + }, + { + "name": "calc_info_template", + "long_name": "calc_info_template( self , prefix )", + "filename": "system_info.py", + "nloc": 1, + "complexity": 1, + "token_count": 8, + "parameters": [ + "self", + "prefix" + ], + "start_line": 184, + "end_line": 185, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "get_libs", + "long_name": "get_libs( self , key , default )", + "filename": "system_info.py", + "nloc": 6, + "complexity": 3, + "token_count": 49, + "parameters": [ + "self", + "key", + "default" + ], + "start_line": 198, + "end_line": 203, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self )", + "filename": "system_info.py", + "nloc": 4, + "complexity": 1, + "token_count": 19, + "parameters": [ + "self" + ], + "start_line": 370, + "end_line": 373, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "get_info", + "long_name": "get_info( self )", + "filename": "system_info.py", + "nloc": 20, + "complexity": 9, + "token_count": 113, + "parameters": [ + "self" + ], + "start_line": 160, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 23, + "top_nesting_level": 1 + }, + { + "name": "get_lib_dirs", + "long_name": "get_lib_dirs( self , key = 'lib_dir' )", + "filename": "system_info.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "self", + "key" + ], + "start_line": 193, + "end_line": 194, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self , prefix )", + "filename": "system_info.py", + "nloc": 84, + "complexity": 30, + "token_count": 561, + "parameters": [ + "self", + "prefix" + ], + "start_line": 186, + "end_line": 273, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 88, + "top_nesting_level": 1 + }, + { + "name": "get_paths", + "long_name": "get_paths( self , section , key )", + "filename": "system_info.py", + "nloc": 5, + "complexity": 3, + "token_count": 66, + "parameters": [ + "self", + "section", + "key" + ], + "start_line": 187, + "end_line": 191, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "calc_info", + "long_name": "calc_info( self )", + "filename": "system_info.py", + "nloc": 69, + "complexity": 24, + "token_count": 443, + "parameters": [ + "self" + ], + "start_line": 245, + "end_line": 316, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 72, + "top_nesting_level": 1 + } + ], + "nloc": 371, + "complexity": 100, + "token_count": 2183, + "diff_parsed": { + "added": [ + "The file 'site.cfg' in the same directory as this module is read", + "for configuration options. The format is that used by ConfigParser (i.e.,", + "Windows .INI style). The section DEFAULT has options that are the default", + "for each section. The available sections are fftw, atlas, and x11. Appropiate", + "defaults are used if nothing is specified.", + "", + "Example:", + "----------", + "[DEFAULT]", + "lib_dir = /usr/lib:/usr/local/lib:/opt/lib", + "include_dir = /usr/include:/usr/local/include:/opt/include", + "# use static libraries in preference to shared ones", + "static_first = 1", + "", + "[fftw]", + "fftw_libs = fftw, rfftw", + "fftw_opt_libs = fftw_threaded, rfftw_threaded", + "# if the above aren't found, look for {s,d}fftw_libs and {s,d}fftw_opt_libs", + "", + "[atlas]", + "lib_dir = /usr/lib/3dnow:/usr/lib/3dnow/atlas", + "# for overriding the names of the atlas libraries", + "atlas_libs = f77blas, cblas, atlas", + "lapack_libs = lapack", + "", + "[x11]", + "lib_dir = /usr/X11R6/lib", + "include_dir = /usr/X11R6/include", + "----------", + "", + "Authors:", + " David M. Cooke , April 2002", + "import sys,os,re,types", + "import ConfigParser", + " default_lib_dirs = ['C:\\\\'] # probably not very helpful...", + " default_include_dirs = []", + " default_x11_lib_dirs = []", + " default_x11_include_dirs = []", + " default_lib_dirs = ['/usr/local/lib', '/opt/lib', '/usr/lib']", + " default_include_dirs = ['/usr/local/include',", + " '/opt/include', '/usr/include']", + " default_x11_lib_dirs = ['/usr/X11R6/lib','/usr/X11/lib']", + " default_x11_include_dirs = ['/usr/X11R6/include','/usr/X11/include']", + "", + "if os.path.join(sys.prefix, 'lib') not in default_lib_dirs:", + " default_lib_dirs.append(os.path.join(sys.prefix, 'lib'))", + " default_include_dirs.append(os.path.join(sys.prefix, 'include'))", + "default_lib_dirs = filter(os.path.isdir, default_lib_dirs)", + "default_include_dirs = filter(os.path.isdir, default_include_dirs)", + " section = 'DEFAULT'", + "", + " def __init__ (self,", + " default_lib_dirs=default_lib_dirs,", + " default_include_dirs=default_include_dirs,", + " ):", + " defaults = {}", + " defaults['lib_dir'] = ':'.join(default_lib_dirs)", + " defaults['include_dir'] = ':'.join(default_include_dirs)", + " defaults['static_first'] = '1'", + " self.cp = ConfigParser.ConfigParser(defaults)", + " cf = os.path.join(os.path.split(os.path.abspath(__file__))[0],", + " 'site.cfg')", + " self.cp.read([cf])", + " if not self.cp.has_section(self.section):", + " self.cp.add_section(self.section)", + " self.static_first = self.cp.getboolean(self.section, 'static_first')", + " if hasattr(self, 'calc_info'):", + " self.calc_info()", + " \"\"\" Calculate info dictionary. \"\"\"", + "", + " def get_paths(self, section, key):", + " dirs = self.cp.get(section, key).split(':')", + " default_dirs = self.cp.get('DEFAULT', key).split(':')", + " dirs.extend(default_dirs)", + " return [ d for d in dirs if os.path.isdir(d) ]", + "", + " def get_lib_dirs(self, key='lib_dir'):", + " return self.get_paths(self.section, key)", + " def get_include_dirs(self, key='include_dir'):", + " return self.get_paths(self.section, key)", + "", + " def get_libs(self, key, default):", + " try:", + " libs = self.cp.get(self.section, key)", + " except ConfigParser.NoOptionError:", + " return default", + " return [a.strip() for a in libs.split(',')]", + "", + " section = 'fftw'", + "", + " def calc_info(self):", + " lib_dirs = self.get_lib_dirs()", + " incl_dirs = self.get_include_dirs()", + " libs = self.get_libs('fftw_libs', ['fftw','rfftw'])", + " opt_libs = self.get_libs('fftw_opt_libs',", + " ['fftw_threads','rfftw_threads'])", + " libs = self.get_libs('dfftw_libs', ['dfftw', 'drfftw'])", + " opt_libs = self.get_libs('dfftw_opt_libs',", + " ['dfftw_threads', 'drfftw_threads'])", + "", + " libs = self.get_libs('sfftw_libs', ['sfftw', 'srfftw'])", + " opt_libs = self.get_libs('sfftw_opt_libs',", + " ['sfftw_threads', 'srfftw_threads'])", + " section = 'atlas'", + " def get_paths(self, section, key):", + " default_dirs = self.cp.get('DEFAULT', key).split(':')", + " dirs = []", + " for d in self.cp.get(section, key).split(':') + default_dirs:", + " dirs.extend([d]+combine_paths(d,['atlas*','ATLAS*']))", + " return [ d for d in dirs if os.path.isdir(d) ]", + " def calc_info(self):", + " lib_dirs = self.get_lib_dirs()", + " include_dirs = self.get_include_dirs()", + "", + " h = (combine_paths(lib_dirs+include_dirs,'cblas.h') or [None])[0]", + " if h: h = os.path.dirname(h)", + " # lapack must appear before atlas", + " lapack_libs = self.get_libs('lapack_libs', ['lapack'])", + " lapack = self.check_libs(d,lapack_libs,[])", + " if lapack is not None:", + " info = lapack", + " break", + " else:", + " return", + " atlas_libs = self.get_libs('atlas_libs', ['f77blas', 'cblas', 'atlas'])", + " for d in lib_dirs:", + " atlas = self.check_libs(d,atlas_libs,[])", + " if atlas is not None:", + " dict_append(info, **atlas)", + " else:", + " return", + "", + "## class blas_info(system_info):", + "## # For Fortran or optimized blas, not atlas.", + "## pass", + "## class lapack_info(system_info):", + "## # For Fortran or optimized lapack, not atlas", + "## pass", + " section = 'x11'", + "", + " def __init__(self):", + " system_info.__init__(self,", + " default_lib_dirs=default_x11_lib_dirs,", + " default_include_dirs=default_x11_include_dirs)", + " def calc_info(self):", + " lib_dirs = self.get_lib_dirs()", + " include_dirs = self.get_include_dirs()", + " x11_libs = self.get_libs('x11_libs', ['X11'])", + " for lib_dir in lib_dirs:", + " info = self.check_libs(lib_dir, x11_libs, [])", + " if info is not None:", + " break", + " else:", + " return", + " inc_dir = None", + " for d in include_dirs:", + " if combine_paths(d, 'X11/X.h'):", + " inc_dir = d", + " break", + " if inc_dir is not None:", + " dict_append(info, include_dirs=[inc_dir])", + " self.set_info(**info)" + ], + "deleted": [ + "The following environment variables are used if defined:", + " ATLAS - path to ATLAS library", + " FFTW - path to FFTW library", + " prefixes - a list of prefixes for scanning the location of", + " resources.", + "Author:", + "import sys,os,re,types,pprint", + " prefixes = ['C:\\\\'] # XXX: what is prefix in win32?", + " prefixes = ['/usr','/usr/local','/opt']", + "if sys.prefix not in prefixes:", + " prefixes.append(sys.prefix)", + "prefixes = filter(os.path.isdir,prefixes) # XXX: Is this ok on win32? Is 'C:' dir?", + "", + " def __init__ (self):", + " for n in ['calc_info','calc_info_debian']:", + " calc_info = getattr(self,n,None)", + " if calc_info is None: continue", + " for p in self.local_prefixes + prefixes:", + " if self.verbose:", + " print ' Looking in',p,'...'", + " calc_info(p)", + " if self.has_info(): break", + " if self.has_info(): break", + " \"\"\" Calculate info distionary. \"\"\"", + "", + " p = os.environ.get('FFTW')", + " if p is not None:", + " p = os.path.abspath(p)", + " if os.path.isdir(p):", + " self.local_prefixes.insert(0,p)", + "", + " def calc_info(self,prefix):", + " lib_dirs = filter(os.path.isdir,", + " combine_paths(prefix,'lib',['fftw*','FFTW*']))", + " if not lib_dirs:", + " lib_dirs = filter(os.path.isdir,", + " combine_paths(prefix,['fftw*','FFTW*'],'lib'))", + " if not lib_dirs:", + " lib_dirs = filter(os.path.isdir,", + " combine_paths(prefix,['lib','fftw*','FFTW*']))", + "", + " if not lib_dirs:", + " lib_dirs = [prefix]", + " incl_dirs = filter(os.path.isdir,", + " combine_paths(prefix,'include',['fftw*','FFTW*']))", + " if not incl_dirs:", + " incl_dirs = filter(os.path.isdir,", + " combine_paths(prefix,['fftw*','FFTW*'],'include'))", + " if not incl_dirs:", + " incl_dirs = filter(os.path.isdir,", + " combine_paths(prefix,['include','fftw*','FFTW*']))", + " if not incl_dirs:", + " incl_dirs = [prefix]", + " libs = ['fftw','rfftw']", + " opt_libs = ['fftw_threads','rfftw_threads']", + " libs = ['dfftw','drfftw']", + " opt_libs = ['dfftw_threads','drfftw_threads']", + "", + " libs = ['sfftw','srfftw']", + " opt_libs = ['sfftw_threads','srfftw_threads']", + " def __init__(self):", + " system_info.__init__(self)", + " p = os.environ.get('ATLAS')", + " if p is not None:", + " p = os.path.abspath(p)", + " if os.path.isdir(p):", + " self.local_prefixes.insert(0,p)", + "", + " def calc_info(self, prefix):", + " print combine_paths(prefix,'lib',['atlas*','ATLAS*'])", + " lib_dirs = filter(os.path.isdir,combine_paths(prefix,'lib',", + " ['atlas*','ATLAS*']))", + " if lib_dirs:", + " other_dirs = filter(os.path.isdir,combine_paths(lib_dirs,'*'))", + " other_dirs.extend(filter(os.path.isdir,combine_paths(prefix,'lib')))", + " lib_dirs.extend(other_dirs)", + " else:", + " lib_dirs = filter(os.path.isdir,", + " combine_paths(prefix,['lib','atlas*','ATLAS*']))", + " if not lib_dirs:", + " lib_dirs = [prefix]", + "", + " h = (combine_paths(lib_dirs,'cblas.h') or [None])[0]", + " if not h:", + " h = (combine_paths(lib_dirs,'include','cblas.h') or [None])[0]", + " if h: h = os.path.dirname(h)", + " libs = ['lapack','f77blas','cblas','atlas']", + " r = self.check_libs(d,libs,[])", + " if r is not None:", + " info = r", + " if info is None: return", + " def calc_info_debian(self,prefix):", + " print 'Trying Debian setup'", + " atlas = self.check_libs(os.path.join(prefix,'lib'),", + " ['cblas','f77blas','atlas'],[])", + " if not atlas: return", + " lapack = self.check_libs(os.path.join(prefix,'lib','atlas'),['lapack'],[])", + " if not lapack:", + " lapack = self.check_libs(os.path.join(prefix,'lib'),['lapack'],[])", + " if not lapack: return", + " info = lapack", + " h = (combine_paths(prefix,'include','cblas.h') or [None])[0]", + " if h: dict_append(info,include_dirs=[os.path.dirname(h)])", + " dict_append(info,**atlas)", + " self.set_info(**info)", + "", + "class blas_info(system_info):", + " # For Fortran or optimized blas, not atlas.", + " pass", + "class lapack_info(system_info):", + " # For Fortran or optimized lapack, not atlas", + " pass", + " def calc_info(self, prefix):", + " for x11_dir in combine_paths(prefix,['X11R6','X11']):", + " inc_dir = None", + " for d in combine_paths(x11_dir,['include','include/X11']):", + " if combine_paths(d,'X.h'):", + " inc_dir = d", + " break", + " if not d: return", + " lib_dir = combine_paths(x11_dir,'lib')", + " if not lib_dir: return", + " info = self.check_libs(lib_dir[0],['X11'],[])", + " if info is None:", + " continue", + " dict_append(info,include_dirs=[inc_dir])", + " self.set_info(**info)" + ] + } + } + ] + }, + { + "hash": "5dcb2081efa2d04accfe75fca7cbe08fbdf37dad", + "msg": "Finished special functions. (Added orthogonal polynomials).", + "author": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "committer": { + "name": "Travis Oliphant", + "email": "oliphant@enthought.com" + }, + "author_date": "2002-04-02T08:18:44+00:00", + "author_timezone": 0, + "committer_date": "2002-04-02T08:18:44+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "5082215ea3a74cc66a0da9e80094ec503d6ef185" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 8, + "insertions": 12, + "lines": 20, + "files": 3, + "dmm_unit_size": null, + "dmm_unit_complexity": null, + "dmm_unit_interfacing": null, + "modified_files": [ + { + "old_path": "scipy_base/__init__.py", + "new_path": "scipy_base/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -12,6 +12,10 @@\n from Matrix import Matrix as mat\n Mat = mat # deprecated\n \n+# needs fastumath\n+Inf = inf = Numeric.array(1e308)**10\n+NaN = nan = Numeric.array(0.0) / Numeric.array(0.0)\n+\n #---- testing ----#\n \n def test(level=10):\n", + "added_lines": 4, + "deleted_lines": 0, + "source_code": "\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom utility import *\nfrom convenience import *\nfrom polynomial import *\nfrom scimath import *\nfrom helpmod import help, source\nfrom Matrix import Matrix as mat\nMat = mat # deprecated\n\n# needs fastumath\nInf = inf = Numeric.array(1e308)**10\nNaN = nan = Numeric.array(0.0) / Numeric.array(0.0)\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_base.testing\n import scipy_base\n this_mod = scipy_base\n return scipy_base.testing.harvest_test_suites(this_mod,level=level)\n\n\n", + "source_code_before": "\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom utility import *\nfrom convenience import *\nfrom polynomial import *\nfrom scimath import *\nfrom helpmod import help, source\nfrom Matrix import Matrix as mat\nMat = mat # deprecated\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_base.testing\n import scipy_base\n this_mod = scipy_base\n return scipy_base.testing.harvest_test_suites(this_mod,level=level)\n\n\n", + "methods": [ + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "__init__.py", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "level" + ], + "start_line": 21, + "end_line": 25, + "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": 5, + "complexity": 1, + "token_count": 29, + "parameters": [ + "level" + ], + "start_line": 27, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "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": 17, + "end_line": 21, + "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": 5, + "complexity": 1, + "token_count": 29, + "parameters": [ + "level" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 23, + "complexity": 2, + "token_count": 131, + "diff_parsed": { + "added": [ + "# needs fastumath", + "Inf = inf = Numeric.array(1e308)**10", + "NaN = nan = Numeric.array(0.0) / Numeric.array(0.0)", + "" + ], + "deleted": [] + } + }, + { + "old_path": "scipy_base/polynomial.py", + "new_path": "scipy_base/polynomial.py", + "filename": "polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,7 +2,7 @@\n from Numeric import *\n from scimath import *\n from convenience import diag\n-from utility import hstack, r1array, trim_zeros\n+from utility import hstack, r1array, trim_zeros, isscalar\n \n __all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n@@ -72,7 +72,7 @@ def roots(p):\n raise ValueError,\"Input must be a rank-1 array.\"\n \n # find non-zero array entries\n- non_zero = nonzero(ravel(a))\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", + "added_lines": 2, + "deleted_lines": 2, + "source_code": "import Numeric\nfrom Numeric import *\nfrom scimath import *\nfrom convenience import diag\nfrom utility import hstack, r1array, trim_zeros, isscalar\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:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = r1array(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros, vecs = MLab.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 = r1array(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\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 = r1array(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(r1array,(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(r1array,(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 = r1array(signal)\n den = r1array(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 = r1array(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key == '__coerce__':\n raise KeyError\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", + "source_code_before": "import Numeric\nfrom Numeric import *\nfrom scimath import *\nfrom convenience import diag\nfrom utility import hstack, r1array, trim_zeros\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:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = r1array(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros, vecs = MLab.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 = r1array(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(a))\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\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 = r1array(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(r1array,(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(r1array,(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 = r1array(signal)\n den = r1array(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 = r1array(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": 11, + "complexity": 3, + "token_count": 36, + "parameters": [], + "start_line": 10, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 22, + "complexity": 9, + "token_count": 194, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 22, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 61, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "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": 98, + "end_line": 128, + "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": 130, + "end_line": 146, + "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": 148, + "end_line": 161, + "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": 163, + "end_line": 179, + "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": 181, + "end_line": 197, + "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": 200, + "end_line": 207, + "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": 209, + "end_line": 218, + "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": 220, + "end_line": 239, + "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": 243, + "end_line": 267, + "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": 287, + "end_line": 301, + "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": 303, + "end_line": 307, + "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": 309, + "end_line": 312, + "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": 314, + "end_line": 315, + "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": 317, + "end_line": 358, + "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": 361, + "end_line": 362, + "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": 364, + "end_line": 369, + "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": 371, + "end_line": 376, + "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": 378, + "end_line": 383, + "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": 385, + "end_line": 390, + "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": 392, + "end_line": 398, + "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": 400, + "end_line": 405, + "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": 407, + "end_line": 412, + "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": 414, + "end_line": 419, + "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": 421, + "end_line": 426, + "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": 428, + "end_line": 429, + "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": 431, + "end_line": 441, + "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": 443, + "end_line": 449, + "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": 451, + "end_line": 461, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_eigval_func", + "long_name": "get_eigval_func( )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 36, + "parameters": [], + "start_line": 10, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 22, + "complexity": 9, + "token_count": 194, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 22, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 61, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "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": 98, + "end_line": 128, + "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": 130, + "end_line": 146, + "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": 148, + "end_line": 161, + "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": 163, + "end_line": 179, + "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": 181, + "end_line": 197, + "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": 200, + "end_line": 207, + "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": 209, + "end_line": 218, + "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": 220, + "end_line": 239, + "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": 243, + "end_line": 267, + "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": 287, + "end_line": 301, + "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": 303, + "end_line": 307, + "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": 309, + "end_line": 312, + "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": 314, + "end_line": 315, + "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": 317, + "end_line": 358, + "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": 361, + "end_line": 362, + "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": 364, + "end_line": 369, + "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": 371, + "end_line": 376, + "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": 378, + "end_line": 383, + "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": 385, + "end_line": 390, + "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": 392, + "end_line": 398, + "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": 400, + "end_line": 405, + "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": 407, + "end_line": 412, + "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": 414, + "end_line": 419, + "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": 421, + "end_line": 426, + "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": 428, + "end_line": 429, + "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": 431, + "end_line": 441, + "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": 443, + "end_line": 449, + "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": 451, + "end_line": 461, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 61, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + } + ], + "nloc": 368, + "complexity": 119, + "token_count": 2685, + "diff_parsed": { + "added": [ + "from utility import hstack, r1array, trim_zeros, isscalar", + " non_zero = nonzero(ravel(p))" + ], + "deleted": [ + "from utility import hstack, r1array, trim_zeros", + " non_zero = nonzero(ravel(a))" + ] + } + }, + { + "old_path": "scipy_base/scimath.py", + "new_path": "scipy_base/scimath.py", + "filename": "scimath.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -38,23 +38,23 @@ def log10(x):\n x = _tocomplex(x)\n return fastumath.log10(x) \n \n-def logn(n,s):\n- \"\"\" logn(n,s) -- Take log base n of s.\n+def logn(n,x):\n+ \"\"\" Take log base n of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n- return fastumath.log(s)/fastumath.log(n)\n+ return fastumath.log(x)/fastumath.log(n)\n \n-def log2(s):\n- \"\"\" log2(s) -- Take log base 2 of s.\n+def log2(x):\n+ \"\"\" Take log base 2 of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n- return fastumath.log(s)/fastumath.log(2)\n+ return fastumath.log(x)/fastumath.log(2)\n \n \n def power(x, p):\n", + "added_lines": 6, + "deleted_lines": 6, + "source_code": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions whose output is\ndifferent than the input under certain conditions.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']\n\nfrom convenience import any, isreal\nimport fastumath\nimport Numeric\nfrom fastumath import *\ntoextend = fastumath.__dict__.keys()\nfor key in toextend:\n if key not in __all__ and key[0] != '_':\n __all__.append(key)\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,x):\n \"\"\" Take log base n of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(x)/fastumath.log(n)\n\ndef log2(x):\n \"\"\" Take log base 2 of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n\n\n", + "source_code_before": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions whose output is\ndifferent than the input under certain conditions.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']\n\nfrom convenience import any, isreal\nimport fastumath\nimport Numeric\nfrom fastumath import *\ntoextend = fastumath.__dict__.keys()\nfor key in toextend:\n if key not in __all__ and key[0] != '_':\n __all__.append(key)\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,s):\n \"\"\" logn(n,s) -- Take log base n of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(s)/fastumath.log(n)\n\ndef log2(s):\n \"\"\" log2(s) -- Take log base 2 of s.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(s)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n\n\n", + "methods": [ + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 17, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 29, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , x )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "x" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "x" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 60, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 72, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 17, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 29, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , s )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "s" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( s )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "s" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 60, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 72, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "log2", + "long_name": "log2( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "x" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( s )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "s" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , s )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "s" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , x )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "x" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + } + ], + "nloc": 65, + "complexity": 31, + "token_count": 517, + "diff_parsed": { + "added": [ + "def logn(n,x):", + " \"\"\" Take log base n of x.", + " return fastumath.log(x)/fastumath.log(n)", + "def log2(x):", + " \"\"\" Take log base 2 of x.", + " return fastumath.log(x)/fastumath.log(2)" + ], + "deleted": [ + "def logn(n,s):", + " \"\"\" logn(n,s) -- Take log base n of s.", + " return fastumath.log(s)/fastumath.log(n)", + "def log2(s):", + " \"\"\" log2(s) -- Take log base 2 of s.", + " return fastumath.log(s)/fastumath.log(2)" + ] + } + } + ] + }, + { + "hash": "f897e1fc50d41e219b0868b1394dee9b118082d0", + "msg": "major reorg of scipy_base -- initial checkin", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-02T23:13:09+00:00", + "author_timezone": 0, + "committer_date": "2002-04-02T23:13:09+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "5dcb2081efa2d04accfe75fca7cbe08fbdf37dad" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 18, + "insertions": 1394, + "lines": 1412, + "files": 10, + "dmm_unit_size": 0.6789473684210526, + "dmm_unit_complexity": 0.7894736842105263, + "dmm_unit_interfacing": 0.7859649122807018, + "modified_files": [ + { + "old_path": "scipy_base/__init__.py", + "new_path": "scipy_base/__init__.py", + "filename": "__init__.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -4,18 +4,23 @@\n import fastumath\n import limits\n \n-from utility import *\n-from convenience import *\n+#from utility import *\n+#from convenience import *\n+\n+from type_check import *\n+from index_tricks import *\n+from function_base import *\n+from shape_base import *\n+from matrix_base import *\n+\n from polynomial import *\n from scimath import *\n-from helpmod import help, source\n-from Matrix import Matrix as mat\n-Mat = mat # deprecated\n \n # needs fastumath\n Inf = inf = Numeric.array(1e308)**10\n NaN = nan = Numeric.array(0.0) / Numeric.array(0.0)\n \n+\n #---- testing ----#\n \n def test(level=10):\n@@ -28,6 +33,10 @@ def test_suite(level=1):\n import scipy_base.testing\n import scipy_base\n this_mod = scipy_base\n- return scipy_base.testing.harvest_test_suites(this_mod,level=level)\n+ # ieee_754 gets tested in the type_check module.\n+ # testing is the module that actually does all the testing...\n+ ignore = ['ieee_754','testing']\n+ return scipy_base.testing.harvest_test_suites(this_mod,ignore = ignore,\n+ level=level)\n \n \n", + "added_lines": 15, + "deleted_lines": 6, + "source_code": "\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\n#from utility import *\n#from convenience import *\n\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\n# needs fastumath\nInf = inf = Numeric.array(1e308)**10\nNaN = nan = Numeric.array(0.0) / Numeric.array(0.0)\n\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_base.testing\n import scipy_base\n this_mod = scipy_base\n # ieee_754 gets tested in the type_check module.\n # testing is the module that actually does all the testing...\n ignore = ['ieee_754','testing']\n return scipy_base.testing.harvest_test_suites(this_mod,ignore = ignore,\n level=level)\n\n\n", + "source_code_before": "\nimport Numeric\nfrom Numeric import *\nimport fastumath\nimport limits\n\nfrom utility import *\nfrom convenience import *\nfrom polynomial import *\nfrom scimath import *\nfrom helpmod import help, source\nfrom Matrix import Matrix as mat\nMat = mat # deprecated\n\n# needs fastumath\nInf = inf = Numeric.array(1e308)**10\nNaN = nan = Numeric.array(0.0) / Numeric.array(0.0)\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_base.testing\n import scipy_base\n this_mod = scipy_base\n return scipy_base.testing.harvest_test_suites(this_mod,level=level)\n\n\n", + "methods": [ + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "__init__.py", + "nloc": 5, + "complexity": 1, + "token_count": 26, + "parameters": [ + "level" + ], + "start_line": 26, + "end_line": 30, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "__init__.py", + "nloc": 7, + "complexity": 1, + "token_count": 40, + "parameters": [ + "level" + ], + "start_line": 32, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 21, + "end_line": 25, + "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": 5, + "complexity": 1, + "token_count": 29, + "parameters": [ + "level" + ], + "start_line": 27, + "end_line": 31, + "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": "__init__.py", + "nloc": 7, + "complexity": 1, + "token_count": 40, + "parameters": [ + "level" + ], + "start_line": 32, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + } + ], + "nloc": 25, + "complexity": 2, + "token_count": 139, + "diff_parsed": { + "added": [ + "#from utility import *", + "#from convenience import *", + "", + "from type_check import *", + "from index_tricks import *", + "from function_base import *", + "from shape_base import *", + "from matrix_base import *", + "", + "", + " # ieee_754 gets tested in the type_check module.", + " # testing is the module that actually does all the testing...", + " ignore = ['ieee_754','testing']", + " return scipy_base.testing.harvest_test_suites(this_mod,ignore = ignore,", + " level=level)" + ], + "deleted": [ + "from utility import *", + "from convenience import *", + "from helpmod import help, source", + "from Matrix import Matrix as mat", + "Mat = mat # deprecated", + " return scipy_base.testing.harvest_test_suites(this_mod,level=level)" + ] + } + }, + { + "old_path": null, + "new_path": "scipy_base/function_base.py", + "filename": "function_base.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,265 @@\n+import types\n+import Numeric\n+from Numeric import *\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+\n+round = Numeric.around\n+any = Numeric.sometrue\n+all = Numeric.alltrue\n+\n+def 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 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+\n+def 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 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+\n+def 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+\n+def 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+\n+def 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\n+def 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+\n+def 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+\n+def 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+\n+def 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+\n+def 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+\n+def 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+\n+def 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+def 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+\n+def unwrap(p,discont=pi,axis=-1):\n+ \"\"\"unwrap(p,discont=pi,axis=-1)\n+\n+ unwraps radian phase p by changing absolute jumps greater than discont to\n+ 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+\n+#-----------------------------------------------------------------------------\n+# Test Routines\n+#-----------------------------------------------------------------------------\n+\n+def test(level=10):\n+ from scipy_base.testing import module_test\n+ module_test(__name__,__file__,level=level)\n+\n+def test_suite(level=1):\n+ from scipy_base.testing import module_test_suite\n+ return module_test_suite(__name__,__file__,level=level)\n+\n+if __name__ == '__main__':\n+ test()\n\\ No newline at end of file\n", + "added_lines": 265, + "deleted_lines": 0, + "source_code": "import types\nimport Numeric\nfrom Numeric import *\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\nround = Numeric.around\nany = Numeric.sometrue\nall = Numeric.alltrue\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 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 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\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 \"\"\"unwrap(p,discont=pi,axis=-1)\n\n unwraps radian phase p by changing absolute jumps greater than discont to\n 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\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()", + "source_code_before": null, + "methods": [ + { + "name": "logspace", + "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", + "filename": "function_base.py", + "nloc": 8, + "complexity": 2, + "token_count": 88, + "parameters": [ + "start", + "stop", + "num", + "endpoint" + ], + "start_line": 13, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "linspace", + "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", + "filename": "function_base.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "start", + "stop", + "num", + "endpoint", + "retstep" + ], + "start_line": 27, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 44, + "end_line": 49, + "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": 51, + "end_line": 57, + "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": 59, + "end_line": 105, + "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": 108, + "end_line": 116, + "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": 118, + "end_line": 126, + "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": 130, + "end_line": 138, + "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": 140, + "end_line": 148, + "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": 150, + "end_line": 158, + "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": 160, + "end_line": 168, + "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": 170, + "end_line": 182, + "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": 184, + "end_line": 197, + "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": 199, + "end_line": 216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "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": 222, + "end_line": 226, + "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": 218, + "end_line": 229, + "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": 231, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 256, + "end_line": 258, + "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": 260, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "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": 59, + "end_line": 105, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "sort_complex", + "long_name": "sort_complex( a )", + "filename": "function_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 44, + "parameters": [ + "a" + ], + "start_line": 218, + "end_line": 229, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "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": 260, + "end_line": 262, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "function_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 256, + "end_line": 258, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "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": 184, + "end_line": 197, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "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": 130, + "end_line": 138, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 44, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "linspace", + "long_name": "linspace( start , stop , num = 50 , endpoint = 1 , retstep = 0 )", + "filename": "function_base.py", + "nloc": 11, + "complexity": 3, + "token_count": 92, + "parameters": [ + "start", + "stop", + "num", + "endpoint", + "retstep" + ], + "start_line": 27, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "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": 140, + "end_line": 148, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "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": 222, + "end_line": 226, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "prod", + "long_name": "prod( m , axis = - 1 )", + "filename": "function_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 42, + "parameters": [ + "m", + "axis" + ], + "start_line": 150, + "end_line": 158, + "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": 118, + "end_line": 126, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 108, + "end_line": 116, + "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": 160, + "end_line": 168, + "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": 170, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "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": 231, + "end_line": 250, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "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": 199, + "end_line": 216, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "logspace", + "long_name": "logspace( start , stop , num = 50 , endpoint = 1 )", + "filename": "function_base.py", + "nloc": 8, + "complexity": 2, + "token_count": 88, + "parameters": [ + "start", + "stop", + "num", + "endpoint" + ], + "start_line": 13, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "nloc": 161, + "complexity": 46, + "token_count": 1296, + "diff_parsed": { + "added": [ + "import types", + "import Numeric", + "from Numeric import *", + "", + "__all__ = ['round','any','all','logspace','linspace','fix','mod',", + " 'select','trim_zeros','amax','amin','ptp','cumsum',", + " 'prod','cumprod','diff','angle','unwrap','sort_complex']", + "", + "round = Numeric.around", + "any = Numeric.sometrue", + "all = Numeric.alltrue", + "", + "def logspace(start,stop,num=50,endpoint=1):", + " \"\"\" Evenly spaced samples on a logarithmic scale.", + "", + " Return num evenly spaced samples from 10**start to 10**stop. If", + " endpoint=1 then last sample is 10**stop.", + " \"\"\"", + " if endpoint:", + " step = (stop-start)/float((num-1))", + " y = Numeric.arange(0,num) * step + start", + " else:", + " step = (stop-start)/float(num)", + " y = Numeric.arange(0,num) * step + start", + " return Numeric.power(10.0,y)", + "", + "def linspace(start,stop,num=50,endpoint=1,retstep=0):", + " \"\"\" Evenly spaced samples.", + "", + " Return num evenly spaced samples from start to stop. If endpoint=1 then", + " last sample is stop. If retstep is 1 then return the step value used.", + " \"\"\"", + " if endpoint:", + " step = (stop-start)/float((num-1))", + " y = Numeric.arange(0,num) * step + start", + " else:", + " step = (stop-start)/float(num)", + " y = Numeric.arange(0,num) * step + start", + " if retstep:", + " return y, step", + " else:", + " return y", + "", + "def fix(x):", + " \"\"\" Round x to nearest integer towards zero.", + " \"\"\"", + " x = Numeric.asarray(x)", + " y = Numeric.floor(x)", + " return Numeric.where(x<0,y+1,y)", + "", + "def mod(x,y):", + " \"\"\" x - y*floor(x/y)", + "", + " For numeric arrays, x % y has the same sign as x while", + " mod(x,y) has the same sign as y.", + " \"\"\"", + " return x - y*Numeric.floor(x*1.0/y)", + "", + "def select(condlist, choicelist, default=0):", + " \"\"\" Returns an array comprised from different elements of choicelist", + " depending on the list of conditions.", + "", + " condlist is a list of condition arrays containing ones or zeros", + "", + " choicelist is a list of choice matrices (of the \"same\" size as the", + " arrays in condlist). The result array has the \"same\" size as the", + " arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist", + " must be of length N. The elements of the choicelist can then be", + " represented as [v0,...,vN-1]. The default choice if none of the", + " conditions are met is given as the default argument.", + "", + " The conditions are tested in order and the first one statisfied is", + " used to select the choice. In other words, the elements of the", + " output array are found from the following tree (notice the order of", + " the conditions matters):", + "", + " if c0: v0", + " elif c1: v1", + " elif c2: v2", + " ...", + " elif cN-1: vN-1", + " else: default", + "", + " Note, that one of the condition arrays must be large enough to handle", + " the largest array in the choice list.", + " \"\"\"", + " n = len(condlist)", + " n2 = len(choicelist)", + " if n2 != n:", + " raise ValueError, \"List of cases, must be same length as the list of conditions.\"", + " choicelist.insert(0,default)", + " S = 0", + " pfac = 1", + " for k in range(1,n+1):", + " S += k * pfac * asarray(condlist[k-1])", + " if k < n:", + " pfac *= (1-asarray(condlist[k-1]))", + " # handle special case of a 1-element condition but", + " # a multi-element choice", + " if type(S) in ScalarType or max(asarray(S).shape)==1:", + " pfac = asarray(1)", + " for k in range(n2+1):", + " pfac = pfac + asarray(choicelist[k])", + " S = S*ones(asarray(pfac).shape)", + " return choose(S, tuple(choicelist))", + "", + "# Basic operations", + "def amax(m,axis=-1):", + " \"\"\"Returns the maximum of m along dimension axis.", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return maximum.reduce(m,axis)", + "", + "def amin(m,axis=-1):", + " \"\"\"Returns the minimum of m along dimension axis.", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return minimum.reduce(m,axis)", + "", + "# Actually from Basis, but it fits in so naturally here...", + "", + "def ptp(m,axis=-1):", + " \"\"\"Returns the maximum - minimum along the the given dimension", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return amax(m,axis)-amin(m,axis)", + "", + "def cumsum(m,axis=-1):", + " \"\"\"Returns the cumulative sum of the elements along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return add.accumulate(m,axis)", + "", + "def prod(m,axis=-1):", + " \"\"\"Returns the product of the elements along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return multiply.reduce(m,axis)", + "", + "def cumprod(m,axis=-1):", + " \"\"\"Returns the cumulative product of the elments along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return multiply.accumulate(m,axis)", + "", + "def diff(x, n=1,axis=-1):", + " \"\"\"Calculates the nth order, discrete difference along given axis.", + " \"\"\"", + " x = asarray(x)", + " nd = len(x.shape)", + " slice1 = [slice(None)]*nd", + " slice2 = [slice(None)]*nd", + " slice1[axis] = slice(1,None)", + " slice2[axis] = slice(None,-1)", + " if n > 1:", + " return diff(x[slice1]-x[slice2], n-1, axis=axis)", + " else:", + " return x[slice1]-x[slice2]", + "", + "def angle(z,deg=0):", + " \"\"\"Return the angle of complex argument z.\"\"\"", + " if deg:", + " fact = 180/pi", + " else:", + " fact = 1.0", + " z = asarray(z)", + " if z.typecode() in ['D','F']:", + " zimag = z.imag", + " zreal = z.real", + " else:", + " zimag = 0", + " zreal = z", + " return arctan2(zimag,zreal) * fact", + "", + "def unwrap(p,discont=pi,axis=-1):", + " \"\"\"unwrap(p,discont=pi,axis=-1)", + "", + " unwraps radian phase p by changing absolute jumps greater than discont to", + " their 2*pi complement along the given axis.", + " \"\"\"", + " p = asarray(p)", + " nd = len(p.shape)", + " dd = diff(p,axis=axis)", + " slice1 = [slice(None,None)]*nd # full slices", + " slice1[axis] = slice(1,None)", + " ddmod = mod(dd+pi,2*pi)-pi", + " putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)", + " ph_correct = ddmod - dd;", + " putmask(ph_correct,abs(dd)>> import scipy", + " >>> a = array((0,0,0,1,2,3,2,1,0))", + " >>> scipy.trim_zeros(a)", + " array([1, 2, 3, 2, 1])", + " \"\"\"", + " first = 0", + " if 'f' in trim or 'F' in trim:", + " for i in filt:", + " if i != 0.: break", + " else: first = first + 1", + " last = len(filt)", + " if 'b' in trim or 'B' in trim:", + " for i in filt[::-1]:", + " if i != 0.: break", + " else: last = last - 1", + " return filt[first:last]", + "", + "#-----------------------------------------------------------------------------", + "# Test Routines", + "#-----------------------------------------------------------------------------", + "", + "def test(level=10):", + " from scipy_base.testing import module_test", + " module_test(__name__,__file__,level=level)", + "", + "def test_suite(level=1):", + " from scipy_base.testing import module_test_suite", + " return module_test_suite(__name__,__file__,level=level)", + "", + "if __name__ == '__main__':", + " test()" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy_base/ieee_754.py", + "filename": "ieee_754.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,74 @@\n+\"\"\"Module ieee: exports a few useful IEEE-754 constants and functions.\n+\n+PINF positive infinity\n+MINF minus infinity\n+NAN a generic quiet NaN\n+PZERO positive zero\n+MZERO minus zero\n+\n+isnan(x)\n+ Return true iff x is a NaN.\n+\"\"\"\n+\n+def _make_inf():\n+ x = 2.0\n+ x2 = x * x\n+ i = 0\n+ while i < 100 and x != x2:\n+ x = x2\n+ x2 = x * x\n+ i = i + 1\n+ if x != x2:\n+ raise ValueError(\"This machine's floats go on forever!\")\n+ return x\n+\n+# NaN-testing.\n+#\n+# The usual method (x != x) doesn't work.\n+# Python forces all comparisons thru a 3-outcome cmp protocol; unordered\n+# isn't a possible outcome. The float cmp outcome is essentially defined\n+# by this C expression (combining some cross-module implementation\n+# details, and where px and py are pointers to C double):\n+# px == py ? 0 : *px < *py ? -1 : *px > *py ? 1 : 0\n+# Comparing x to itself thus always yields 0 by the first clause, and so x\n+# != x is never true. If px and py point to distinct NaN objects, a\n+# strange thing happens: 1. On scrupulous 754 implementations, *px < *py\n+# returns false, and so\n+# does *px > *py. Python therefore returns 0, i.e. \"equal\"!\n+# 2. On Pentium HW, an unordered outcome sets an otherwise-impossible\n+# combination of condition codes, including both the \"less than\" and\n+# \"equal to\" flags. Microsoft C generates naive code that accepts the\n+# \"less than\" flag at face value, and so the *px < *py clause returns\n+# true, and Python returns -1, i.e. \"not equal\".\n+# So with a proper C 754 implementation Python returns the wrong result,\n+# and under MS's improper 754 implementation Python yields the right\n+# result -- both by accident. It's unclear who should be shot .\n+#\n+# Anyway, the point of all that was to convince you it's tricky getting\n+# the right answer in a portable way!\n+\n+def isnan(x):\n+ \"\"\"x -> true iff x is a NaN.\"\"\"\n+ # multiply by 1.0 to create a distinct object (x < x *always*\n+ # false in Python, due to object identity forcing equality)\n+ if x * 1.0 < x:\n+ # it's a NaN and this is MS C on a Pentium\n+ return 1\n+ # Else it's non-NaN, or NaN on a non-MS+Pentium combo.\n+ # If it's non-NaN, then x == 1.0 and x == 2.0 can't both be true, \n+ # so we return false. If it is NaN, then assuming a good 754 C \n+ # implementation Python maps both unordered outcomes to true. \n+ return 1.0 == x == 2.0\n+\n+PINF = _make_inf()\n+MINF = -PINF\n+\n+NAN = PINF - PINF\n+if not isnan(NAN):\n+ raise ValueError(\"This machine doesn't have NaNs, \"\n+ \"'overflows' to a finite number, \"\n+ \"suffers a novel way of implementing C comparisons, \"\n+ \"or is 754-conformant but is using \" \n+ \"a goofy rounding mode.\")\n+PZERO = 0.0\n+MZERO = -PZERO\n\\ No newline at end of file\n", + "added_lines": 74, + "deleted_lines": 0, + "source_code": "\"\"\"Module ieee: exports a few useful IEEE-754 constants and functions.\n\nPINF positive infinity\nMINF minus infinity\nNAN a generic quiet NaN\nPZERO positive zero\nMZERO minus zero\n\nisnan(x)\n Return true iff x is a NaN.\n\"\"\"\n\ndef _make_inf():\n x = 2.0\n x2 = x * x\n i = 0\n while i < 100 and x != x2:\n x = x2\n x2 = x * x\n i = i + 1\n if x != x2:\n raise ValueError(\"This machine's floats go on forever!\")\n return x\n\n# NaN-testing.\n#\n# The usual method (x != x) doesn't work.\n# Python forces all comparisons thru a 3-outcome cmp protocol; unordered\n# isn't a possible outcome. The float cmp outcome is essentially defined\n# by this C expression (combining some cross-module implementation\n# details, and where px and py are pointers to C double):\n# px == py ? 0 : *px < *py ? -1 : *px > *py ? 1 : 0\n# Comparing x to itself thus always yields 0 by the first clause, and so x\n# != x is never true. If px and py point to distinct NaN objects, a\n# strange thing happens: 1. On scrupulous 754 implementations, *px < *py\n# returns false, and so\n# does *px > *py. Python therefore returns 0, i.e. \"equal\"!\n# 2. On Pentium HW, an unordered outcome sets an otherwise-impossible\n# combination of condition codes, including both the \"less than\" and\n# \"equal to\" flags. Microsoft C generates naive code that accepts the\n# \"less than\" flag at face value, and so the *px < *py clause returns\n# true, and Python returns -1, i.e. \"not equal\".\n# So with a proper C 754 implementation Python returns the wrong result,\n# and under MS's improper 754 implementation Python yields the right\n# result -- both by accident. It's unclear who should be shot .\n#\n# Anyway, the point of all that was to convince you it's tricky getting\n# the right answer in a portable way!\n\ndef isnan(x):\n \"\"\"x -> true iff x is a NaN.\"\"\"\n # multiply by 1.0 to create a distinct object (x < x *always*\n # false in Python, due to object identity forcing equality)\n if x * 1.0 < x:\n # it's a NaN and this is MS C on a Pentium\n return 1\n # Else it's non-NaN, or NaN on a non-MS+Pentium combo.\n # If it's non-NaN, then x == 1.0 and x == 2.0 can't both be true, \n # so we return false. If it is NaN, then assuming a good 754 C \n # implementation Python maps both unordered outcomes to true. \n return 1.0 == x == 2.0\n\nPINF = _make_inf()\nMINF = -PINF\n\nNAN = PINF - PINF\nif not isnan(NAN):\n raise ValueError(\"This machine doesn't have NaNs, \"\n \"'overflows' to a finite number, \"\n \"suffers a novel way of implementing C comparisons, \"\n \"or is 754-conformant but is using \" \n \"a goofy rounding mode.\")\nPZERO = 0.0\nMZERO = -PZERO", + "source_code_before": null, + "methods": [ + { + "name": "_make_inf", + "long_name": "_make_inf( )", + "filename": "ieee_754.py", + "nloc": 11, + "complexity": 4, + "token_count": 51, + "parameters": [], + "start_line": 13, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isnan", + "long_name": "isnan( x )", + "filename": "ieee_754.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 50, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "_make_inf", + "long_name": "_make_inf( )", + "filename": "ieee_754.py", + "nloc": 11, + "complexity": 4, + "token_count": 51, + "parameters": [], + "start_line": 13, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isnan", + "long_name": "isnan( x )", + "filename": "ieee_754.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 50, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + } + ], + "nloc": 37, + "complexity": 6, + "token_count": 120, + "diff_parsed": { + "added": [ + "\"\"\"Module ieee: exports a few useful IEEE-754 constants and functions.", + "", + "PINF positive infinity", + "MINF minus infinity", + "NAN a generic quiet NaN", + "PZERO positive zero", + "MZERO minus zero", + "", + "isnan(x)", + " Return true iff x is a NaN.", + "\"\"\"", + "", + "def _make_inf():", + " x = 2.0", + " x2 = x * x", + " i = 0", + " while i < 100 and x != x2:", + " x = x2", + " x2 = x * x", + " i = i + 1", + " if x != x2:", + " raise ValueError(\"This machine's floats go on forever!\")", + " return x", + "", + "# NaN-testing.", + "#", + "# The usual method (x != x) doesn't work.", + "# Python forces all comparisons thru a 3-outcome cmp protocol; unordered", + "# isn't a possible outcome. The float cmp outcome is essentially defined", + "# by this C expression (combining some cross-module implementation", + "# details, and where px and py are pointers to C double):", + "# px == py ? 0 : *px < *py ? -1 : *px > *py ? 1 : 0", + "# Comparing x to itself thus always yields 0 by the first clause, and so x", + "# != x is never true. If px and py point to distinct NaN objects, a", + "# strange thing happens: 1. On scrupulous 754 implementations, *px < *py", + "# returns false, and so", + "# does *px > *py. Python therefore returns 0, i.e. \"equal\"!", + "# 2. On Pentium HW, an unordered outcome sets an otherwise-impossible", + "# combination of condition codes, including both the \"less than\" and", + "# \"equal to\" flags. Microsoft C generates naive code that accepts the", + "# \"less than\" flag at face value, and so the *px < *py clause returns", + "# true, and Python returns -1, i.e. \"not equal\".", + "# So with a proper C 754 implementation Python returns the wrong result,", + "# and under MS's improper 754 implementation Python yields the right", + "# result -- both by accident. It's unclear who should be shot .", + "#", + "# Anyway, the point of all that was to convince you it's tricky getting", + "# the right answer in a portable way!", + "", + "def isnan(x):", + " \"\"\"x -> true iff x is a NaN.\"\"\"", + " # multiply by 1.0 to create a distinct object (x < x *always*", + " # false in Python, due to object identity forcing equality)", + " if x * 1.0 < x:", + " # it's a NaN and this is MS C on a Pentium", + " return 1", + " # Else it's non-NaN, or NaN on a non-MS+Pentium combo.", + " # If it's non-NaN, then x == 1.0 and x == 2.0 can't both be true,", + " # so we return false. If it is NaN, then assuming a good 754 C", + " # implementation Python maps both unordered outcomes to true.", + " return 1.0 == x == 2.0", + "", + "PINF = _make_inf()", + "MINF = -PINF", + "", + "NAN = PINF - PINF", + "if not isnan(NAN):", + " raise ValueError(\"This machine doesn't have NaNs, \"", + " \"'overflows' to a finite number, \"", + " \"suffers a novel way of implementing C comparisons, \"", + " \"or is 754-conformant but is using \"", + " \"a goofy rounding mode.\")", + "PZERO = 0.0", + "MZERO = -PZERO" + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy_base/index_tricks.py", + "filename": "index_tricks.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,177 @@\n+import types\n+import Numeric\n+\n+__all__ = ['mgrid','r_','c_','index_exp']\n+\n+from type_check import ScalarType\n+\n+class 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 complex\n+ number, then the stop is not inclusive.\n+ \n+ However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n+ part of it's magnitude is interpreted as specifying the number of points to\n+ create between the start and stop values, where the stop value\n+ IS INCLUSIVE.\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+ 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+ 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+\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+\n+mgrid = nd_grid()\n+\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 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 = linspace(start, stop, num=size, 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+\n+r_=concatenator(0)\n+c_=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+\n+class _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+\n+index_exp = _index_expression_class()\n+\n+# End contribution from Konrad.\n", + "added_lines": 177, + "deleted_lines": 0, + "source_code": "import types\nimport Numeric\n\n__all__ = ['mgrid','r_','c_','index_exp']\n\nfrom type_check import ScalarType\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 complex\n number, then the stop is not inclusive.\n \n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n part of it's magnitude is interpreted as specifying the number of points to\n create between the start and stop values, where the stop value\n IS INCLUSIVE.\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 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 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\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()\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 = linspace(start, stop, num=size, 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", + "source_code_before": null, + "methods": [ + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "index_tricks.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 38, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "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": 81, + "end_line": 82, + "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": 84, + "end_line": 85, + "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": 92, + "end_line": 93, + "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": 31, + "complexity": 11, + "token_count": 253, + "parameters": [ + "self", + "key" + ], + "start_line": 94, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "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": 126, + "end_line": 127, + "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": 129, + "end_line": 130, + "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": 161, + "end_line": 165, + "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": 167, + "end_line": 168, + "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": 170, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "index_tricks.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 84, + "end_line": 85, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "index_tricks.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 92, + "end_line": 93, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "index_tricks.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 81, + "end_line": 82, + "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": 170, + "end_line": 173, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "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": 161, + "end_line": 165, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "index_tricks.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 38, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + } + ], + "nloc": 138, + "complexity": 35, + "token_count": 820, + "diff_parsed": { + "added": [ + "import types", + "import Numeric", + "", + "__all__ = ['mgrid','r_','c_','index_exp']", + "", + "from type_check import ScalarType", + "", + "class nd_grid:", + " \"\"\" Construct a \"meshgrid\" in N-dimensions.", + "", + " grid = nd_grid() creates an instance which will return a mesh-grid", + " when indexed. The dimension and number of the output arrays are equal", + " to the number of indexing dimensions. If the step length is not a complex", + " number, then the stop is not inclusive.", + "", + " However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer", + " part of it's magnitude is interpreted as specifying the number of points to", + " create between the start and stop values, where the stop value", + " IS INCLUSIVE.", + "", + " Example:", + "", + " >>> mgrid = nd_grid()", + " >>> mgrid[0:5,0:5]", + " array([[[0, 0, 0, 0, 0],", + " [1, 1, 1, 1, 1],", + " [2, 2, 2, 2, 2],", + " [3, 3, 3, 3, 3],", + " [4, 4, 4, 4, 4]],", + " [[0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4]]])", + " >>> mgrid[-1:1:5j]", + " array([-1. , -0.5, 0. , 0.5, 1. ])", + " \"\"\"", + " def __getitem__(self,key):", + " try:", + "\t size = []", + " typecode = Numeric.Int", + "\t for k in range(len(key)):", + "\t step = key[k].step", + " start = key[k].start", + " if start is None: start = 0", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " size.append(int(abs(step)))", + " typecode = Numeric.Float", + " else:", + " size.append(int((key[k].stop - start)/(step*1.0)))", + " if isinstance(step,types.FloatType) or \\", + " isinstance(start, types.FloatType) or \\", + " isinstance(key[k].stop, types.FloatType):", + " typecode = Numeric.Float", + " nn = Numeric.indices(size,typecode)", + "\t for k in range(len(size)):", + " step = key[k].step", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " step = int(abs(step))", + " step = (key[k].stop - key[k].start)/float(step-1)", + " nn[k] = (nn[k]*step+key[k].start)", + "\t return nn", + " except (IndexError, TypeError):", + " step = key.step", + " stop = key.stop", + " start = key.start", + " if start is None: start = 0", + " if type(step) is type(1j):", + " step = abs(step)", + " length = int(step)", + " step = (key.stop-start)/float(step-1)", + " stop = key.stop+step", + " return Numeric.arange(0,length,1,Numeric.Float)*step + start", + " else:", + " return Numeric.arange(start, stop, step)", + "", + " def __getslice__(self,i,j):", + " return Numeric.arange(i,j)", + "", + " def __len__(self):", + " return 0", + "", + "mgrid = nd_grid()", + "", + "class concatenator:", + " \"\"\" Translates slice objects to concatenation along an axis.", + " \"\"\"", + " def __init__(self, axis=0):", + " self.axis = axis", + " def __getitem__(self,key):", + " if type(key) is not types.TupleType:", + " key = (key,)", + " objs = []", + " for k in range(len(key)):", + " if type(key[k]) is types.SliceType:", + " typecode = Numeric.Int", + "\t step = key[k].step", + " start = key[k].start", + " stop = key[k].stop", + " if start is None: start = 0", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " size = int(abs(step))", + " typecode = Numeric.Float", + " endpoint = 1", + " else:", + " size = int((stop - start)/(step*1.0))", + " endpoint = 0", + " if isinstance(step,types.FloatType) or \\", + " isinstance(start, types.FloatType) or \\", + " isinstance(stop, types.FloatType):", + " typecode = Numeric.Float", + " newobj = linspace(start, stop, num=size, endpoint=endpoint)", + " elif type(key[k]) in ScalarType:", + " newobj = Numeric.asarray([key[k]])", + " else:", + " newobj = key[k]", + " objs.append(newobj)", + " return Numeric.concatenate(tuple(objs),axis=self.axis)", + "", + " def __getslice__(self,i,j):", + " return Numeric.arange(i,j)", + "", + " def __len__(self):", + " return 0", + "", + "r_=concatenator(0)", + "c_=concatenator(-1)", + "", + "# A nicer way to build up index tuples for arrays.", + "#", + "# You can do all this with slice() plus a few special objects,", + "# but there's a lot to remember. This version is simpler because", + "# it uses the standard array indexing syntax.", + "#", + "# Written by Konrad Hinsen ", + "# last revision: 1999-7-23", + "#", + "# Cosmetic changes by T. Oliphant 2001", + "#", + "#", + "# This module provides a convenient method for constructing", + "# array indices algorithmically. It provides one importable object,", + "# 'index_expression'.", + "#", + "# For any index combination, including slicing and axis insertion,", + "# 'a[indices]' is the same as 'a[index_expression[indices]]' for any", + "# array 'a'. However, 'index_expression[indices]' can be used anywhere", + "# in Python code and returns a tuple of slice objects that can be", + "# used in the construction of complex index expressions.", + "", + "class _index_expression_class:", + " import sys", + " maxint = sys.maxint", + "", + " def __getitem__(self, item):", + " if type(item) != type(()):", + " return (item,)", + " else:", + " return item", + "", + " def __len__(self):", + " return self.maxint", + "", + " def __getslice__(self, start, stop):", + " if stop == self.maxint:", + " stop = None", + " return self[start:stop:None]", + "", + "index_exp = _index_expression_class()", + "", + "# End contribution from Konrad." + ], + "deleted": [] + } + }, + { + "old_path": null, + "new_path": "scipy_base/matrix_base.py", + "filename": "matrix_base.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,205 @@\n+\"\"\" Basic functions for manipulating 2d arrays\n+\n+\"\"\"\n+\n+__all__ = ['diag','eye','fliplr','flipud','hankel','rot90','tri',\n+ 'tril','triu','toeplitz','all_mat']\n+ \n+# These are from Numeric\n+import Matrix\n+from Numeric import *\n+from fastumath import *\n+from type_check import isscalar\n+from index_tricks import mgrid,r_,c_\n+# Elementary Matrices\n+\n+# zeros is from matrixmodule in C\n+# ones is from Numeric.py\n+\n+ \n+def 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+\n+def 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+\n+def 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+\n+def tri(N, M=None, k=0, typecode=None):\n+ \"\"\" returns a N-by-M matrix where all the diagonals starting from \n+ lower left corner up to the k-th are all ones.\n+ \"\"\"\n+ if M is None: M = N\n+ if type(M) == type('d'): \n+ typecode = M\n+ M = N\n+ m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n+ if typecode is None:\n+ return m\n+ else:\n+ return m.astype(typecode)\n+ \n+def eye(N, M=None, k=0, typecode=None):\n+ \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n+ and everything else is zeros.\n+ \"\"\"\n+ if M is None: M = N\n+ if type(M) == type('d'): \n+ typecode = M\n+ M = N\n+ m = equal(subtract.outer(arange(N), arange(M)),-k)\n+ if typecode is None:\n+ return m\n+ else:\n+ return m.astype(typecode)\n+\n+def 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+# move all these\n+#-----------------------------------------------------------------------------\n+\n+def tril(m, k=0):\n+ \"\"\" returns the elements on and below the k-th diagonal of m. k=0 is the\n+ main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n+ \"\"\"\n+ svsp = m.spacesaver()\n+ m = asarray(m,savespace=1)\n+ out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n+ out.savespace(svsp)\n+ return out\n+\n+def triu(m, k=0):\n+ \"\"\" returns the elements on and above the k-th diagonal of m. k=0 is the\n+ main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n+ \"\"\"\n+ svsp = m.spacesaver()\n+ m = asarray(m,savespace=1)\n+ out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n+ out.savespace(svsp)\n+ return out\n+\n+def toeplitz(c,r=None):\n+ \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).\n+\n+ Description:\n+\n+ toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first\n+ column and r as its first row.\n+\n+ toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). \n+\n+ See also: hankel\n+ \"\"\"\n+ if isscalar(c) or isscalar(r):\n+ return c \n+ if r is None:\n+ r = c\n+ r[0] = conjugate(r[0])\n+ c = conjugate(c)\n+ r,c = map(asarray,(r,c))\n+ r,c = map(ravel,(r,c))\n+ rN,cN = map(len,(r,c))\n+ if r[0] != c[0]:\n+ print \"Warning: column and row values don't agree; column value used.\"\n+ vals = r_[r[rN-1:0:-1], c]\n+ cols = mgrid[0:cN]\n+ rows = mgrid[rN:0:-1]\n+ indx = cols[:,NewAxis]*ones((1,rN)) + \\\n+ rows[NewAxis,:]*ones((cN,1)) - 1\n+ return take(vals, indx)\n+\n+\n+def hankel(c,r=None):\n+ \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).\n+\n+ Description:\n+\n+ hankel(c,r) is a Hankel matrix whose first column is c and whose\n+ last row is r.\n+\n+ hankel(c) is a square Hankel matrix whose first column is C.\n+ Elements below the first anti-diagonal are zero.\n+\n+ See also: toeplitz\n+ \"\"\"\n+ if isscalar(c) or isscalar(r):\n+ return c \n+ if r is None:\n+ r = zeros(len(c))\n+ elif r[0] != c[-1]:\n+ print \"Warning: column and row values don't agree; column value used.\"\n+ r,c = map(asarray,(r,c))\n+ r,c = map(ravel,(r,c))\n+ rN,cN = map(len,(r,c))\n+ vals = r_[c, r[1:rN]]\n+ cols = mgrid[1:cN+1]\n+ rows = mgrid[0:rN]\n+ indx = cols[:,NewAxis]*ones((1,rN)) + \\\n+ rows[NewAxis,:]*ones((cN,1)) - 1\n+ return take(vals, indx)\n+\n+def all_mat(args):\n+ return map(Matrix.Matrix,args)\n+\n+#-----------------------------------------------------------------------------\n+# Test Routines\n+#-----------------------------------------------------------------------------\n+\n+def test(level=10):\n+ from scipy_base.testing import module_test\n+ module_test(__name__,__file__,level=level)\n+\n+def test_suite(level=1):\n+ from scipy_base.testing import module_test_suite\n+ return module_test_suite(__name__,__file__,level=level)\n+\n+if __name__ == '__main__':\n+ print 'float epsilon:',float_epsilon\n+ print 'float tiny:',float_tiny\n+ print 'double epsilon:',double_epsilon\n+ print 'double tiny:',double_tiny\n", + "added_lines": 205, + "deleted_lines": 0, + "source_code": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','hankel','rot90','tri',\n 'tril','triu','toeplitz','all_mat']\n \n# These are from Numeric\nimport Matrix\nfrom Numeric import *\nfrom fastumath import *\nfrom type_check import isscalar\nfrom index_tricks import mgrid,r_,c_\n# Elementary Matrices\n\n# zeros is from matrixmodule in C\n# ones is from Numeric.py\n\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 tri(N, M=None, k=0, typecode=None):\n \"\"\" returns a N-by-M matrix where all the diagonals starting from \n lower left corner up to the k-th are all ones.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = greater_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 eye(N, M=None, k=0, typecode=None):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n and everything else is zeros.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n\ndef diag(v, k=0):\n \"\"\" returns the k-th diagonal if v is a matrix or returns a matrix \n with v as the k-th diagonal if v is a vector.\n \"\"\"\n v = asarray(v)\n s = v.shape\n if len(s)==1:\n n = s[0]+abs(k)\n if k > 0:\n v = concatenate((zeros(k, v.typecode()),v))\n elif k < 0:\n v = concatenate((v,zeros(-k, v.typecode())))\n return eye(n, k=k)*v\n elif len(s)==2:\n v = add.reduce(eye(s[0], s[1], k=k)*v)\n if k > 0: return v[k:]\n elif k < 0: return v[:k]\n else: return v\n else:\n raise ValueError, \"Input must be 1- or 2-D.\"\n\n#-----------------------------------------------------------------------------\n# move all these\n#-----------------------------------------------------------------------------\n\ndef tril(m, k=0):\n \"\"\" returns the elements on and below the k-th diagonal of m. k=0 is the\n main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n out.savespace(svsp)\n return out\n\ndef triu(m, k=0):\n \"\"\" returns the elements on and above the k-th diagonal of m. k=0 is the\n main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n out.savespace(svsp)\n return out\n\ndef toeplitz(c,r=None):\n \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).\n\n Description:\n\n toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first\n column and r as its first row.\n\n toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). \n\n See also: hankel\n \"\"\"\n if isscalar(c) or isscalar(r):\n return c \n if r is None:\n r = c\n r[0] = conjugate(r[0])\n c = conjugate(c)\n r,c = map(asarray,(r,c))\n r,c = map(ravel,(r,c))\n rN,cN = map(len,(r,c))\n if r[0] != c[0]:\n print \"Warning: column and row values don't agree; column value used.\"\n vals = r_[r[rN-1:0:-1], c]\n cols = mgrid[0:cN]\n rows = mgrid[rN:0:-1]\n indx = cols[:,NewAxis]*ones((1,rN)) + \\\n rows[NewAxis,:]*ones((cN,1)) - 1\n return take(vals, indx)\n\n\ndef hankel(c,r=None):\n \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).\n\n Description:\n\n hankel(c,r) is a Hankel matrix whose first column is c and whose\n last row is r.\n\n hankel(c) is a square Hankel matrix whose first column is C.\n Elements below the first anti-diagonal are zero.\n\n See also: toeplitz\n \"\"\"\n if isscalar(c) or isscalar(r):\n return c \n if r is None:\n r = zeros(len(c))\n elif r[0] != c[-1]:\n print \"Warning: column and row values don't agree; column value used.\"\n r,c = map(asarray,(r,c))\n r,c = map(ravel,(r,c))\n rN,cN = map(len,(r,c))\n vals = r_[c, r[1:rN]]\n cols = mgrid[1:cN+1]\n rows = mgrid[0:rN]\n indx = cols[:,NewAxis]*ones((1,rN)) + \\\n rows[NewAxis,:]*ones((cN,1)) - 1\n return take(vals, indx)\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": null, + "methods": [ + { + "name": "fliplr", + "long_name": "fliplr( m )", + "filename": "matrix_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "m" + ], + "start_line": 20, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "flipud", + "long_name": "flipud( m )", + "filename": "matrix_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 33, + "parameters": [ + "m" + ], + "start_line": 29, + "end_line": 36, + "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": 40, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "tri", + "long_name": "tri( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 53, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "eye", + "long_name": "eye( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 67, + "end_line": 79, + "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": 81, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "tril", + "long_name": "tril( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 67, + "parameters": [ + "m", + "k" + ], + "start_line": 106, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "triu", + "long_name": "triu( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 69, + "parameters": [ + "m", + "k" + ], + "start_line": 116, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "toeplitz", + "long_name": "toeplitz( c , r = None )", + "filename": "matrix_base.py", + "nloc": 18, + "complexity": 5, + "token_count": 184, + "parameters": [ + "c", + "r" + ], + "start_line": 126, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "hankel", + "long_name": "hankel( c , r = None )", + "filename": "matrix_base.py", + "nloc": 16, + "complexity": 5, + "token_count": 167, + "parameters": [ + "c", + "r" + ], + "start_line": 157, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "matrix_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 186, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 193, + "end_line": 195, + "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": 197, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "fliplr", + "long_name": "fliplr( m )", + "filename": "matrix_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "parameters": [ + "m" + ], + "start_line": 20, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "hankel", + "long_name": "hankel( c , r = None )", + "filename": "matrix_base.py", + "nloc": 16, + "complexity": 5, + "token_count": 167, + "parameters": [ + "c", + "r" + ], + "start_line": 157, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "matrix_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 186, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "toeplitz", + "long_name": "toeplitz( c , r = None )", + "filename": "matrix_base.py", + "nloc": 18, + "complexity": 5, + "token_count": 184, + "parameters": [ + "c", + "r" + ], + "start_line": 126, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "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": 197, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "matrix_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 193, + "end_line": 195, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "tril", + "long_name": "tril( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 67, + "parameters": [ + "m", + "k" + ], + "start_line": 106, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "eye", + "long_name": "eye( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 67, + "end_line": 79, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "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": 40, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "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": 29, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "tri", + "long_name": "tri( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 53, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "triu", + "long_name": "triu( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 69, + "parameters": [ + "m", + "k" + ], + "start_line": 116, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "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": 81, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + } + ], + "nloc": 125, + "complexity": 39, + "token_count": 1103, + "diff_parsed": { + "added": [ + "\"\"\" Basic functions for manipulating 2d arrays", + "", + "\"\"\"", + "", + "__all__ = ['diag','eye','fliplr','flipud','hankel','rot90','tri',", + " 'tril','triu','toeplitz','all_mat']", + "", + "# These are from Numeric", + "import Matrix", + "from Numeric import *", + "from fastumath import *", + "from type_check import isscalar", + "from index_tricks import mgrid,r_,c_", + "# Elementary Matrices", + "", + "# zeros is from matrixmodule in C", + "# ones is from Numeric.py", + "", + "", + "def fliplr(m):", + " \"\"\" returns a 2-D matrix m with the rows preserved and columns flipped", + " in the left/right direction. Only works with 2-D arrays.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " return m[:, ::-1]", + "", + "def flipud(m):", + " \"\"\" returns a 2-D matrix with the columns preserved and rows flipped in", + " the up/down direction. Only works with 2-D arrays.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " return m[::-1]", + "", + "# reshape(x, m, n) is not used, instead use reshape(x, (m, n))", + "", + "def rot90(m, k=1):", + " \"\"\" returns the matrix found by rotating m by k*90 degrees in the", + " counterclockwise direction.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " k = k % 4", + " if k == 0: return m", + " elif k == 1: return transpose(fliplr(m))", + " elif k == 2: return fliplr(flipud(m))", + " else: return fliplr(transpose(m)) # k==3", + "", + "def tri(N, M=None, k=0, typecode=None):", + " \"\"\" returns a N-by-M matrix where all the diagonals starting from", + " lower left corner up to the k-th are all ones.", + " \"\"\"", + " if M is None: M = N", + " if type(M) == type('d'):", + " typecode = M", + " M = N", + " m = greater_equal(subtract.outer(arange(N), arange(M)),-k)", + " if typecode is None:", + " return m", + " else:", + " return m.astype(typecode)", + "", + "def eye(N, M=None, k=0, typecode=None):", + " \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones,", + " and everything else is zeros.", + " \"\"\"", + " if M is None: M = N", + " if type(M) == type('d'):", + " typecode = M", + " M = N", + " m = equal(subtract.outer(arange(N), arange(M)),-k)", + " if typecode is None:", + " return m", + " else:", + " return m.astype(typecode)", + "", + "def diag(v, k=0):", + " \"\"\" returns the k-th diagonal if v is a matrix or returns a matrix", + " with v as the k-th diagonal if v is a vector.", + " \"\"\"", + " v = asarray(v)", + " s = v.shape", + " if len(s)==1:", + " n = s[0]+abs(k)", + " if k > 0:", + " v = concatenate((zeros(k, v.typecode()),v))", + " elif k < 0:", + " v = concatenate((v,zeros(-k, v.typecode())))", + " return eye(n, k=k)*v", + " elif len(s)==2:", + " v = add.reduce(eye(s[0], s[1], k=k)*v)", + " if k > 0: return v[k:]", + " elif k < 0: return v[:k]", + " else: return v", + " else:", + " raise ValueError, \"Input must be 1- or 2-D.\"", + "", + "#-----------------------------------------------------------------------------", + "# move all these", + "#-----------------------------------------------------------------------------", + "", + "def tril(m, k=0):", + " \"\"\" returns the elements on and below the k-th diagonal of m. k=0 is the", + " main diagonal, k > 0 is above and k < 0 is below the main diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m", + " out.savespace(svsp)", + " return out", + "", + "def triu(m, k=0):", + " \"\"\" returns the elements on and above the k-th diagonal of m. k=0 is the", + " main diagonal, k > 0 is above and k < 0 is below the main diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m", + " out.savespace(svsp)", + " return out", + "", + "def toeplitz(c,r=None):", + " \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).", + "", + " Description:", + "", + " toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first", + " column and r as its first row.", + "", + " toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c).", + "", + " See also: hankel", + " \"\"\"", + " if isscalar(c) or isscalar(r):", + " return c", + " if r is None:", + " r = c", + " r[0] = conjugate(r[0])", + " c = conjugate(c)", + " r,c = map(asarray,(r,c))", + " r,c = map(ravel,(r,c))", + " rN,cN = map(len,(r,c))", + " if r[0] != c[0]:", + " print \"Warning: column and row values don't agree; column value used.\"", + " vals = r_[r[rN-1:0:-1], c]", + " cols = mgrid[0:cN]", + " rows = mgrid[rN:0:-1]", + " indx = cols[:,NewAxis]*ones((1,rN)) + \\", + " rows[NewAxis,:]*ones((cN,1)) - 1", + " return take(vals, indx)", + "", + "", + "def hankel(c,r=None):", + " \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).", + "", + " Description:", + "", + " hankel(c,r) is a Hankel matrix whose first column is c and whose", + " last row is r.", + "", + " hankel(c) is a square Hankel matrix whose first column is C.", + " Elements below the first anti-diagonal are zero.", + "", + " See also: toeplitz", + " \"\"\"", + " if isscalar(c) or isscalar(r):", + " return c", + " if r is None:", + " r = zeros(len(c))", + " elif r[0] != c[-1]:", + " print \"Warning: column and row values don't agree; column value used.\"", + " r,c = map(asarray,(r,c))", + " r,c = map(ravel,(r,c))", + " rN,cN = map(len,(r,c))", + " vals = r_[c, r[1:rN]]", + " cols = mgrid[1:cN+1]", + " rows = mgrid[0:rN]", + " indx = cols[:,NewAxis]*ones((1,rN)) + \\", + " rows[NewAxis,:]*ones((cN,1)) - 1", + " return take(vals, indx)", + "", + "def all_mat(args):", + " return map(Matrix.Matrix,args)", + "", + "#-----------------------------------------------------------------------------", + "# Test Routines", + "#-----------------------------------------------------------------------------", + "", + "def test(level=10):", + " from scipy_base.testing import module_test", + " module_test(__name__,__file__,level=level)", + "", + "def test_suite(level=1):", + " from scipy_base.testing import module_test_suite", + " return module_test_suite(__name__,__file__,level=level)", + "", + "if __name__ == '__main__':", + " print 'float epsilon:',float_epsilon", + " print 'float tiny:',float_tiny", + " print 'double epsilon:',double_epsilon", + " print 'double tiny:',double_tiny" + ], + "deleted": [] + } + }, + { + "old_path": "scipy_base/polynomial.py", + "new_path": "scipy_base/polynomial.py", + "filename": "polynomial.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,8 +1,11 @@\n import Numeric\n from Numeric import *\n from scimath import *\n-from convenience import diag\n-from utility import hstack, r1array, trim_zeros, isscalar\n+\n+from type_check import isscalar\n+from matrix_base import diag\n+from shape_base import hstack, atleast_1d\n+from function_base import trim_zeros\n \n __all__ = ['poly','roots','polyint','polyder','polyadd','polysub','polymul',\n 'polydiv','polyval','poly1d']\n@@ -30,7 +33,7 @@ def poly(seq_of_zeros):\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n- seq_of_zeros = r1array(seq_of_zeros) \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 seq_of_zeros, vecs = MLab.eig(seq_of_zeros)\n@@ -67,7 +70,7 @@ def roots(p):\n \"\"\"\n # If input is scalar, this makes it an array\n eig = get_eigval_func()\n- p = r1array(p)\n+ p = atleast_1d(p)\n if len(p.shape) != 1:\n raise ValueError,\"Input must be a rank-1 array.\"\n \n@@ -108,7 +111,7 @@ def polyint(p,m=1,k=None):\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n- k = r1array(k)\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@@ -164,7 +167,7 @@ def polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n- a1,a2 = map(r1array,(a1,a2))\n+ a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n@@ -182,7 +185,7 @@ def polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n- a1,a2 = map(r1array,(a1,a2))\n+ a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n@@ -224,8 +227,8 @@ def deconvolve(signal, divisor):\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n- num = r1array(signal)\n- den = r1array(divisor)\n+ num = atleast_1d(signal)\n+ den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n@@ -291,7 +294,7 @@ def __init__(self, c_or_r, r=0):\n return\n if r:\n c_or_r = poly(c_or_r)\n- c_or_r = r1array(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", + "added_lines": 13, + "deleted_lines": 10, + "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\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:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = atleast_1d(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros, vecs = MLab.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\n # tack any zeros onto the back of the array \n roots = hstack((roots,zeros(trailing_zeros,roots.typecode())))\n return roots\n\ndef polyint(p,m=1,k=None):\n \"\"\"Return the mth analytical integral of the polynomial p.\n\n If k is None, then zero-valued constants of integration are used.\n otherwise, k should be a list of length m (or a scalar if m=1) to\n represent the constants of integration to use for each integration\n (starting with k[0])\n \"\"\"\n m = int(m)\n if m < 0:\n raise ValueError, \"Order of integral must be positive (see polyder)\"\n if k is None:\n k = Numeric.zeros(m)\n k = atleast_1d(k)\n if len(k) == 1 and m > 1:\n k = k[0]*Numeric.ones(m)\n if len(k) < m:\n raise ValueError, \\\n \"k must be a scalar or a rank-1 array of length 1 or >m.\"\n if m == 0:\n return p\n else:\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n y = Numeric.zeros(len(p)+1,'d')\n y[:-1] = p*1.0/Numeric.arange(len(p),0,-1)\n y[-1] = k[0] \n val = polyint(y,m-1,k=k[1:])\n if truepoly:\n val = poly1d(val)\n return val\n \ndef polyder(p,m=1):\n \"\"\"Return the mth derivative of the polynomial p.\n \"\"\"\n m = int(m)\n truepoly = isinstance(p,poly1d)\n p = Numeric.asarray(p)\n n = len(p)-1\n y = p[:-1] * Numeric.arange(n,0,-1)\n if m < 0:\n raise ValueError, \"Order of derivative must be positive (see polyint)\"\n if m == 0:\n return p\n else:\n val = polyder(y,m-1)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polyval(p,x):\n \"\"\"Evaluate the polymnomial p at x.\n\n Description:\n\n If p is of length N, this function returns the value:\n p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]\n \"\"\"\n x = Numeric.asarray(x)\n p = Numeric.asarray(p)\n y = Numeric.zeros(x.shape,x.typecode())\n for i in range(len(p)):\n y = x * y + p[i]\n return y\n\ndef polyadd(a1,a2):\n \"\"\"Adds two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 + a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) + a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 + Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polysub(a1,a2):\n \"\"\"Subtracts two polynomials represented as lists\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n a1,a2 = map(atleast_1d,(a1,a2))\n diff = len(a2) - len(a1)\n if diff == 0:\n return a1 - a2\n elif diff > 0:\n zr = Numeric.zeros(diff)\n val = Numeric.concatenate((zr,a1)) - a2\n else:\n zr = Numeric.zeros(abs(diff))\n val = a1 - Numeric.concatenate((zr,a2))\n if truepoly:\n val = poly1d(val)\n return val\n\n\ndef polymul(a1,a2):\n \"\"\"Multiplies two polynomials represented as lists.\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n val = Numeric.convolve(a1,a2)\n if truepoly:\n val = poly1d(val)\n return val\n\ndef polydiv(a1,a2):\n \"\"\"Computes q and r polynomials so that a1(s) = q(s)*a2(s) + r(s)\n \"\"\"\n truepoly = (isinstance(a1,poly1d) or isinstance(a2,poly1d))\n q, r = deconvolve(a1,a2)\n while Numeric.allclose(r[0], 0, rtol=1e-14) and (r.shape[-1] > 1):\n r = r[1:]\n if truepoly:\n q, r = map(poly1d,(q,r))\n return q, r\n\ndef deconvolve(signal, divisor):\n \"\"\"Deconvolves divisor out of signal.\n \"\"\"\n try:\n import scipy.signal\n except:\n print \"You need scipy.signal to use this function.\"\n num = atleast_1d(signal)\n den = atleast_1d(divisor)\n N = len(num)\n D = len(den)\n if D > N:\n quot = [];\n rem = num;\n else:\n input = Numeric.ones(N-D+1,Numeric.Float)\n input[1:] = 0\n quot = scipy.signal.lfilter(num, den, input)\n rem = num - Numeric.convolve(den,quot,mode=2)\n return quot, rem\n\nimport re\n_poly_mat = re.compile(r\"[*][*]([0-9]*)\")\ndef _raise_power(astr, wrap=70):\n n = 0\n line1 = ''\n line2 = ''\n output = ' '\n while 1:\n mat = _poly_mat.search(astr,n)\n if mat is None:\n break\n span = mat.span()\n power = mat.groups()[0]\n partstr = astr[n:span[0]]\n n = span[1]\n toadd2 = partstr + ' '*(len(power)-1)\n toadd1 = ' '*(len(partstr)-1) + power\n if ((len(line2)+len(toadd2) > wrap) or \\\n (len(line1)+len(toadd1) > wrap)):\n output += line1 + \"\\n\" + line2 + \"\\n \"\n line1 = toadd1\n line2 = toadd2\n else: \n line2 += partstr + ' '*(len(power)-1)\n line1 += ' '*(len(partstr)-1) + power\n output += line1 + \"\\n\" + line2\n return output + astr[n:]\n \n \nclass poly1d:\n \"\"\"A one-dimensional polynomial class.\n\n p = poly1d([1,2,3]) constructs the polynomial x**2 + 2 x + 3\n\n p(0.5) evaluates the polynomial at the location\n p.r is a list of roots\n p.c is the coefficient array [1,2,3]\n p.order is the polynomial order (after leading zeros in p.c are removed)\n p[k] is the coefficient on the kth power of x (backwards from\n sequencing the coefficient array.\n\n polynomials can be added, substracted, multplied and divided (returns\n quotient and remainder).\n asarray(p) will also give the coefficient array, so polynomials can\n be used in all functions that accept arrays.\n \"\"\"\n def __init__(self, c_or_r, r=0):\n if isinstance(c_or_r,poly1d):\n for key in c_or_r.__dict__.keys():\n self.__dict__[key] = c_or_r.__dict__[key]\n return\n if r:\n c_or_r = poly(c_or_r)\n c_or_r = atleast_1d(c_or_r)\n if len(c_or_r.shape) > 1:\n raise ValueError, \"Polynomial must be 1d only.\"\n c_or_r = trim_zeros(c_or_r, trim='f')\n if len(c_or_r) == 0:\n c_or_r = Numeric.array([0])\n self.__dict__['coeffs'] = c_or_r\n self.__dict__['order'] = len(c_or_r) - 1\n\n def __array__(self,t=None):\n if t:\n return Numeric.asarray(self.coeffs,t)\n else:\n return Numeric.asarray(self.coeffs)\n\n def __repr__(self):\n vals = repr(self.coeffs)\n vals = vals[6:-1]\n return \"poly1d(%s)\" % vals\n\n def __len__(self):\n return self.order\n\n def __str__(self):\n N = self.order\n thestr = \"0\"\n for k in range(len(self.coeffs)):\n coefstr ='%.4g' % abs(self.coeffs[k])\n if coefstr[-4:] == '0000':\n coefstr = coefstr[:-5]\n power = (N-k)\n if power == 0:\n if coefstr != '0':\n newstr = '%s' % (coefstr,)\n else:\n if k == 0:\n newstr = '0'\n else:\n newstr = ''\n elif power == 1:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x'\n else: \n newstr = '%s x' % (coefstr,)\n else:\n if coefstr == '0':\n newstr = ''\n elif coefstr == '1':\n newstr = 'x**%d' % (power,)\n else: \n newstr = '%s x**%d' % (coefstr, power)\n\n if k > 0:\n if newstr != '':\n if self.coeffs[k] < 0:\n thestr = \"%s - %s\" % (thestr, newstr)\n else:\n thestr = \"%s + %s\" % (thestr, newstr)\n elif (k == 0) and (newstr != '') and (self.coeffs[k] < 0):\n thestr = \"-%s\" % (newstr,)\n else:\n thestr = newstr\n return _raise_power(thestr)\n \n\n def __call__(self, val):\n return polyval(self.coeffs, val)\n\n def __mul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs))\n\n def __rmul__(self, other):\n if isscalar(other):\n return poly1d(other*self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polymul(self.coeffs, other.coeffs)) \n\n def __add__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs)) \n \n def __radd__(self, other):\n if isscalar(other):\n return poly1d(other+self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polyadd(self.coeffs, other.coeffs))\n\n def __pow__(self, val):\n if not isscalar(val) or int(val) != val or val < 0:\n raise ValueError, \"Power to non-negative integers only.\"\n res = [1]\n for k in range(val):\n res = polymul(self.coeffs, res)\n return poly1d(res)\n\n def __sub__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs-other)\n else:\n other = poly1d(other)\n return poly1d(polysub(self.coeffs, other.coeffs))\n\n def __rsub__(self, other):\n if isscalar(other):\n return poly1d(other-self.coeffs)\n else:\n other = poly1d(other)\n return poly1d(polysub(other.coeffs, self.coeffs))\n\n def __div__(self, other):\n if isscalar(other):\n return poly1d(self.coeffs/other)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(self.coeffs, other.coeffs))\n\n def __rdiv__(self, other):\n if isscalar(other):\n return poly1d(other/self.coeffs)\n else:\n other = poly1d(other)\n return map(poly1d,polydiv(other.coeffs, self.coeffs))\n\n def __setattr__(self, key, val):\n raise ValueError, \"Attributes cannot be changed this way.\"\n\n def __getattr__(self, key):\n if key == '__coerce__':\n raise KeyError\n if key in ['r','roots']:\n return roots(self.coeffs)\n elif key in ['c','coef','coefficients']:\n return self.coeffs\n elif key in ['o']:\n return self.order\n else:\n return self.__dict__[key]\n \n def __getitem__(self, val):\n ind = self.order - val\n if val > self.order:\n return 0\n if val < 0:\n return 0\n return self.coeffs[ind]\n\n def __setitem__(self, key, val):\n ind = self.order - key\n if key < 0:\n raise ValueError, \"Does not support negative powers.\"\n if key > self.order:\n zr = Numeric.zeros(key-self.order,self.coeffs.typecode())\n self.__dict__['coeffs'] = Numeric.concatenate((zr,self.coeffs))\n self.__dict__['order'] = key\n ind = 0\n self.__dict__['coeffs'][ind] = val\n return\n\n def integ(self, m=1, k=0):\n return poly1d(polyint(self.coeffs,m=m,k=k))\n\n def deriv(self, m=1):\n return poly1d(polyder(self.coeffs,m=m))\n", + "source_code_before": "import Numeric\nfrom Numeric import *\nfrom scimath import *\nfrom convenience import diag\nfrom utility import hstack, r1array, trim_zeros, isscalar\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:\n try:\n import LinearAlgebra\n eigvals = LinearAlgebra.eigenvalues\n except:\n raise ImportError, \"You must have scipy.linalg our LinearAlgebra to use this function.\"\n return eigvals\n\ndef poly(seq_of_zeros):\n \"\"\" Return a sequence representing a polynomial given a sequence of roots.\n\n If the input is a matrix, return the characteristic polynomial.\n \n Example:\n \n >>> b = roots([1,3,1,5,6])\n >>> poly(b)\n array([1., 3., 1., 5., 6.])\n \"\"\"\n seq_of_zeros = r1array(seq_of_zeros) \n sh = shape(seq_of_zeros)\n if len(sh) == 2 and sh[0] == sh[1]:\n seq_of_zeros, vecs = MLab.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 = r1array(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\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 = r1array(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(r1array,(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(r1array,(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 = r1array(signal)\n den = r1array(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 = r1array(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": 11, + "complexity": 3, + "token_count": 36, + "parameters": [], + "start_line": 13, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 22, + "complexity": 9, + "token_count": 194, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 25, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 64, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "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": 101, + "end_line": 131, + "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": 133, + "end_line": 149, + "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": 151, + "end_line": 164, + "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": 166, + "end_line": 182, + "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": 184, + "end_line": 200, + "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": 203, + "end_line": 210, + "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": 212, + "end_line": 221, + "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": 223, + "end_line": 242, + "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": 246, + "end_line": 270, + "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": 290, + "end_line": 304, + "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": 306, + "end_line": 310, + "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": 312, + "end_line": 315, + "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": 317, + "end_line": 318, + "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": 320, + "end_line": 361, + "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": 364, + "end_line": 365, + "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": 367, + "end_line": 372, + "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": 374, + "end_line": 379, + "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": 381, + "end_line": 386, + "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": 388, + "end_line": 393, + "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": 395, + "end_line": 401, + "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": 403, + "end_line": 408, + "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": 410, + "end_line": 415, + "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": 417, + "end_line": 422, + "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": 424, + "end_line": 429, + "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": 431, + "end_line": 432, + "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": 434, + "end_line": 444, + "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": 446, + "end_line": 452, + "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": 454, + "end_line": 464, + "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": 466, + "end_line": 467, + "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": 469, + "end_line": 470, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "methods_before": [ + { + "name": "get_eigval_func", + "long_name": "get_eigval_func( )", + "filename": "polynomial.py", + "nloc": 11, + "complexity": 3, + "token_count": 36, + "parameters": [], + "start_line": 10, + "end_line": 20, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 22, + "complexity": 9, + "token_count": 194, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 22, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 61, + "end_line": 96, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "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": 98, + "end_line": 128, + "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": 130, + "end_line": 146, + "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": 148, + "end_line": 161, + "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": 163, + "end_line": 179, + "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": 181, + "end_line": 197, + "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": 200, + "end_line": 207, + "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": 209, + "end_line": 218, + "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": 220, + "end_line": 239, + "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": 243, + "end_line": 267, + "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": 287, + "end_line": 301, + "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": 303, + "end_line": 307, + "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": 309, + "end_line": 312, + "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": 314, + "end_line": 315, + "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": 317, + "end_line": 358, + "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": 361, + "end_line": 362, + "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": 364, + "end_line": 369, + "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": 371, + "end_line": 376, + "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": 378, + "end_line": 383, + "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": 385, + "end_line": 390, + "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": 392, + "end_line": 398, + "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": 400, + "end_line": 405, + "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": 407, + "end_line": 412, + "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": 414, + "end_line": 419, + "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": 421, + "end_line": 426, + "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": 428, + "end_line": 429, + "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": 431, + "end_line": 441, + "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": 443, + "end_line": 449, + "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": 451, + "end_line": 461, + "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": 463, + "end_line": 464, + "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": 466, + "end_line": 467, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + } + ], + "changed_methods": [ + { + "name": "polysub", + "long_name": "polysub( a1 , a2 )", + "filename": "polynomial.py", + "nloc": 15, + "complexity": 5, + "token_count": 124, + "parameters": [ + "a1", + "a2" + ], + "start_line": 184, + "end_line": 200, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "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": 166, + "end_line": 182, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "polyint", + "long_name": "polyint( p , m = 1 , k = None )", + "filename": "polynomial.py", + "nloc": 24, + "complexity": 8, + "token_count": 192, + "parameters": [ + "p", + "m", + "k" + ], + "start_line": 101, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 0 + }, + { + "name": "roots", + "long_name": "roots( p )", + "filename": "polynomial.py", + "nloc": 17, + "complexity": 4, + "token_count": 182, + "parameters": [ + "p" + ], + "start_line": 64, + "end_line": 99, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "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": 290, + "end_line": 304, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 15, + "top_nesting_level": 1 + }, + { + "name": "deconvolve", + "long_name": "deconvolve( signal , divisor )", + "filename": "polynomial.py", + "nloc": 18, + "complexity": 3, + "token_count": 115, + "parameters": [ + "signal", + "divisor" + ], + "start_line": 223, + "end_line": 242, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "poly", + "long_name": "poly( seq_of_zeros )", + "filename": "polynomial.py", + "nloc": 22, + "complexity": 9, + "token_count": 194, + "parameters": [ + "seq_of_zeros" + ], + "start_line": 25, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 38, + "top_nesting_level": 0 + } + ], + "nloc": 370, + "complexity": 119, + "token_count": 2689, + "diff_parsed": { + "added": [ + "", + "from type_check import isscalar", + "from matrix_base import diag", + "from shape_base import hstack, atleast_1d", + "from function_base import trim_zeros", + " seq_of_zeros = atleast_1d(seq_of_zeros)", + " p = atleast_1d(p)", + " k = atleast_1d(k)", + " a1,a2 = map(atleast_1d,(a1,a2))", + " a1,a2 = map(atleast_1d,(a1,a2))", + " num = atleast_1d(signal)", + " den = atleast_1d(divisor)", + " c_or_r = atleast_1d(c_or_r)" + ], + "deleted": [ + "from convenience import diag", + "from utility import hstack, r1array, trim_zeros, isscalar", + " seq_of_zeros = r1array(seq_of_zeros)", + " p = r1array(p)", + " k = r1array(k)", + " a1,a2 = map(r1array,(a1,a2))", + " a1,a2 = map(r1array,(a1,a2))", + " num = r1array(signal)", + " den = r1array(divisor)", + " c_or_r = r1array(c_or_r)" + ] + } + }, + { + "old_path": "scipy_base/scimath.py", + "new_path": "scipy_base/scimath.py", + "filename": "scimath.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -5,7 +5,8 @@\n \n __all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']\n \n-from convenience import any, isreal\n+from type_check import isreal\n+from function_base import any\n import fastumath\n import Numeric\n from fastumath import *\n", + "added_lines": 2, + "deleted_lines": 1, + "source_code": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions whose output is\ndifferent than the input under certain conditions.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']\n\nfrom type_check import isreal\nfrom function_base import any\nimport fastumath\nimport Numeric\nfrom fastumath import *\ntoextend = fastumath.__dict__.keys()\nfor key in toextend:\n if key not in __all__ and key[0] != '_':\n __all__.append(key)\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,x):\n \"\"\" Take log base n of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(x)/fastumath.log(n)\n\ndef log2(x):\n \"\"\" Take log base 2 of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n\n\n", + "source_code_before": "\"\"\"\nWrapper functions to more user-friendly calling of certain math functions whose output is\ndifferent than the input under certain conditions.\n\"\"\"\n\n__all__ = ['sqrt', 'log', 'log2','logn','log10', 'power', 'arccos', 'arcsin', 'arctanh']\n\nfrom convenience import any, isreal\nimport fastumath\nimport Numeric\nfrom fastumath import *\ntoextend = fastumath.__dict__.keys()\nfor key in toextend:\n if key not in __all__ and key[0] != '_':\n __all__.append(key)\n\ndef _tocomplex(arr):\n if arr.typecode() in ['f', 's', 'b', '1']:\n return arr.astype('F')\n else:\n return arr.astype('D')\n\ndef sqrt(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.sqrt(x)\n\ndef log(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)\n\ndef log10(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log10(x) \n\ndef logn(n,x):\n \"\"\" Take log base n of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n if isreal(n) and (n<0):\n n = _tocomplex(n)\n return fastumath.log(x)/fastumath.log(n)\n\ndef log2(x):\n \"\"\" Take log base 2 of x.\n \"\"\"\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.log(x)/fastumath.log(2)\n\n\ndef power(x, p):\n x = Numeric.asarray(x)\n if isreal(x) and any(x<0):\n x = _tocomplex(x)\n return fastumath.power(x, p)\n \ndef arccos(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arccos(x)\n\ndef arcsin(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arcsin(x)\n\ndef arctanh(x):\n x = Numeric.asarray(x)\n if isreal(x) and any(abs(x)>1):\n x = _tocomplex(x)\n return fastumath.arctanh(x)\n\n\n", + "methods": [ + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 18, + "end_line": 22, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 24, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 30, + "end_line": 34, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 36, + "end_line": 40, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , x )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "x" + ], + "start_line": 42, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "x" + ], + "start_line": 52, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 61, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 67, + "end_line": 71, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 73, + "end_line": 77, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 79, + "end_line": 83, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "_tocomplex", + "long_name": "_tocomplex( arr )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 2, + "token_count": 38, + "parameters": [ + "arr" + ], + "start_line": 17, + "end_line": 21, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "sqrt", + "long_name": "sqrt( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 23, + "end_line": 27, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log", + "long_name": "log( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 29, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "log10", + "long_name": "log10( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 39, + "parameters": [ + "x" + ], + "start_line": 35, + "end_line": 39, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "logn", + "long_name": "logn( n , x )", + "filename": "scimath.py", + "nloc": 7, + "complexity": 5, + "token_count": 67, + "parameters": [ + "n", + "x" + ], + "start_line": 41, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "log2", + "long_name": "log2( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 47, + "parameters": [ + "x" + ], + "start_line": 51, + "end_line": 57, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "power", + "long_name": "power( x , p )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 43, + "parameters": [ + "x", + "p" + ], + "start_line": 60, + "end_line": 64, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arccos", + "long_name": "arccos( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 66, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arcsin", + "long_name": "arcsin( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 72, + "end_line": 76, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "arctanh", + "long_name": "arctanh( x )", + "filename": "scimath.py", + "nloc": 5, + "complexity": 3, + "token_count": 42, + "parameters": [ + "x" + ], + "start_line": 78, + "end_line": 82, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 66, + "complexity": 31, + "token_count": 519, + "diff_parsed": { + "added": [ + "from type_check import isreal", + "from function_base import any" + ], + "deleted": [ + "from convenience import any, isreal" + ] + } + }, + { + "old_path": null, + "new_path": "scipy_base/shape_base.py", + "filename": "shape_base.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,439 @@\n+import Numeric\n+from Numeric import *\n+\n+__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n+ 'column_stack','dstack','array_split','split','hsplit',\n+ 'vsplit','dsplit','squeeze']\n+\n+def squeeze(a):\n+ \"Returns a with any ones from the shape of a removed\"\n+ a = asarray(a)\n+ b = asarray(a.shape)\n+ return reshape (a, tuple (compress (not_equal (b, 1), b)))\n+\n+def atleast_1d(ary):\n+ \"\"\" Force a sequence of arrays to each be at least 1D.\n+\n+ Description:\n+ Force an array to be at least 1D. If an array is 0D, the \n+ array is converted to a single row of values. Otherwise,\n+ the array is unaltered.\n+ Arguments:\n+ ary -- array to be converted to 1 or more dimensional array.\n+ Returns:\n+ input array converted to at least 1D array.\n+ \"\"\"\n+ ary = asarray(ary)\n+ if len(ary.shape) == 0: \n+ result = Numeric.array([ary[0]])\n+ else:\n+ result = ary\n+ return result\n+\n+def atleast_2d(ary):\n+ \"\"\" Force a sequence of arrays to each be at least 2D.\n+\n+ Description:\n+ Force an array to each be at least 2D. If the array\n+ is 0D or 1D, the array is converted to a single\n+ row of values. Otherwise, the array is unaltered.\n+ Arguments:\n+ ary -- array to be converted to 2 or more dimensional array.\n+ Returns:\n+ input array converted to at least 2D array.\n+ \"\"\"\n+ ary = asarray(ary)\n+ if len(ary.shape) == 0: \n+ ary = Numeric.array([ary[0]])\n+ if len(ary.shape) == 1: \n+ result = ary[NewAxis,:]\n+ else: \n+ result = ary\n+ return result\n+\n+def atleast_3d(ary):\n+ \"\"\" Force a sequence of arrays to each be at least 3D.\n+\n+ Description:\n+ Force an array each be at least 3D. If the array is 0D or 1D, \n+ the array is converted to a single 1xNx1 array of values where \n+ N is the orginal length of the array. If the array is 2D, the \n+ array is converted to a single MxNx1 array of values where MxN\n+ is the orginal shape of the array. Otherwise, the array is \n+ unaltered.\n+ Arguments:\n+ ary -- array to be converted to 3 or more dimensional array.\n+ Returns:\n+ input array converted to at least 3D array.\n+ \"\"\"\n+ ary = asarray(ary)\n+ if len(ary.shape) == 0:\n+ ary = Numeric.array([ary[0]])\n+ if len(ary.shape) == 1:\n+ result = ary[NewAxis,:,NewAxis]\n+ elif len(ary.shape) == 2:\n+ result = ary[:,:,NewAxis]\n+ else: \n+ result = ary\n+ return result\n+\n+def vstack(tup):\n+ \"\"\" Stack arrays in sequence vertically (row wise)\n+\n+ Description:\n+ Take a sequence of arrays and stack them veritcally\n+ to make a single array. All arrays in the sequence\n+ must have the same shape along all but the first axis. \n+ vstack will rebuild arrays divided by vsplit.\n+ Arguments:\n+ tup -- sequence of arrays. All arrays must have the same \n+ shape.\n+ Examples:\n+ >>> import scipy\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.vstack((a,b))\n+ array([[1, 2, 3],\n+ [2, 3, 4]])\n+ >>> a = array([[1],[2],[3]])\n+ >>> b = array([[2],[3],[4]])\n+ >>> scipy.vstack((a,b))\n+ array([[1],\n+ [2],\n+ [3],\n+ [2],\n+ [3],\n+ [4]])\n+\n+ \"\"\"\n+ return Numeric.concatenate(map(atleast_2d,tup),0)\n+\n+def hstack(tup):\n+ \"\"\" Stack arrays in sequence horizontally (column wise)\n+\n+ Description:\n+ Take a sequence of arrays and stack them horizontally\n+ to make a single array. All arrays in the sequence\n+ must have the same shape along all but the second axis.\n+ hstack will rebuild arrays divided by hsplit.\n+ Arguments:\n+ tup -- sequence of arrays. All arrays must have the same \n+ shape.\n+ Examples:\n+ >>> import scipy\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.hstack((a,b))\n+ array([1, 2, 3, 2, 3, 4])\n+ >>> a = array([[1],[2],[3]])\n+ >>> b = array([[2],[3],[4]])\n+ >>> scipy.hstack((a,b))\n+ array([[1, 2],\n+ [2, 3],\n+ [3, 4]])\n+\n+ \"\"\"\n+ return Numeric.concatenate(map(atleast_1d,tup),1)\n+\n+def column_stack(tup):\n+ \"\"\" Stack 1D arrays as columns into a 2D array\n+\n+ Description:\n+ Take a sequence of 1D arrays and stack them as columns\n+ to make a single 2D array. All arrays in the sequence\n+ must have the same length.\n+ Arguments:\n+ tup -- sequence of 1D arrays. All arrays must have the same \n+ length.\n+ Examples:\n+ >>> import scipy\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.vstack((a,b))\n+ array([[1, 2],\n+ [2, 3],\n+ [3, 4]])\n+\n+ \"\"\"\n+ arrays = map(Numeric.transpose,map(atleast_2d,tup))\n+ return Numeric.concatenate(arrays,1)\n+ \n+def dstack(tup):\n+ \"\"\" Stack arrays in sequence depth wise (along third dimension)\n+\n+ Description:\n+ Take a sequence of arrays and stack them along the third axis.\n+ All arrays in the sequence must have the same shape along all \n+ but the third axis. This is a simple way to stack 2D arrays \n+ (images) into a single 3D array for processing.\n+ dstack will rebuild arrays divided by dsplit.\n+ Arguments:\n+ tup -- sequence of arrays. All arrays must have the same \n+ shape.\n+ Examples:\n+ >>> import scipy\n+ >>> a = array((1,2,3))\n+ >>> b = array((2,3,4))\n+ >>> scipy.dstack((a,b))\n+ array([ [[1, 2],\n+ [2, 3],\n+ [3, 4]]])\n+ >>> a = array([[1],[2],[3]])\n+ >>> b = array([[2],[3],[4]])\n+ >>> scipy.dstack((a,b))\n+ array([[ [1, 2]],\n+ [ [2, 3]],\n+ [ [3, 4]]])\n+ \"\"\"\n+ return Numeric.concatenate(map(atleast_3d,tup),2)\n+\n+def _replace_zero_by_x_arrays(sub_arys):\n+ for i in range(len(sub_arys)):\n+ if len(Numeric.shape(sub_arys[i])) == 0:\n+ sub_arys[i] = Numeric.array([])\n+ elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n+ sub_arys[i] = Numeric.array([]) \n+ return sub_arys\n+ \n+def array_split(ary,indices_or_sections,axis = 0):\n+ \"\"\" Divide an array into a list of sub-arrays.\n+\n+ Description:\n+ Divide ary into a list of sub-arrays along the\n+ specified axis. If indices_or_sections is an integer,\n+ ary is divided into that many equally sized arrays.\n+ If it is impossible to make an equal split, each of the\n+ leading arrays in the list have one additional member. If\n+ indices_or_sections is a list of sorted integers, its\n+ entries define the indexes where ary is split.\n+\n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ axis -- integer. default=0.\n+ Specifies the axis along which to split ary.\n+ Caveats:\n+ Currently, the default for axis is 0. This\n+ means a 2D array is divided into multiple groups\n+ of rows. This seems like the appropriate default, but\n+ we've agreed most other functions should default to\n+ axis=-1. Perhaps we should use axis=-1 for consistency.\n+ However, we could also make the argument that SciPy\n+ works on \"rows\" by default. sum() sums up rows of\n+ values. split() will split data into rows. Opinions?\n+ \"\"\"\n+ try:\n+ Ntotal = ary.shape[axis]\n+ except AttributeError:\n+ Ntotal = len(ary)\n+ try: # handle scalar case.\n+ Nsections = len(indices_or_sections) + 1\n+ div_points = [0] + list(indices_or_sections) + [Ntotal]\n+ except TypeError: #indices_or_sections is a scalar, not an array.\n+ Nsections = int(indices_or_sections)\n+ if Nsections <= 0:\n+ raise ValueError, 'number sections must be larger than 0.'\n+ Neach_section,extras = divmod(Ntotal,Nsections)\n+ section_sizes = [0] + \\\n+ extras * [Neach_section+1] + \\\n+ (Nsections-extras) * [Neach_section]\n+ div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n+\n+ sub_arys = []\n+ sary = Numeric.swapaxes(ary,axis,0)\n+ for i in range(Nsections):\n+ st = div_points[i]; end = div_points[i+1]\n+ sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n+\n+ # there is a wierd issue with array slicing that allows\n+ # 0x10 arrays and other such things. The following cluge is needed\n+ # to get around this issue.\n+ sub_arys = _replace_zero_by_x_arrays(sub_arys)\n+ # end cluge.\n+\n+ return sub_arys\n+\n+def split(ary,indices_or_sections,axis=0):\n+ \"\"\" Divide an array into a list of sub-arrays.\n+\n+ Description:\n+ Divide ary into a list of sub-arrays along the\n+ specified axis. If indices_or_sections is an integer,\n+ ary is divided into that many equally sized arrays.\n+ If it is impossible to make an equal split, an error is \n+ raised. This is the only way this function differs from\n+ the array_split() function. If indices_or_sections is a \n+ list of sorted integers, its entries define the indexes\n+ where ary is split.\n+\n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ axis -- integer. default=0.\n+ Specifies the axis along which to split ary.\n+ Caveats:\n+ Currently, the default for axis is 0. This\n+ means a 2D array is divided into multiple groups\n+ of rows. This seems like the appropriate default, but\n+ we've agreed most other functions should default to\n+ axis=-1. Perhaps we should use axis=-1 for consistency.\n+ However, we could also make the argument that SciPy\n+ works on \"rows\" by default. sum() sums up rows of\n+ values. split() will split data into rows. Opinions?\n+ \"\"\"\n+ try: len(indices_or_sections)\n+ except TypeError:\n+ sections = indices_or_sections\n+ N = ary.shape[axis]\n+ if N % sections:\n+ raise ValueError, 'array split does not result in an equal division'\n+ res = array_split(ary,indices_or_sections,axis)\n+ return res\n+\n+def hsplit(ary,indices_or_sections):\n+ \"\"\" Split ary into multiple columns of sub-arrays\n+\n+ Description:\n+ Split a single array into multiple sub arrays. The array is\n+ divided into groups of columns. If indices_or_sections is\n+ an integer, ary is divided into that many equally sized sub arrays.\n+ If it is impossible to make the sub-arrays equally sized, the\n+ operation throws a ValueError exception. See array_split and\n+ split for other options on indices_or_sections. \n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ Returns:\n+ sequence of sub-arrays. The returned arrays have the same \n+ number of dimensions as the input array.\n+ Related:\n+ hstack, split, array_split, vsplit, dsplit. \n+ Examples:\n+ >>> import scipy\n+ >>> a= array((1,2,3,4))\n+ >>> scipy.hsplit(a,2)\n+ [array([1, 2]), array([3, 4])]\n+ >>> a = array([[1,2,3,4],[1,2,3,4]])\n+ [array([[1, 2],\n+ [1, 2]]), array([[3, 4],\n+ [3, 4]])]\n+ \n+ \"\"\"\n+ if len(Numeric.shape(ary)) == 0:\n+ raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n+ if len(ary.shape) > 1:\n+ return split(ary,indices_or_sections,1)\n+ else:\n+ return split(ary,indices_or_sections,0)\n+ \n+def vsplit(ary,indices_or_sections):\n+ \"\"\" Split ary into multiple rows of sub-arrays\n+\n+ Description:\n+ Split a single array into multiple sub arrays. The array is\n+ divided into groups of rows. If indices_or_sections is\n+ an integer, ary is divided into that many equally sized sub arrays.\n+ If it is impossible to make the sub-arrays equally sized, the\n+ operation throws a ValueError exception. See array_split and\n+ split for other options on indices_or_sections.\n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ Returns:\n+ sequence of sub-arrays. The returned arrays have the same \n+ number of dimensions as the input array. \n+ Caveats:\n+ How should we handle 1D arrays here? I am currently raising\n+ an error when I encounter them. Any better approach? \n+ \n+ Should we reduce the returned array to their minium dimensions\n+ by getting rid of any dimensions that are 1?\n+ Related:\n+ vstack, split, array_split, hsplit, dsplit.\n+ Examples:\n+ import scipy\n+ >>> a = array([[1,2,3,4],\n+ ... [1,2,3,4]])\n+ >>> scipy.vsplit(a)\n+ [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n+ \n+ \"\"\"\n+ if len(Numeric.shape(ary)) < 2:\n+ raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n+ return split(ary,indices_or_sections,0)\n+\n+def dsplit(ary,indices_or_sections):\n+ \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n+\n+ Description:\n+ Split a single array into multiple sub arrays. The array is\n+ divided into groups along the 3rd axis. If indices_or_sections is\n+ an integer, ary is divided into that many equally sized sub arrays.\n+ If it is impossible to make the sub-arrays equally sized, the\n+ operation throws a ValueError exception. See array_split and\n+ split for other options on indices_or_sections. \n+ Arguments:\n+ ary -- N-D array.\n+ Array to be divided into sub-arrays.\n+ indices_or_sections -- integer or 1D array.\n+ If integer, defines the number of (close to) equal sized\n+ sub-arrays. If it is a 1D array of sorted indices, it\n+ defines the indexes at which ary is divided. Any empty\n+ list results in a single sub-array equal to the original\n+ array.\n+ Returns:\n+ sequence of sub-arrays. The returned arrays have the same \n+ number of dimensions as the input array.\n+ Caveats:\n+ See vsplit caveats. \n+ Related:\n+ dstack, split, array_split, hsplit, vsplit.\n+ Examples:\n+ >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n+ [array([ [[1, 2],\n+ [1, 2]]]), array([ [[3, 4],\n+ [3, 4]]])]\n+ \n+ \"\"\"\n+ if len(Numeric.shape(ary)) < 3:\n+ raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n+ return split(ary,indices_or_sections,2)\n+\n+#-----------------------------------------------------------------------------\n+# Test Routines\n+#-----------------------------------------------------------------------------\n+\n+def test(level=10):\n+ from scipy_base.testing import module_test\n+ module_test(__name__,__file__,level=level)\n+\n+def test_suite(level=1):\n+ from scipy_base.testing import module_test_suite\n+ return module_test_suite(__name__,__file__,level=level)\n+\n+if __name__ == '__main__':\n+ test()\n\\ No newline at end of file\n", + "added_lines": 439, + "deleted_lines": 0, + "source_code": "import Numeric\nfrom Numeric import *\n\n__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',\n 'column_stack','dstack','array_split','split','hsplit',\n 'vsplit','dsplit','squeeze']\n\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n a = asarray(a)\n b = asarray(a.shape)\n return reshape (a, tuple (compress (not_equal (b, 1), b)))\n\ndef atleast_1d(ary):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force an array to be at least 1D. If an array is 0D, the \n array is converted to a single row of values. Otherwise,\n the array is unaltered.\n Arguments:\n ary -- array to be converted to 1 or more dimensional array.\n Returns:\n input array converted to at least 1D array.\n \"\"\"\n ary = asarray(ary)\n if len(ary.shape) == 0: \n result = Numeric.array([ary[0]])\n else:\n result = ary\n return result\n\ndef atleast_2d(ary):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force an array to each be at least 2D. If the array\n is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n ary -- array to be converted to 2 or more dimensional array.\n Returns:\n input array converted to at least 2D array.\n \"\"\"\n ary = asarray(ary)\n if len(ary.shape) == 0: \n ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: \n result = ary[NewAxis,:]\n else: \n result = ary\n return result\n\ndef atleast_3d(ary):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force an array each be at least 3D. If the array is 0D or 1D, \n the array is converted to a single 1xNx1 array of values where \n N is the orginal length of the array. If the array is 2D, the \n array is converted to a single MxNx1 array of values where MxN\n is the orginal shape of the array. Otherwise, the array is \n unaltered.\n Arguments:\n ary -- array to be converted to 3 or more dimensional array.\n Returns:\n input array converted to at least 3D array.\n \"\"\"\n ary = asarray(ary)\n if len(ary.shape) == 0:\n ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1:\n result = ary[NewAxis,:,NewAxis]\n elif len(ary.shape) == 2:\n result = ary[:,:,NewAxis]\n else: \n result = ary\n return result\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(map(atleast_2d,tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(map(atleast_1d,tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,map(atleast_2d,tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(map(atleast_3d,tup),2)\n\ndef _replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = _replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n test()", + "source_code_before": null, + "methods": [ + { + "name": "squeeze", + "long_name": "squeeze( a )", + "filename": "shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "a" + ], + "start_line": 8, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( ary )", + "filename": "shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 42, + "parameters": [ + "ary" + ], + "start_line": 14, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( ary )", + "filename": "shape_base.py", + "nloc": 9, + "complexity": 3, + "token_count": 60, + "parameters": [ + "ary" + ], + "start_line": 33, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( ary )", + "filename": "shape_base.py", + "nloc": 11, + "complexity": 4, + "token_count": 82, + "parameters": [ + "ary" + ], + "start_line": 54, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "shape_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "tup" + ], + "start_line": 80, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "shape_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "tup" + ], + "start_line": 111, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 30, + "parameters": [ + "tup" + ], + "start_line": 138, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "shape_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "tup" + ], + "start_line": 161, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "_replace_zero_by_x_arrays", + "long_name": "_replace_zero_by_x_arrays( sub_arys )", + "filename": "shape_base.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 190, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "shape_base.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 198, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "shape_base.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 262, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "shape_base.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 305, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "shape_base.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 347, + "end_line": 387, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "shape_base.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 389, + "end_line": 424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 430, + "end_line": 432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 434, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "shape_base.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 347, + "end_line": 387, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "shape_base.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 262, + "end_line": 303, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 434, + "end_line": 436, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 430, + "end_line": 432, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "shape_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 30, + "parameters": [ + "tup" + ], + "start_line": 138, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "shape_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "tup" + ], + "start_line": 111, + "end_line": 136, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "shape_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "tup" + ], + "start_line": 161, + "end_line": 188, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "squeeze", + "long_name": "squeeze( a )", + "filename": "shape_base.py", + "nloc": 5, + "complexity": 1, + "token_count": 40, + "parameters": [ + "a" + ], + "start_line": 8, + "end_line": 12, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( ary )", + "filename": "shape_base.py", + "nloc": 11, + "complexity": 4, + "token_count": 82, + "parameters": [ + "ary" + ], + "start_line": 54, + "end_line": 78, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 25, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( ary )", + "filename": "shape_base.py", + "nloc": 7, + "complexity": 2, + "token_count": 42, + "parameters": [ + "ary" + ], + "start_line": 14, + "end_line": 31, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "shape_base.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 198, + "end_line": 260, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "shape_base.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 305, + "end_line": 345, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "shape_base.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 389, + "end_line": 424, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "shape_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "tup" + ], + "start_line": 80, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( ary )", + "filename": "shape_base.py", + "nloc": 9, + "complexity": 3, + "token_count": 60, + "parameters": [ + "ary" + ], + "start_line": 33, + "end_line": 52, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "_replace_zero_by_x_arrays", + "long_name": "_replace_zero_by_x_arrays( sub_arys )", + "filename": "shape_base.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 190, + "end_line": 196, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + } + ], + "nloc": 109, + "complexity": 35, + "token_count": 867, + "diff_parsed": { + "added": [ + "import Numeric", + "from Numeric import *", + "", + "__all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',", + " 'column_stack','dstack','array_split','split','hsplit',", + " 'vsplit','dsplit','squeeze']", + "", + "def squeeze(a):", + " \"Returns a with any ones from the shape of a removed\"", + " a = asarray(a)", + " b = asarray(a.shape)", + " return reshape (a, tuple (compress (not_equal (b, 1), b)))", + "", + "def atleast_1d(ary):", + " \"\"\" Force a sequence of arrays to each be at least 1D.", + "", + " Description:", + " Force an array to be at least 1D. If an array is 0D, the", + " array is converted to a single row of values. Otherwise,", + " the array is unaltered.", + " Arguments:", + " ary -- array to be converted to 1 or more dimensional array.", + " Returns:", + " input array converted to at least 1D array.", + " \"\"\"", + " ary = asarray(ary)", + " if len(ary.shape) == 0:", + " result = Numeric.array([ary[0]])", + " else:", + " result = ary", + " return result", + "", + "def atleast_2d(ary):", + " \"\"\" Force a sequence of arrays to each be at least 2D.", + "", + " Description:", + " Force an array to each be at least 2D. If the array", + " is 0D or 1D, the array is converted to a single", + " row of values. Otherwise, the array is unaltered.", + " Arguments:", + " ary -- array to be converted to 2 or more dimensional array.", + " Returns:", + " input array converted to at least 2D array.", + " \"\"\"", + " ary = asarray(ary)", + " if len(ary.shape) == 0:", + " ary = Numeric.array([ary[0]])", + " if len(ary.shape) == 1:", + " result = ary[NewAxis,:]", + " else:", + " result = ary", + " return result", + "", + "def atleast_3d(ary):", + " \"\"\" Force a sequence of arrays to each be at least 3D.", + "", + " Description:", + " Force an array each be at least 3D. If the array is 0D or 1D,", + " the array is converted to a single 1xNx1 array of values where", + " N is the orginal length of the array. If the array is 2D, the", + " array is converted to a single MxNx1 array of values where MxN", + " is the orginal shape of the array. Otherwise, the array is", + " unaltered.", + " Arguments:", + " ary -- array to be converted to 3 or more dimensional array.", + " Returns:", + " input array converted to at least 3D array.", + " \"\"\"", + " ary = asarray(ary)", + " if len(ary.shape) == 0:", + " ary = Numeric.array([ary[0]])", + " if len(ary.shape) == 1:", + " result = ary[NewAxis,:,NewAxis]", + " elif len(ary.shape) == 2:", + " result = ary[:,:,NewAxis]", + " else:", + " result = ary", + " return result", + "", + "def vstack(tup):", + " \"\"\" Stack arrays in sequence vertically (row wise)", + "", + " Description:", + " Take a sequence of arrays and stack them veritcally", + " to make a single array. All arrays in the sequence", + " must have the same shape along all but the first axis.", + " vstack will rebuild arrays divided by vsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.vstack((a,b))", + " array([[1, 2, 3],", + " [2, 3, 4]])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.vstack((a,b))", + " array([[1],", + " [2],", + " [3],", + " [2],", + " [3],", + " [4]])", + "", + " \"\"\"", + " return Numeric.concatenate(map(atleast_2d,tup),0)", + "", + "def hstack(tup):", + " \"\"\" Stack arrays in sequence horizontally (column wise)", + "", + " Description:", + " Take a sequence of arrays and stack them horizontally", + " to make a single array. All arrays in the sequence", + " must have the same shape along all but the second axis.", + " hstack will rebuild arrays divided by hsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.hstack((a,b))", + " array([1, 2, 3, 2, 3, 4])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.hstack((a,b))", + " array([[1, 2],", + " [2, 3],", + " [3, 4]])", + "", + " \"\"\"", + " return Numeric.concatenate(map(atleast_1d,tup),1)", + "", + "def column_stack(tup):", + " \"\"\" Stack 1D arrays as columns into a 2D array", + "", + " Description:", + " Take a sequence of 1D arrays and stack them as columns", + " to make a single 2D array. All arrays in the sequence", + " must have the same length.", + " Arguments:", + " tup -- sequence of 1D arrays. All arrays must have the same", + " length.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.vstack((a,b))", + " array([[1, 2],", + " [2, 3],", + " [3, 4]])", + "", + " \"\"\"", + " arrays = map(Numeric.transpose,map(atleast_2d,tup))", + " return Numeric.concatenate(arrays,1)", + "", + "def dstack(tup):", + " \"\"\" Stack arrays in sequence depth wise (along third dimension)", + "", + " Description:", + " Take a sequence of arrays and stack them along the third axis.", + " All arrays in the sequence must have the same shape along all", + " but the third axis. This is a simple way to stack 2D arrays", + " (images) into a single 3D array for processing.", + " dstack will rebuild arrays divided by dsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.dstack((a,b))", + " array([ [[1, 2],", + " [2, 3],", + " [3, 4]]])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.dstack((a,b))", + " array([[ [1, 2]],", + " [ [2, 3]],", + " [ [3, 4]]])", + " \"\"\"", + " return Numeric.concatenate(map(atleast_3d,tup),2)", + "", + "def _replace_zero_by_x_arrays(sub_arys):", + " for i in range(len(sub_arys)):", + " if len(Numeric.shape(sub_arys[i])) == 0:", + " sub_arys[i] = Numeric.array([])", + " elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):", + " sub_arys[i] = Numeric.array([])", + " return sub_arys", + "", + "def array_split(ary,indices_or_sections,axis = 0):", + " \"\"\" Divide an array into a list of sub-arrays.", + "", + " Description:", + " Divide ary into a list of sub-arrays along the", + " specified axis. If indices_or_sections is an integer,", + " ary is divided into that many equally sized arrays.", + " If it is impossible to make an equal split, each of the", + " leading arrays in the list have one additional member. If", + " indices_or_sections is a list of sorted integers, its", + " entries define the indexes where ary is split.", + "", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " axis -- integer. default=0.", + " Specifies the axis along which to split ary.", + " Caveats:", + " Currently, the default for axis is 0. This", + " means a 2D array is divided into multiple groups", + " of rows. This seems like the appropriate default, but", + " we've agreed most other functions should default to", + " axis=-1. Perhaps we should use axis=-1 for consistency.", + " However, we could also make the argument that SciPy", + " works on \"rows\" by default. sum() sums up rows of", + " values. split() will split data into rows. Opinions?", + " \"\"\"", + " try:", + " Ntotal = ary.shape[axis]", + " except AttributeError:", + " Ntotal = len(ary)", + " try: # handle scalar case.", + " Nsections = len(indices_or_sections) + 1", + " div_points = [0] + list(indices_or_sections) + [Ntotal]", + " except TypeError: #indices_or_sections is a scalar, not an array.", + " Nsections = int(indices_or_sections)", + " if Nsections <= 0:", + " raise ValueError, 'number sections must be larger than 0.'", + " Neach_section,extras = divmod(Ntotal,Nsections)", + " section_sizes = [0] + \\", + " extras * [Neach_section+1] + \\", + " (Nsections-extras) * [Neach_section]", + " div_points = Numeric.add.accumulate(Numeric.array(section_sizes))", + "", + " sub_arys = []", + " sary = Numeric.swapaxes(ary,axis,0)", + " for i in range(Nsections):", + " st = div_points[i]; end = div_points[i+1]", + " sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))", + "", + " # there is a wierd issue with array slicing that allows", + " # 0x10 arrays and other such things. The following cluge is needed", + " # to get around this issue.", + " sub_arys = _replace_zero_by_x_arrays(sub_arys)", + " # end cluge.", + "", + " return sub_arys", + "", + "def split(ary,indices_or_sections,axis=0):", + " \"\"\" Divide an array into a list of sub-arrays.", + "", + " Description:", + " Divide ary into a list of sub-arrays along the", + " specified axis. If indices_or_sections is an integer,", + " ary is divided into that many equally sized arrays.", + " If it is impossible to make an equal split, an error is", + " raised. This is the only way this function differs from", + " the array_split() function. If indices_or_sections is a", + " list of sorted integers, its entries define the indexes", + " where ary is split.", + "", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " axis -- integer. default=0.", + " Specifies the axis along which to split ary.", + " Caveats:", + " Currently, the default for axis is 0. This", + " means a 2D array is divided into multiple groups", + " of rows. This seems like the appropriate default, but", + " we've agreed most other functions should default to", + " axis=-1. Perhaps we should use axis=-1 for consistency.", + " However, we could also make the argument that SciPy", + " works on \"rows\" by default. sum() sums up rows of", + " values. split() will split data into rows. Opinions?", + " \"\"\"", + " try: len(indices_or_sections)", + " except TypeError:", + " sections = indices_or_sections", + " N = ary.shape[axis]", + " if N % sections:", + " raise ValueError, 'array split does not result in an equal division'", + " res = array_split(ary,indices_or_sections,axis)", + " return res", + "", + "def hsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple columns of sub-arrays", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups of columns. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Related:", + " hstack, split, array_split, vsplit, dsplit.", + " Examples:", + " >>> import scipy", + " >>> a= array((1,2,3,4))", + " >>> scipy.hsplit(a,2)", + " [array([1, 2]), array([3, 4])]", + " >>> a = array([[1,2,3,4],[1,2,3,4]])", + " [array([[1, 2],", + " [1, 2]]), array([[3, 4],", + " [3, 4]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) == 0:", + " raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'", + " if len(ary.shape) > 1:", + " return split(ary,indices_or_sections,1)", + " else:", + " return split(ary,indices_or_sections,0)", + "", + "def vsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple rows of sub-arrays", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups of rows. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Caveats:", + " How should we handle 1D arrays here? I am currently raising", + " an error when I encounter them. Any better approach?", + "", + " Should we reduce the returned array to their minium dimensions", + " by getting rid of any dimensions that are 1?", + " Related:", + " vstack, split, array_split, hsplit, dsplit.", + " Examples:", + " import scipy", + " >>> a = array([[1,2,3,4],", + " ... [1,2,3,4]])", + " >>> scipy.vsplit(a)", + " [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) < 2:", + " raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'", + " return split(ary,indices_or_sections,0)", + "", + "def dsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups along the 3rd axis. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Caveats:", + " See vsplit caveats.", + " Related:", + " dstack, split, array_split, hsplit, vsplit.", + " Examples:", + " >>> a = array([[[1,2,3,4],[1,2,3,4]]])", + " [array([ [[1, 2],", + " [1, 2]]]), array([ [[3, 4],", + " [3, 4]]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) < 3:", + " raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'", + " return split(ary,indices_or_sections,2)", + "", + "#-----------------------------------------------------------------------------", + "# Test Routines", + "#-----------------------------------------------------------------------------", + "", + "def test(level=10):", + " from scipy_base.testing import module_test", + " module_test(__name__,__file__,level=level)", + "", + "def test_suite(level=1):", + " from scipy_base.testing import module_test_suite", + " return module_test_suite(__name__,__file__,level=level)", + "", + "if __name__ == '__main__':", + " test()" + ], + "deleted": [] + } + }, + { + "old_path": "scipy_base/testing.py", + "new_path": "scipy_base/testing.py", + "filename": "testing.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -1,4 +1,3 @@\n-\n import os,sys,time\n import unittest\n \n@@ -332,3 +331,14 @@ def output_exception():\n (filename, lineno, type.__name__, str(value), function)\n finally:\n type = value = tb = None # clean up\n+\n+def rand(*args):\n+ \"\"\" Returns an array of random numbers with the given shape.\n+ used for testing\n+ \"\"\"\n+ import whrandom\n+ results = zeros(args,Float64)\n+ f = results.flat\n+ for i in range(len(f)):\n+ f[i] = whrandom.random()\n+ return results \n", + "added_lines": 11, + "deleted_lines": 1, + "source_code": "import os,sys,time\nimport unittest\n\nclass ScipyTestCase (unittest.TestCase):\n\n def measure(self,code_str,times=1):\n frame = sys._getframe(1)\n locs,globs = frame.f_locals,frame.f_globals\n code = compile(code_str,\n 'ScipyTestCase runner for '+self.__class__.__name__,\n 'exec')\n i = 0\n elapsed = time.time()\n while i 0)\n+ return val == PINF\n+ \n+def isneginf(val):\n+ # complex not handled currently (and potentially ambiguous)\n+ #return Numeric.logical_and(isinf(val),val < 0)\n+ return val == MINF\n+ \n+def isinf(val):\n+ return Numeric.logical_or(isposinf(val),isneginf(val))\n+\n+def isfinite(val):\n+ vals = asarray(val)\n+ if array_iscomplex(vals):\n+ r = isfinite(real(vals))\n+ i = isfinite(imag(vals))\n+ results = Numeric.logical_and(r,i)\n+ else: \n+ fin = Numeric.logical_not(isinf(val))\n+ an = Numeric.logical_not(isnan(val))\n+ results = Numeric.logical_and(fin,an)\n+ return results \n+def nan_to_num(x):\n+ # mapping:\n+ # NaN -> 0\n+ # Inf -> limits.double_max\n+ # -Inf -> limits.double_min\n+ # complex not handled currently\n+ import limits\n+ try:\n+ t = x.typecode()\n+ except AttributeError:\n+ t = type(x)\n+ if t in [types.ComplexType,'F','D']: \n+ y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n+ else: \n+ x = Numeric.asarray(x)\n+ are_inf = isposinf(x)\n+ are_neg_inf = isneginf(x)\n+ are_nan = isnan(x)\n+ choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n+ y = Numeric.choose(choose_array,\n+ (x,limits.double_min, 0., limits.double_max))\n+ return y\n+\n+#-----------------------------------------------------------------------------\n+\n+def real_if_close(a,tol=1e-13):\n+ a = Numeric.asarray(a)\n+ if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):\n+ a = a.real\n+ return a\n+\n+\n+#-----------------------------------------------------------------------------\n+\n+_namefromtype = {'c' : 'character',\n+ '1' : 'signed char',\n+ 'b' : 'unsigned char',\n+ 's' : 'short',\n+ 'i' : 'integer',\n+ 'l' : 'long integer',\n+ 'f' : 'float',\n+ 'd' : 'double',\n+ 'F' : 'complex float',\n+ 'D' : 'complex double',\n+ 'O' : 'object'\n+ }\n+\n+def typename(char):\n+ \"\"\"Return an english name for the given typecode character.\n+ \"\"\"\n+ return _namefromtype[char]\n+\n+#-----------------------------------------------------------------------------\n+\n+#determine the \"minimum common type code\" for a group of arrays.\n+array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\n+array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\n+array_type = [['f', 'd'], ['F', 'D']]\n+def common_type(*arrays):\n+ kind = 0\n+ precision = 0\n+ for a in arrays:\n+ t = a.typecode()\n+ kind = max(kind, array_kind[t])\n+ precision = max(precision, array_precision[t])\n+ return array_type[kind][precision]\n+\n+#-----------------------------------------------------------------------------\n+# Test Routines\n+#-----------------------------------------------------------------------------\n+\n+def test(level=10):\n+ from scipy_base.testing import module_test\n+ module_test(__name__,__file__,level=level)\n+\n+def test_suite(level=1):\n+ from scipy_base.testing import module_test_suite\n+ return module_test_suite(__name__,__file__,level=level)\n+\n+if __name__ == '__main__':\n+ print 'float epsilon:',float_epsilon\n+ print 'float tiny:',float_tiny\n+ print 'double epsilon:',double_epsilon\n+ print 'double tiny:',double_tiny\n", + "added_lines": 193, + "deleted_lines": 0, + "source_code": "import types\nimport Numeric\nfrom Numeric import *\nfrom fastumath import *\n\nimport limits\n\n# For now, we'll use Tim Peter's IEEE module for NaN, Inf, -Inf comparison\n# stuff. Perhaps move to cephes in the future??\nfrom ieee_754 import PINF,MINF,NAN\n\n__all__ = ['ScalarType','array_iscomplex','array_isreal','imag','iscomplex',\n 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',\n 'isreal','isscalar','nan_to_num','real','real_if_close',\n 'typename']\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoInt = lambda x: Numeric.array(x, Numeric.Int)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\ntoComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n\ncast = {Numeric.Character: toChar,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef real(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.real\n else:\n return aval\n\ndef imag(val):\n aval = asarray(val)\n if aval.typecode() in ['F', 'D']:\n return aval.imag\n else:\n return array(0,aval.typecode())*aval\n\ndef iscomplex(x):\n return imag(x) != Numeric.zeros(asarray(x).shape)\n\ndef isreal(x):\n return imag(x) == Numeric.zeros(asarray(x).shape)\n\ndef array_iscomplex(x):\n return asarray(x).typecode() in ['F', 'D']\n\ndef array_isreal(x):\n return not asarray(x).typecode() in ['F', 'D']\n\n#-----------------------------------------------------------------------------\n\ndef isnan(val):\n # fast, but apparently not portable (according to notes by Tim Peters)\n #return val != val\n # very slow -- should really use cephes methods or *something* different\n import ieee_754\n vals = ravel(val)\n if array_iscomplex(vals):\n r = array(map(ieee_754.isnan,real(vals))) \n i = array(map(ieee_754.isnan,imag(vals)))\n results = Numeric.logical_or(r,i)\n else: \n results = array(map(ieee_754.isnan,vals))\n return results\n\ndef isposinf(val):\n # complex not handled currently (and potentially ambiguous)\n #return Numeric.logical_and(isinf(val),val > 0)\n return val == PINF\n \ndef isneginf(val):\n # complex not handled currently (and potentially ambiguous)\n #return Numeric.logical_and(isinf(val),val < 0)\n return val == MINF\n \ndef isinf(val):\n return Numeric.logical_or(isposinf(val),isneginf(val))\n\ndef isfinite(val):\n vals = asarray(val)\n if array_iscomplex(vals):\n r = isfinite(real(vals))\n i = isfinite(imag(vals))\n results = Numeric.logical_and(r,i)\n else: \n fin = Numeric.logical_not(isinf(val))\n an = Numeric.logical_not(isnan(val))\n results = Numeric.logical_and(fin,an)\n return results \ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> limits.double_max\n # -Inf -> limits.double_min\n # complex not handled currently\n import limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [types.ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = Numeric.asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,limits.double_min, 0., limits.double_max))\n return y\n\n#-----------------------------------------------------------------------------\n\ndef real_if_close(a,tol=1e-13):\n a = Numeric.asarray(a)\n if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):\n a = a.real\n return a\n\n\n#-----------------------------------------------------------------------------\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'i' : 'integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\n#-----------------------------------------------------------------------------\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": null, + "methods": [ + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "type_check.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 39, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "real", + "long_name": "real( val )", + "filename": "type_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "val" + ], + "start_line": 44, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "imag", + "long_name": "imag( val )", + "filename": "type_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 43, + "parameters": [ + "val" + ], + "start_line": 51, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "iscomplex", + "long_name": "iscomplex( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "x" + ], + "start_line": 58, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isreal", + "long_name": "isreal( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "x" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "array_iscomplex", + "long_name": "array_iscomplex( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x" + ], + "start_line": 64, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "array_isreal", + "long_name": "array_isreal( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "x" + ], + "start_line": 67, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isnan", + "long_name": "isnan( val )", + "filename": "type_check.py", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "val" + ], + "start_line": 72, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "isposinf", + "long_name": "isposinf( val )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "val" + ], + "start_line": 86, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isneginf", + "long_name": "isneginf( val )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "val" + ], + "start_line": 91, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "isinf", + "long_name": "isinf( val )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "val" + ], + "start_line": 96, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isfinite", + "long_name": "isfinite( val )", + "filename": "type_check.py", + "nloc": 11, + "complexity": 2, + "token_count": 81, + "parameters": [ + "val" + ], + "start_line": 99, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "nan_to_num", + "long_name": "nan_to_num( x )", + "filename": "type_check.py", + "nloc": 17, + "complexity": 3, + "token_count": 119, + "parameters": [ + "x" + ], + "start_line": 110, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "real_if_close", + "long_name": "real_if_close( a , tol = 1e - 13 )", + "filename": "type_check.py", + "nloc": 5, + "complexity": 3, + "token_count": 54, + "parameters": [ + "a", + "tol" + ], + "start_line": 135, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 157, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "type_check.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 168, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 181, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 185, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "real_if_close", + "long_name": "real_if_close( a , tol = 1e - 13 )", + "filename": "type_check.py", + "nloc": 5, + "complexity": 3, + "token_count": 54, + "parameters": [ + "a", + "tol" + ], + "start_line": 135, + "end_line": 139, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 157, + "end_line": 160, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "type_check.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 168, + "end_line": 175, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 185, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "type_check.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 181, + "end_line": 183, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "isinf", + "long_name": "isinf( val )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "val" + ], + "start_line": 96, + "end_line": 97, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isposinf", + "long_name": "isposinf( val )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "val" + ], + "start_line": 86, + "end_line": 89, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "iscomplex", + "long_name": "iscomplex( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "x" + ], + "start_line": 58, + "end_line": 59, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "type_check.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 39, + "end_line": 42, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "real", + "long_name": "real( val )", + "filename": "type_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 32, + "parameters": [ + "val" + ], + "start_line": 44, + "end_line": 49, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "isneginf", + "long_name": "isneginf( val )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "val" + ], + "start_line": 91, + "end_line": 94, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "array_isreal", + "long_name": "array_isreal( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 21, + "parameters": [ + "x" + ], + "start_line": 67, + "end_line": 68, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "array_iscomplex", + "long_name": "array_iscomplex( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 20, + "parameters": [ + "x" + ], + "start_line": 64, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "isnan", + "long_name": "isnan( val )", + "filename": "type_check.py", + "nloc": 10, + "complexity": 2, + "token_count": 78, + "parameters": [ + "val" + ], + "start_line": 72, + "end_line": 84, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "imag", + "long_name": "imag( val )", + "filename": "type_check.py", + "nloc": 6, + "complexity": 2, + "token_count": 43, + "parameters": [ + "val" + ], + "start_line": 51, + "end_line": 56, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "isfinite", + "long_name": "isfinite( val )", + "filename": "type_check.py", + "nloc": 11, + "complexity": 2, + "token_count": 81, + "parameters": [ + "val" + ], + "start_line": 99, + "end_line": 109, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isreal", + "long_name": "isreal( x )", + "filename": "type_check.py", + "nloc": 2, + "complexity": 1, + "token_count": 22, + "parameters": [ + "x" + ], + "start_line": 61, + "end_line": 62, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "nan_to_num", + "long_name": "nan_to_num( x )", + "filename": "type_check.py", + "nloc": 17, + "complexity": 3, + "token_count": 119, + "parameters": [ + "x" + ], + "start_line": 110, + "end_line": 131, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + } + ], + "nloc": 138, + "complexity": 29, + "token_count": 1104, + "diff_parsed": { + "added": [ + "import types", + "import Numeric", + "from Numeric import *", + "from fastumath import *", + "", + "import limits", + "", + "# For now, we'll use Tim Peter's IEEE module for NaN, Inf, -Inf comparison", + "# stuff. Perhaps move to cephes in the future??", + "from ieee_754 import PINF,MINF,NAN", + "", + "__all__ = ['ScalarType','array_iscomplex','array_isreal','imag','iscomplex',", + " 'isscalar','isneginf','isposinf','isnan','isinf','isfinite',", + " 'isreal','isscalar','nan_to_num','real','real_if_close',", + " 'typename']", + "", + "ScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]", + "", + "toChar = lambda x: Numeric.array(x, Numeric.Character)", + "toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte", + "toInt16 = lambda x: Numeric.array(x, Numeric.Int16)", + "toInt32 = lambda x: Numeric.array(x, Numeric.Int32)", + "toInt = lambda x: Numeric.array(x, Numeric.Int)", + "toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)", + "toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)", + "toComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)", + "toComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)", + "", + "cast = {Numeric.Character: toChar,", + " Numeric.Int8: toInt8,", + " Numeric.Int16: toInt16,", + " Numeric.Int32: toInt32,", + " Numeric.Int: toInt,", + " Numeric.Float32: toFloat32,", + " Numeric.Float64: toFloat64,", + " Numeric.Complex32: toComplex32,", + " Numeric.Complex64: toComplex64}", + "", + "def isscalar(num):", + " if isinstance(num, ArrayType):", + " return len(num.shape) == 0 and num.typecode() != 'O'", + " return type(num) in ScalarType", + "", + "def real(val):", + " aval = asarray(val)", + " if aval.typecode() in ['F', 'D']:", + " return aval.real", + " else:", + " return aval", + "", + "def imag(val):", + " aval = asarray(val)", + " if aval.typecode() in ['F', 'D']:", + " return aval.imag", + " else:", + " return array(0,aval.typecode())*aval", + "", + "def iscomplex(x):", + " return imag(x) != Numeric.zeros(asarray(x).shape)", + "", + "def isreal(x):", + " return imag(x) == Numeric.zeros(asarray(x).shape)", + "", + "def array_iscomplex(x):", + " return asarray(x).typecode() in ['F', 'D']", + "", + "def array_isreal(x):", + " return not asarray(x).typecode() in ['F', 'D']", + "", + "#-----------------------------------------------------------------------------", + "", + "def isnan(val):", + " # fast, but apparently not portable (according to notes by Tim Peters)", + " #return val != val", + " # very slow -- should really use cephes methods or *something* different", + " import ieee_754", + " vals = ravel(val)", + " if array_iscomplex(vals):", + " r = array(map(ieee_754.isnan,real(vals)))", + " i = array(map(ieee_754.isnan,imag(vals)))", + " results = Numeric.logical_or(r,i)", + " else:", + " results = array(map(ieee_754.isnan,vals))", + " return results", + "", + "def isposinf(val):", + " # complex not handled currently (and potentially ambiguous)", + " #return Numeric.logical_and(isinf(val),val > 0)", + " return val == PINF", + "", + "def isneginf(val):", + " # complex not handled currently (and potentially ambiguous)", + " #return Numeric.logical_and(isinf(val),val < 0)", + " return val == MINF", + "", + "def isinf(val):", + " return Numeric.logical_or(isposinf(val),isneginf(val))", + "", + "def isfinite(val):", + " vals = asarray(val)", + " if array_iscomplex(vals):", + " r = isfinite(real(vals))", + " i = isfinite(imag(vals))", + " results = Numeric.logical_and(r,i)", + " else:", + " fin = Numeric.logical_not(isinf(val))", + " an = Numeric.logical_not(isnan(val))", + " results = Numeric.logical_and(fin,an)", + " return results", + "def nan_to_num(x):", + " # mapping:", + " # NaN -> 0", + " # Inf -> limits.double_max", + " # -Inf -> limits.double_min", + " # complex not handled currently", + " import limits", + " try:", + " t = x.typecode()", + " except AttributeError:", + " t = type(x)", + " if t in [types.ComplexType,'F','D']:", + " y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)", + " else:", + " x = Numeric.asarray(x)", + " are_inf = isposinf(x)", + " are_neg_inf = isneginf(x)", + " are_nan = isnan(x)", + " choose_array = are_neg_inf + are_nan * 2 + are_inf * 3", + " y = Numeric.choose(choose_array,", + " (x,limits.double_min, 0., limits.double_max))", + " return y", + "", + "#-----------------------------------------------------------------------------", + "", + "def real_if_close(a,tol=1e-13):", + " a = Numeric.asarray(a)", + " if a.typecode() in ['F','D'] and Numeric.allclose(a.imag, 0, atol=tol):", + " a = a.real", + " return a", + "", + "", + "#-----------------------------------------------------------------------------", + "", + "_namefromtype = {'c' : 'character',", + " '1' : 'signed char',", + " 'b' : 'unsigned char',", + " 's' : 'short',", + " 'i' : 'integer',", + " 'l' : 'long integer',", + " 'f' : 'float',", + " 'd' : 'double',", + " 'F' : 'complex float',", + " 'D' : 'complex double',", + " 'O' : 'object'", + " }", + "", + "def typename(char):", + " \"\"\"Return an english name for the given typecode character.", + " \"\"\"", + " return _namefromtype[char]", + "", + "#-----------------------------------------------------------------------------", + "", + "#determine the \"minimum common type code\" for a group of arrays.", + "array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}", + "array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}", + "array_type = [['f', 'd'], ['F', 'D']]", + "def common_type(*arrays):", + " kind = 0", + " precision = 0", + " for a in arrays:", + " t = a.typecode()", + " kind = max(kind, array_kind[t])", + " precision = max(precision, array_precision[t])", + " return array_type[kind][precision]", + "", + "#-----------------------------------------------------------------------------", + "# Test Routines", + "#-----------------------------------------------------------------------------", + "", + "def test(level=10):", + " from scipy_base.testing import module_test", + " module_test(__name__,__file__,level=level)", + "", + "def test_suite(level=1):", + " from scipy_base.testing import module_test_suite", + " return module_test_suite(__name__,__file__,level=level)", + "", + "if __name__ == '__main__':", + " print 'float epsilon:',float_epsilon", + " print 'float tiny:',float_tiny", + " print 'double epsilon:',double_epsilon", + " print 'double tiny:',double_tiny" + ], + "deleted": [] + } + } + ] + }, + { + "hash": "fa4589795279e69c392eaf16d4182fc3bc3dbc58", + "msg": "removed functions specific to linalg", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-02T23:27:28+00:00", + "author_timezone": 0, + "committer_date": "2002-04-02T23:27:28+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "f897e1fc50d41e219b0868b1394dee9b118082d0" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 102, + "insertions": 1, + "lines": 103, + "files": 1, + "dmm_unit_size": 0.5862068965517241, + "dmm_unit_complexity": 0.0, + "dmm_unit_interfacing": 0.1724137931034483, + "modified_files": [ + { + "old_path": "scipy_base/matrix_base.py", + "new_path": "scipy_base/matrix_base.py", + "filename": "matrix_base.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -2,8 +2,7 @@\n \n \"\"\"\n \n-__all__ = ['diag','eye','fliplr','flipud','hankel','rot90','tri',\n- 'tril','triu','toeplitz','all_mat']\n+__all__ = ['diag','eye','fliplr','flipud','rot90']\n \n # These are from Numeric\n import Matrix\n@@ -49,20 +48,6 @@ def rot90(m, k=1):\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-\n-def tri(N, M=None, k=0, typecode=None):\n- \"\"\" returns a N-by-M matrix where all the diagonals starting from \n- lower left corner up to the k-th are all ones.\n- \"\"\"\n- if M is None: M = N\n- if type(M) == type('d'): \n- typecode = M\n- M = N\n- m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n- if typecode is None:\n- return m\n- else:\n- return m.astype(typecode)\n \n def eye(N, M=None, k=0, typecode=None):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n@@ -99,92 +84,6 @@ def diag(v, k=0):\n else:\n raise ValueError, \"Input must be 1- or 2-D.\"\n \n-#-----------------------------------------------------------------------------\n-# move all these\n-#-----------------------------------------------------------------------------\n-\n-def tril(m, k=0):\n- \"\"\" returns the elements on and below the k-th diagonal of m. k=0 is the\n- main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n- \"\"\"\n- svsp = m.spacesaver()\n- m = asarray(m,savespace=1)\n- out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n- out.savespace(svsp)\n- return out\n-\n-def triu(m, k=0):\n- \"\"\" returns the elements on and above the k-th diagonal of m. k=0 is the\n- main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n- \"\"\"\n- svsp = m.spacesaver()\n- m = asarray(m,savespace=1)\n- out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n- out.savespace(svsp)\n- return out\n-\n-def toeplitz(c,r=None):\n- \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).\n-\n- Description:\n-\n- toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first\n- column and r as its first row.\n-\n- toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). \n-\n- See also: hankel\n- \"\"\"\n- if isscalar(c) or isscalar(r):\n- return c \n- if r is None:\n- r = c\n- r[0] = conjugate(r[0])\n- c = conjugate(c)\n- r,c = map(asarray,(r,c))\n- r,c = map(ravel,(r,c))\n- rN,cN = map(len,(r,c))\n- if r[0] != c[0]:\n- print \"Warning: column and row values don't agree; column value used.\"\n- vals = r_[r[rN-1:0:-1], c]\n- cols = mgrid[0:cN]\n- rows = mgrid[rN:0:-1]\n- indx = cols[:,NewAxis]*ones((1,rN)) + \\\n- rows[NewAxis,:]*ones((cN,1)) - 1\n- return take(vals, indx)\n-\n-\n-def hankel(c,r=None):\n- \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).\n-\n- Description:\n-\n- hankel(c,r) is a Hankel matrix whose first column is c and whose\n- last row is r.\n-\n- hankel(c) is a square Hankel matrix whose first column is C.\n- Elements below the first anti-diagonal are zero.\n-\n- See also: toeplitz\n- \"\"\"\n- if isscalar(c) or isscalar(r):\n- return c \n- if r is None:\n- r = zeros(len(c))\n- elif r[0] != c[-1]:\n- print \"Warning: column and row values don't agree; column value used.\"\n- r,c = map(asarray,(r,c))\n- r,c = map(ravel,(r,c))\n- rN,cN = map(len,(r,c))\n- vals = r_[c, r[1:rN]]\n- cols = mgrid[1:cN+1]\n- rows = mgrid[0:rN]\n- indx = cols[:,NewAxis]*ones((1,rN)) + \\\n- rows[NewAxis,:]*ones((cN,1)) - 1\n- return take(vals, indx)\n-\n-def all_mat(args):\n- return map(Matrix.Matrix,args)\n \n #-----------------------------------------------------------------------------\n # Test Routines\n", + "added_lines": 1, + "deleted_lines": 102, + "source_code": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','rot90']\n \n# These are from Numeric\nimport Matrix\nfrom Numeric import *\nfrom fastumath import *\nfrom type_check import isscalar\nfrom index_tricks import mgrid,r_,c_\n# Elementary Matrices\n\n# zeros is from matrixmodule in C\n# ones is from Numeric.py\n\n \ndef fliplr(m):\n \"\"\" returns a 2-D matrix m with the rows preserved and columns flipped \n in the left/right direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[:, ::-1]\n\ndef flipud(m):\n \"\"\" returns a 2-D matrix with the columns preserved and rows flipped in\n the up/down direction. Only works with 2-D arrays.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n return m[::-1]\n \n# reshape(x, m, n) is not used, instead use reshape(x, (m, n))\n\ndef rot90(m, k=1):\n \"\"\" returns the matrix found by rotating m by k*90 degrees in the \n counterclockwise direction.\n \"\"\"\n m = asarray(m)\n if len(m.shape) != 2:\n raise ValueError, \"Input must be 2-D.\"\n k = k % 4\n if k == 0: return m\n elif k == 1: return transpose(fliplr(m))\n elif k == 2: return fliplr(flipud(m))\n else: return fliplr(transpose(m)) # k==3\n \ndef eye(N, M=None, k=0, typecode=None):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n and everything else is zeros.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n\ndef diag(v, k=0):\n \"\"\" returns the k-th diagonal if v is a matrix or returns a matrix \n with v as the k-th diagonal if v is a vector.\n \"\"\"\n v = asarray(v)\n s = v.shape\n if len(s)==1:\n n = s[0]+abs(k)\n if k > 0:\n v = concatenate((zeros(k, v.typecode()),v))\n elif k < 0:\n v = concatenate((v,zeros(-k, v.typecode())))\n return eye(n, k=k)*v\n elif len(s)==2:\n v = add.reduce(eye(s[0], s[1], k=k)*v)\n if k > 0: return v[k:]\n elif k < 0: return v[:k]\n else: return v\n else:\n raise ValueError, \"Input must be 1- or 2-D.\"\n\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": "\"\"\" Basic functions for manipulating 2d arrays\n\n\"\"\"\n\n__all__ = ['diag','eye','fliplr','flipud','hankel','rot90','tri',\n 'tril','triu','toeplitz','all_mat']\n \n# These are from Numeric\nimport Matrix\nfrom Numeric import *\nfrom fastumath import *\nfrom type_check import isscalar\nfrom index_tricks import mgrid,r_,c_\n# Elementary Matrices\n\n# zeros is from matrixmodule in C\n# ones is from Numeric.py\n\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 tri(N, M=None, k=0, typecode=None):\n \"\"\" returns a N-by-M matrix where all the diagonals starting from \n lower left corner up to the k-th are all ones.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = greater_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 eye(N, M=None, k=0, typecode=None):\n \"\"\" eye returns a N-by-M matrix where the k-th diagonal is all ones, \n and everything else is zeros.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n\ndef diag(v, k=0):\n \"\"\" returns the k-th diagonal if v is a matrix or returns a matrix \n with v as the k-th diagonal if v is a vector.\n \"\"\"\n v = asarray(v)\n s = v.shape\n if len(s)==1:\n n = s[0]+abs(k)\n if k > 0:\n v = concatenate((zeros(k, v.typecode()),v))\n elif k < 0:\n v = concatenate((v,zeros(-k, v.typecode())))\n return eye(n, k=k)*v\n elif len(s)==2:\n v = add.reduce(eye(s[0], s[1], k=k)*v)\n if k > 0: return v[k:]\n elif k < 0: return v[:k]\n else: return v\n else:\n raise ValueError, \"Input must be 1- or 2-D.\"\n\n#-----------------------------------------------------------------------------\n# move all these\n#-----------------------------------------------------------------------------\n\ndef tril(m, k=0):\n \"\"\" returns the elements on and below the k-th diagonal of m. k=0 is the\n main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n out.savespace(svsp)\n return out\n\ndef triu(m, k=0):\n \"\"\" returns the elements on and above the k-th diagonal of m. k=0 is the\n main diagonal, k > 0 is above and k < 0 is below the main diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n out.savespace(svsp)\n return out\n\ndef toeplitz(c,r=None):\n \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).\n\n Description:\n\n toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first\n column and r as its first row.\n\n toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). \n\n See also: hankel\n \"\"\"\n if isscalar(c) or isscalar(r):\n return c \n if r is None:\n r = c\n r[0] = conjugate(r[0])\n c = conjugate(c)\n r,c = map(asarray,(r,c))\n r,c = map(ravel,(r,c))\n rN,cN = map(len,(r,c))\n if r[0] != c[0]:\n print \"Warning: column and row values don't agree; column value used.\"\n vals = r_[r[rN-1:0:-1], c]\n cols = mgrid[0:cN]\n rows = mgrid[rN:0:-1]\n indx = cols[:,NewAxis]*ones((1,rN)) + \\\n rows[NewAxis,:]*ones((cN,1)) - 1\n return take(vals, indx)\n\n\ndef hankel(c,r=None):\n \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).\n\n Description:\n\n hankel(c,r) is a Hankel matrix whose first column is c and whose\n last row is r.\n\n hankel(c) is a square Hankel matrix whose first column is C.\n Elements below the first anti-diagonal are zero.\n\n See also: toeplitz\n \"\"\"\n if isscalar(c) or isscalar(r):\n return c \n if r is None:\n r = zeros(len(c))\n elif r[0] != c[-1]:\n print \"Warning: column and row values don't agree; column value used.\"\n r,c = map(asarray,(r,c))\n r,c = map(ravel,(r,c))\n rN,cN = map(len,(r,c))\n vals = r_[c, r[1:rN]]\n cols = mgrid[1:cN+1]\n rows = mgrid[0:rN]\n indx = cols[:,NewAxis]*ones((1,rN)) + \\\n rows[NewAxis,:]*ones((cN,1)) - 1\n return take(vals, indx)\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "methods": [ + { + "name": "fliplr", + "long_name": "fliplr( m )", + "filename": "matrix_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 35, + "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": "flipud", + "long_name": "flipud( m )", + "filename": "matrix_base.py", + "nloc": 5, + "complexity": 2, + "token_count": 33, + "parameters": [ + "m" + ], + "start_line": 28, + "end_line": 35, + "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": 39, + "end_line": 50, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "eye", + "long_name": "eye( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 52, + "end_line": 64, + "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": 66, + "end_line": 85, + "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": 92, + "end_line": 94, + "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": 96, + "end_line": 98, + "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": 20, + "end_line": 27, + "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": 29, + "end_line": 36, + "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": 40, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "tri", + "long_name": "tri( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 53, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "eye", + "long_name": "eye( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 67, + "end_line": 79, + "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": 81, + "end_line": 100, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 20, + "top_nesting_level": 0 + }, + { + "name": "tril", + "long_name": "tril( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 67, + "parameters": [ + "m", + "k" + ], + "start_line": 106, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "triu", + "long_name": "triu( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 69, + "parameters": [ + "m", + "k" + ], + "start_line": 116, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "toeplitz", + "long_name": "toeplitz( c , r = None )", + "filename": "matrix_base.py", + "nloc": 18, + "complexity": 5, + "token_count": 184, + "parameters": [ + "c", + "r" + ], + "start_line": 126, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "hankel", + "long_name": "hankel( c , r = None )", + "filename": "matrix_base.py", + "nloc": 16, + "complexity": 5, + "token_count": 167, + "parameters": [ + "c", + "r" + ], + "start_line": 157, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "matrix_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 186, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "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": 193, + "end_line": 195, + "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": 197, + "end_line": 199, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "hankel", + "long_name": "hankel( c , r = None )", + "filename": "matrix_base.py", + "nloc": 16, + "complexity": 5, + "token_count": 167, + "parameters": [ + "c", + "r" + ], + "start_line": 157, + "end_line": 184, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "matrix_base.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 186, + "end_line": 187, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "toeplitz", + "long_name": "toeplitz( c , r = None )", + "filename": "matrix_base.py", + "nloc": 18, + "complexity": 5, + "token_count": 184, + "parameters": [ + "c", + "r" + ], + "start_line": 126, + "end_line": 154, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 29, + "top_nesting_level": 0 + }, + { + "name": "tri", + "long_name": "tri( N , M = None , k = 0 , typecode = None )", + "filename": "matrix_base.py", + "nloc": 10, + "complexity": 4, + "token_count": 81, + "parameters": [ + "N", + "M", + "k", + "typecode" + ], + "start_line": 53, + "end_line": 65, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "triu", + "long_name": "triu( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 69, + "parameters": [ + "m", + "k" + ], + "start_line": 116, + "end_line": 124, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tril", + "long_name": "tril( m , k = 0 )", + "filename": "matrix_base.py", + "nloc": 6, + "complexity": 1, + "token_count": 67, + "parameters": [ + "m", + "k" + ], + "start_line": 106, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + } + ], + "nloc": 66, + "complexity": 22, + "token_count": 503, + "diff_parsed": { + "added": [ + "__all__ = ['diag','eye','fliplr','flipud','rot90']" + ], + "deleted": [ + "__all__ = ['diag','eye','fliplr','flipud','hankel','rot90','tri',", + " 'tril','triu','toeplitz','all_mat']", + "", + "def tri(N, M=None, k=0, typecode=None):", + " \"\"\" returns a N-by-M matrix where all the diagonals starting from", + " lower left corner up to the k-th are all ones.", + " \"\"\"", + " if M is None: M = N", + " if type(M) == type('d'):", + " typecode = M", + " M = N", + " m = greater_equal(subtract.outer(arange(N), arange(M)),-k)", + " if typecode is None:", + " return m", + " else:", + " return m.astype(typecode)", + "#-----------------------------------------------------------------------------", + "# move all these", + "#-----------------------------------------------------------------------------", + "", + "def tril(m, k=0):", + " \"\"\" returns the elements on and below the k-th diagonal of m. k=0 is the", + " main diagonal, k > 0 is above and k < 0 is below the main diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m", + " out.savespace(svsp)", + " return out", + "", + "def triu(m, k=0):", + " \"\"\" returns the elements on and above the k-th diagonal of m. k=0 is the", + " main diagonal, k > 0 is above and k < 0 is below the main diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m", + " out.savespace(svsp)", + " return out", + "", + "def toeplitz(c,r=None):", + " \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).", + "", + " Description:", + "", + " toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first", + " column and r as its first row.", + "", + " toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c).", + "", + " See also: hankel", + " \"\"\"", + " if isscalar(c) or isscalar(r):", + " return c", + " if r is None:", + " r = c", + " r[0] = conjugate(r[0])", + " c = conjugate(c)", + " r,c = map(asarray,(r,c))", + " r,c = map(ravel,(r,c))", + " rN,cN = map(len,(r,c))", + " if r[0] != c[0]:", + " print \"Warning: column and row values don't agree; column value used.\"", + " vals = r_[r[rN-1:0:-1], c]", + " cols = mgrid[0:cN]", + " rows = mgrid[rN:0:-1]", + " indx = cols[:,NewAxis]*ones((1,rN)) + \\", + " rows[NewAxis,:]*ones((cN,1)) - 1", + " return take(vals, indx)", + "", + "", + "def hankel(c,r=None):", + " \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).", + "", + " Description:", + "", + " hankel(c,r) is a Hankel matrix whose first column is c and whose", + " last row is r.", + "", + " hankel(c) is a square Hankel matrix whose first column is C.", + " Elements below the first anti-diagonal are zero.", + "", + " See also: toeplitz", + " \"\"\"", + " if isscalar(c) or isscalar(r):", + " return c", + " if r is None:", + " r = zeros(len(c))", + " elif r[0] != c[-1]:", + " print \"Warning: column and row values don't agree; column value used.\"", + " r,c = map(asarray,(r,c))", + " r,c = map(ravel,(r,c))", + " rN,cN = map(len,(r,c))", + " vals = r_[c, r[1:rN]]", + " cols = mgrid[1:cN+1]", + " rows = mgrid[0:rN]", + " indx = cols[:,NewAxis]*ones((1,rN)) + \\", + " rows[NewAxis,:]*ones((cN,1)) - 1", + " return take(vals, indx)", + "", + "def all_mat(args):", + " return map(Matrix.Matrix,args)" + ] + } + } + ] + }, + { + "hash": "3438848f9c2214395da97c53f3e71ef237262615", + "msg": "removing a few files that were placed here temporarily", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-02T23:29:48+00:00", + "author_timezone": 0, + "committer_date": "2002-04-02T23:29:48+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "fa4589795279e69c392eaf16d4182fc3bc3dbc58" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 1577, + "insertions": 0, + "lines": 1577, + "files": 3, + "dmm_unit_size": 0.4771838331160365, + "dmm_unit_complexity": 0.37157757496740546, + "dmm_unit_interfacing": 0.3468057366362451, + "modified_files": [ + { + "old_path": "scipy_base/convenience.py", + "new_path": null, + "filename": "convenience.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,526 +0,0 @@\n-\"\"\"Contains basic routines of common interest. Always imported first.\n- Basically MLab minus the LinearAlgebra-dependent functions.\n-\n- But max is changed to amax (array max)\n- and min is changed to amin (array min)\n- so that the builtin max and min are still available.\n-\"\"\"\n-\n-\n-__all__ = ['logspace','linspace','round','any','all','fix','mod','fftshift',\n- 'ifftshift','fftfreq','cont_ft','toeplitz','hankel','real','imag',\n- 'iscomplex','isreal','array_iscomplex','array_isreal','isposinf',\n- 'isneginf','nan_to_num','eye','tri','diag','fliplr','flipud',\n- 'rot90','tril','triu','amax','amin','ptp','cumsum','prod','cumprod',\n- 'diff','squeeze','sinc','angle','unwrap','real_if_close',\n- 'sort_complex']\n-\n-import Numeric\n-\n-def 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 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-\n-def 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 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-\n-#def round(arr):\n-# return Numeric.floor(arr+0.5)\n-round = Numeric.around\n-any = Numeric.sometrue\n-all = Numeric.alltrue\n-\n-def 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-\n-def 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-\n-def fftshift(x,axes=None):\n- \"\"\"Shift the result of an FFT operation.\n-\n- Return a shifted version of x (useful for obtaining centered spectra).\n- This function swaps \"half-spaces\" for all axes listed (defaults to all)\n- \"\"\"\n- ndim = len(x.shape)\n- if axes == None:\n- axes = range(ndim)\n- y = x\n- for k in axes:\n- N = x.shape[k]\n- p2 = int(Numeric.ceil(N/2.0))\n- mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n- y = Numeric.take(y,mylist,k)\n- return y\n-\n-def ifftshift(x,axes=None):\n- \"\"\"Reverse the effect of fftshift.\n- \"\"\"\n- ndim = len(x.shape)\n- if axes == None:\n- axes = range(ndim)\n- y = x\n- for k in axes:\n- N = x.shape[k]\n- p2 = int(Numeric.floor(N/2.0))\n- mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n- y = Numeric.take(y,mylist,k)\n- return y\n-\n-def fftfreq(N,sample=1.0):\n- \"\"\"FFT sample frequencies\n- \n- Return the frequency bins in cycles/unit (with zero at the start) given a\n- window length N and a sample spacing.\n- \"\"\"\n- N = int(N)\n- sample = float(sample)\n- return Numeric.concatenate((Numeric.arange(0,(N-1)/2+1,1,'d'),Numeric.arange(-(N-1)/2,0,1,'d')))/N/sample\n-\n-def cont_ft(gn,fr,delta=1.0,n=None):\n- \"\"\"Compute the (scaled) DFT of gn at frequencies fr.\n-\n- If the gn are alias-free samples of a continuous time function then the\n- correct value for the spacing, delta, will give the properly scaled,\n- continuous Fourier spectrum.\n-\n- The DFT is obtained when delta=1.0\n- \"\"\"\n- if n is None:\n- n = Numeric.arange(len(gn))\n- dT = delta\n- trans_kernel = Numeric.exp(-2j*Numeric.pi*fr[:,Numeric.NewAxis]*dT*n)\n- return dT*Numeric.dot(trans_kernel,gn)\n-\n-def toeplitz(c,r=None):\n- \"\"\"Construct a toeplitz matrix (i.e. a matrix with constant diagonals).\n-\n- Description:\n-\n- toeplitz(c,r) is a non-symmetric Toeplitz matrix with c as its first\n- column and r as its first row.\n-\n- toeplitz(c) is a symmetric (Hermitian) Toeplitz matrix (r=c). \n-\n- See also: hankel\n- \"\"\"\n- if isscalar(c) or isscalar(r):\n- return c \n- if r is None:\n- r = c\n- r[0] = Numeric.conjugate(r[0])\n- c = Numeric.conjugate(c)\n- r,c = map(Numeric.asarray,(r,c))\n- r,c = map(Numeric.ravel,(r,c))\n- rN,cN = map(len,(r,c))\n- if r[0] != c[0]:\n- print \"Warning: column and row values don't agree; column value used.\"\n- vals = r_[r[rN-1:0:-1], c]\n- cols = grid[0:cN]\n- rows = grid[rN:0:-1]\n- indx = cols[:,Numeric.NewAxis]*Numeric.ones((1,rN)) + \\\n- rows[Numeric.NewAxis,:]*Numeric.ones((cN,1)) - 1\n- return Numeric.take(vals, indx)\n-\n-\n-def hankel(c,r=None):\n- \"\"\"Construct a hankel matrix (i.e. matrix with constant anti-diagonals).\n-\n- Description:\n-\n- hankel(c,r) is a Hankel matrix whose first column is c and whose\n- last row is r.\n-\n- hankel(c) is a square Hankel matrix whose first column is C.\n- Elements below the first anti-diagonal are zero.\n-\n- See also: toeplitz\n- \"\"\"\n- if isscalar(c) or isscalar(r):\n- return c \n- if r is None:\n- r = Numeric.zeros(len(c))\n- elif r[0] != c[-1]:\n- print \"Warning: column and row values don't agree; column value used.\"\n- r,c = map(Numeric.asarray,(r,c))\n- r,c = map(Numeric.ravel,(r,c))\n- rN,cN = map(len,(r,c))\n- vals = r_[c, r[1:rN]]\n- cols = grid[1:cN+1]\n- rows = grid[0:rN]\n- indx = cols[:,Numeric.NewAxis]*Numeric.ones((1,rN)) + \\\n- rows[Numeric.NewAxis,:]*Numeric.ones((cN,1)) - 1\n- return Numeric.take(vals, indx)\n-\n-\n-def real(val):\n- aval = asarray(val)\n- if aval.typecode() in ['F', 'D']:\n- return aval.real\n- else:\n- return aval\n-\n-def imag(val):\n- aval = asarray(val)\n- if aval.typecode() in ['F', 'D']:\n- return aval.imag\n- else:\n- return array(0,aval.typecode())*aval\n-\n-def iscomplex(x):\n- return imag(x) != Numeric.zeros(asarray(x).shape)\n-\n-def isreal(x):\n- return imag(x) == Numeric.zeros(asarray(x).shape)\n-\n-def array_iscomplex(x):\n- return asarray(x).typecode() in ['F', 'D']\n-\n-def array_isreal(x):\n- return not asarray(x).typecode() in ['F', 'D']\n-\n-def isposinf(val):\n- # complex not handled currently (and potentially ambiguous)\n- return Numeric.logical_and(isinf(val),val > 0)\n-\n-def isneginf(val):\n- # complex not handled currently (and potentially ambiguous)\n- return Numeric.logical_and(isinf(val),val < 0)\n- \n-def nan_to_num(x):\n- # mapping:\n- # NaN -> 0\n- # Inf -> scipy.limits.double_max\n- # -Inf -> scipy.limits.double_min\n- # complex not handled currently\n- import limits\n- try:\n- t = x.typecode()\n- except AttributeError:\n- t = type(x)\n- if t in [ComplexType,'F','D']: \n- y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n- else: \n- x = Numeric.asarray(x)\n- are_inf = isposinf(x)\n- are_neg_inf = isneginf(x)\n- are_nan = isnan(x)\n- choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n- y = Numeric.choose(choose_array,\n- (x,scipy.limits.double_min, 0., scipy.limits.double_max))\n- return y\n-\n-# These are from Numeric\n-from Numeric import *\n-import Numeric\n-import Matrix\n-from utility import isscalar\n-from fastumath import *\n-\n-\n-# Elementary Matrices\n-\n-# zeros is from matrixmodule in C\n-# ones is from Numeric.py\n-\n-\n-def eye(N, M=None, k=0, typecode=None):\n- \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the \n- k-th diagonal is all ones, 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-\n-def tri(N, M=None, k=0, typecode=None):\n- \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all\n- the diagonals starting from lower left corner up to the k-th are all ones.\n- \"\"\"\n- if M is None: M = N\n- if type(M) == type('d'): \n- typecode = M\n- M = N\n- m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n- if typecode is None:\n- return m\n- else:\n- return m.astype(typecode)\n- \n-# Matrix manipulation\n-\n-def diag(v, k=0):\n- \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or\n- returns a matrix 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-def fliplr(m):\n- \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and\n- columns flipped in the left/right direction. Only works with 2-D\n- 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-def flipud(m):\n- \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and\n- rows flipped in 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-\n-def rot90(m, k=1):\n- \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees\n- in the 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-\n-def tril(m, k=0):\n- \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of\n- m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n- diagonal.\n- \"\"\"\n- svsp = m.spacesaver()\n- m = asarray(m,savespace=1)\n- out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n- out.savespace(svsp)\n- return out\n-\n-def triu(m, k=0):\n- \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of\n- m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n- diagonal.\n- \"\"\"\n- svsp = m.spacesaver()\n- m = asarray(m,savespace=1)\n- out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n- out.savespace(svsp)\n- return out\n-\n-# Data analysis\n-\n-# Basic operations\n-def 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-\n-def 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-\n-def 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-\n-def 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-\n-def 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-\n-def 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-\n-def 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-def squeeze(a):\n- \"Returns a with any ones from the shape of a removed\"\n- a = asarray(a)\n- b = asarray(a.shape)\n- return reshape (a, tuple (compress (not_equal (b, 1), b)))\n-\n-def sinc(x):\n- \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.\n- \"\"\"\n- w = asarray(x*pi)\n- return where(x==0, 1.0, sin(w)/w)\n-\n-def 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-\n-import copy\n-def unwrap(p,discont=pi,axis=-1):\n- \"\"\"unwrap(p,discont=pi,axis=-1)\n-\n- unwraps radian phase p by changing absolute jumps greater than discont to\n- 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) 0)\n\ndef isneginf(val):\n # complex not handled currently (and potentially ambiguous)\n return Numeric.logical_and(isinf(val),val < 0)\n \ndef nan_to_num(x):\n # mapping:\n # NaN -> 0\n # Inf -> scipy.limits.double_max\n # -Inf -> scipy.limits.double_min\n # complex not handled currently\n import limits\n try:\n t = x.typecode()\n except AttributeError:\n t = type(x)\n if t in [ComplexType,'F','D']: \n y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)\n else: \n x = Numeric.asarray(x)\n are_inf = isposinf(x)\n are_neg_inf = isneginf(x)\n are_nan = isnan(x)\n choose_array = are_neg_inf + are_nan * 2 + are_inf * 3\n y = Numeric.choose(choose_array,\n (x,scipy.limits.double_min, 0., scipy.limits.double_max))\n return y\n\n# These are from Numeric\nfrom Numeric import *\nimport Numeric\nimport Matrix\nfrom utility import isscalar\nfrom fastumath import *\n\n\n# Elementary Matrices\n\n# zeros is from matrixmodule in C\n# ones is from Numeric.py\n\n\ndef eye(N, M=None, k=0, typecode=None):\n \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the \n k-th diagonal is all ones, 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 tri(N, M=None, k=0, typecode=None):\n \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all\n the diagonals starting from lower left corner up to the k-th are all ones.\n \"\"\"\n if M is None: M = N\n if type(M) == type('d'): \n typecode = M\n M = N\n m = greater_equal(subtract.outer(arange(N), arange(M)),-k)\n if typecode is None:\n return m\n else:\n return m.astype(typecode)\n \n# Matrix manipulation\n\ndef diag(v, k=0):\n \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or\n returns a matrix 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 \ndef fliplr(m):\n \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and\n columns flipped in the left/right direction. Only works with 2-D\n 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 \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and\n rows flipped in 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 \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees\n in the 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 tril(m, k=0):\n \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m\n out.savespace(svsp)\n return out\n\ndef triu(m, k=0):\n \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of\n m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main\n diagonal.\n \"\"\"\n svsp = m.spacesaver()\n m = asarray(m,savespace=1)\n out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m\n out.savespace(svsp)\n return out\n\n# Data analysis\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\ndef squeeze(a):\n \"Returns a with any ones from the shape of a removed\"\n a = asarray(a)\n b = asarray(a.shape)\n return reshape (a, tuple (compress (not_equal (b, 1), b)))\n\ndef sinc(x):\n \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.\n \"\"\"\n w = asarray(x*pi)\n return where(x==0, 1.0, sin(w)/w)\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\nimport copy\ndef unwrap(p,discont=pi,axis=-1):\n \"\"\"unwrap(p,discont=pi,axis=-1)\n\n unwraps radian phase p by changing absolute jumps greater than discont to\n 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) 0)", + "", + "def isneginf(val):", + " # complex not handled currently (and potentially ambiguous)", + " return Numeric.logical_and(isinf(val),val < 0)", + "", + "def nan_to_num(x):", + " # mapping:", + " # NaN -> 0", + " # Inf -> scipy.limits.double_max", + " # -Inf -> scipy.limits.double_min", + " # complex not handled currently", + " import limits", + " try:", + " t = x.typecode()", + " except AttributeError:", + " t = type(x)", + " if t in [ComplexType,'F','D']:", + " y = nan_to_num(x.real) + 1j * nan_to_num(x.imag)", + " else:", + " x = Numeric.asarray(x)", + " are_inf = isposinf(x)", + " are_neg_inf = isneginf(x)", + " are_nan = isnan(x)", + " choose_array = are_neg_inf + are_nan * 2 + are_inf * 3", + " y = Numeric.choose(choose_array,", + " (x,scipy.limits.double_min, 0., scipy.limits.double_max))", + " return y", + "", + "# These are from Numeric", + "from Numeric import *", + "import Numeric", + "import Matrix", + "from utility import isscalar", + "from fastumath import *", + "", + "", + "# Elementary Matrices", + "", + "# zeros is from matrixmodule in C", + "# ones is from Numeric.py", + "", + "", + "def eye(N, M=None, k=0, typecode=None):", + " \"\"\"eye(N, M=N, k=0, typecode=None) returns a N-by-M matrix where the", + " k-th diagonal is all ones, and everything else is zeros.", + " \"\"\"", + " if M is None: M = N", + " if type(M) == type('d'):", + " typecode = M", + " M = N", + " m = equal(subtract.outer(arange(N), arange(M)),-k)", + " if typecode is None:", + " return m", + " else:", + " return m.astype(typecode)", + "", + "def tri(N, M=None, k=0, typecode=None):", + " \"\"\"tri(N, M=N, k=0, typecode=None) returns a N-by-M matrix where all", + " the diagonals starting from lower left corner up to the k-th are all ones.", + " \"\"\"", + " if M is None: M = N", + " if type(M) == type('d'):", + " typecode = M", + " M = N", + " m = greater_equal(subtract.outer(arange(N), arange(M)),-k)", + " if typecode is None:", + " return m", + " else:", + " return m.astype(typecode)", + "", + "# Matrix manipulation", + "", + "def diag(v, k=0):", + " \"\"\"diag(v,k=0) returns the k-th diagonal if v is a matrix or", + " returns a matrix with v as the k-th diagonal if v is a vector.", + " \"\"\"", + " v = asarray(v)", + " s = v.shape", + " if len(s)==1:", + " n = s[0]+abs(k)", + " if k > 0:", + " v = concatenate((zeros(k, v.typecode()),v))", + " elif k < 0:", + " v = concatenate((v,zeros(-k, v.typecode())))", + " return eye(n, k=k)*v", + " elif len(s)==2:", + " v = add.reduce(eye(s[0], s[1], k=k)*v)", + " if k > 0: return v[k:]", + " elif k < 0: return v[:k]", + " else: return v", + " else:", + " raise ValueError, \"Input must be 1- or 2-D.\"", + "", + "def fliplr(m):", + " \"\"\"fliplr(m) returns a 2-D matrix m with the rows preserved and", + " columns flipped in the left/right direction. Only works with 2-D", + " arrays.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " return m[:, ::-1]", + "", + "def flipud(m):", + " \"\"\"flipud(m) returns a 2-D matrix with the columns preserved and", + " rows flipped in the up/down direction. Only works with 2-D arrays.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " return m[::-1]", + "", + "# reshape(x, m, n) is not used, instead use reshape(x, (m, n))", + "", + "def rot90(m, k=1):", + " \"\"\"rot90(m,k=1) returns the matrix found by rotating m by k*90 degrees", + " in the counterclockwise direction.", + " \"\"\"", + " m = asarray(m)", + " if len(m.shape) != 2:", + " raise ValueError, \"Input must be 2-D.\"", + " k = k % 4", + " if k == 0: return m", + " elif k == 1: return transpose(fliplr(m))", + " elif k == 2: return fliplr(flipud(m))", + " else: return fliplr(transpose(m)) # k==3", + "", + "def tril(m, k=0):", + " \"\"\"tril(m,k=0) returns the elements on and below the k-th diagonal of", + " m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main", + " diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = tri(m.shape[0], m.shape[1], k=k, typecode=m.typecode())*m", + " out.savespace(svsp)", + " return out", + "", + "def triu(m, k=0):", + " \"\"\"triu(m,k=0) returns the elements on and above the k-th diagonal of", + " m. k=0 is the main diagonal, k > 0 is above and k < 0 is below the main", + " diagonal.", + " \"\"\"", + " svsp = m.spacesaver()", + " m = asarray(m,savespace=1)", + " out = (1-tri(m.shape[0], m.shape[1], k-1, m.typecode()))*m", + " out.savespace(svsp)", + " return out", + "", + "# Data analysis", + "", + "# Basic operations", + "def amax(m,axis=-1):", + " \"\"\"Returns the maximum of m along dimension axis.", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return maximum.reduce(m,axis)", + "", + "def amin(m,axis=-1):", + " \"\"\"Returns the minimum of m along dimension axis.", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return minimum.reduce(m,axis)", + "", + "# Actually from Basis, but it fits in so naturally here...", + "", + "def ptp(m,axis=-1):", + " \"\"\"Returns the maximum - minimum along the the given dimension", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return amax(m,axis)-amin(m,axis)", + "", + "def cumsum(m,axis=-1):", + " \"\"\"Returns the cumulative sum of the elements along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return add.accumulate(m,axis)", + "", + "def prod(m,axis=-1):", + " \"\"\"Returns the product of the elements along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return multiply.reduce(m,axis)", + "", + "def cumprod(m,axis=-1):", + " \"\"\"Returns the cumulative product of the elments along the given axis", + " \"\"\"", + " if axis is None:", + " m = ravel(m)", + " axis = 0", + " else:", + " m = asarray(m)", + " return multiply.accumulate(m,axis)", + "", + "def diff(x, n=1,axis=-1):", + " \"\"\"Calculates the nth order, discrete difference along given axis.", + " \"\"\"", + " x = asarray(x)", + " nd = len(x.shape)", + " slice1 = [slice(None)]*nd", + " slice2 = [slice(None)]*nd", + " slice1[axis] = slice(1,None)", + " slice2[axis] = slice(None,-1)", + " if n > 1:", + " return diff(x[slice1]-x[slice2], n-1, axis=axis)", + " else:", + " return x[slice1]-x[slice2]", + "", + "def squeeze(a):", + " \"Returns a with any ones from the shape of a removed\"", + " a = asarray(a)", + " b = asarray(a.shape)", + " return reshape (a, tuple (compress (not_equal (b, 1), b)))", + "", + "def sinc(x):", + " \"\"\"Returns sin(pi*x)/(pi*x) at all points of array x.", + " \"\"\"", + " w = asarray(x*pi)", + " return where(x==0, 1.0, sin(w)/w)", + "", + "def angle(z,deg=0):", + " \"\"\"Return the angle of complex argument z.\"\"\"", + " if deg:", + " fact = 180/pi", + " else:", + " fact = 1.0", + " z = asarray(z)", + " if z.typecode() in ['D','F']:", + " zimag = z.imag", + " zreal = z.real", + " else:", + " zimag = 0", + " zreal = z", + " return arctan2(zimag,zreal) * fact", + "", + "import copy", + "def unwrap(p,discont=pi,axis=-1):", + " \"\"\"unwrap(p,discont=pi,axis=-1)", + "", + " unwraps radian phase p by changing absolute jumps greater than discont to", + " their 2*pi complement along the given axis.", + " \"\"\"", + " p = asarray(p)", + " nd = len(p.shape)", + " dd = diff(p,axis=axis)", + " slice1 = [slice(None,None)]*nd # full slices", + " slice1[axis] = slice(1,None)", + " ddmod = mod(dd+pi,2*pi)-pi", + " putmask(ddmod,(ddmod==-pi) & (dd > 0),pi)", + " ph_correct = ddmod - dd;", + " putmask(ph_correct,abs(dd) width:\n- k = firstwidth + 1 + len(argument)\n- newstr = newstr + \",\\n\" + \" \"*(firstwidth+2) + argument\n- else:\n- newstr = newstr + addstr + argument\n- return newstr\n-\n-_namedict = None\n-_dictlist = None\n-\n-# Traverse all module directories underneath globals to see if something is defined\n-def makenamedict():\n- import scipy\n- thedict = {'scipy':scipy.__dict__}\n- dictlist = ['scipy']\n- totraverse = [scipy.__dict__]\n- while 1:\n- if len(totraverse) == 0:\n- break\n- thisdict = totraverse.pop(0)\n- for x in thisdict.keys():\n- if isinstance(thisdict[x],types.ModuleType):\n- modname = thisdict[x].__name__\n- if modname not in dictlist:\n- moddict = thisdict[x].__dict__\n- dictlist.append(modname)\n- totraverse.append(moddict)\n- thedict[modname] = moddict\n- return thedict, dictlist\n-\n-\n-def help(object=None,maxwidth=76,output=sys.stdout,):\n- \"\"\"Get help information for a function, class, or module.\n- \n- Example:\n- >>> from scipy import * \n- >>> help(polyval)\n- polyval(p, x)\n- \n- Evaluate the polymnomial p at x.\n- \n- Description: \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- global _namedict, _dictlist\n- if object is None: \n- help(help)\n- elif isinstance(object, types.StringType):\n- if _namedict is None:\n- _namedict, _dictlist = makenamedict()\n- numfound = 0\n- objlist = []\n- for namestr in _dictlist:\n- try:\n- obj = _namedict[namestr][object]\n- if id(obj) in objlist:\n- print >> output, \"\\n *** Repeat reference found in %s *** \" % namestr\n- else:\n- objlist.append(id(obj))\n- print >> output, \" *** Found in %s ***\" % namestr\n- help(obj)\n- print >> output, \"-\"*maxwidth\n- numfound += 1\n- except KeyError:\n- pass\n- if numfound == 0:\n- print >> output, \"Help for %s not found.\" % object\n- else:\n- print >> output, \"\\n *** Total of %d references found. ***\" % numfound\n- \n- elif inspect.isfunction(object):\n- name = object.func_name\n- arguments = apply(inspect.formatargspec, inspect.getargspec(object))\n-\n- if len(name+arguments) > maxwidth:\n- argstr = split_line(name, arguments, maxwidth)\n- else:\n- argstr = name + arguments\n-\n- print >> output, \" \" + argstr + \"\\n\"\n- print >> output, inspect.getdoc(object)\n-\n- elif inspect.isclass(object): \n- name = object.__name__\n- if hasattr(object, '__init__'):\n- arguments = apply(inspect.formatargspec, inspect.getargspec(object.__init__.im_func)) \n- arglist = arguments.split(', ')\n- if len(arglist) > 1:\n- arglist[1] = \"(\"+arglist[1]\n- arguments = \", \".join(arglist[1:])\n- else:\n- arguments = \"()\"\n- else:\n- arguments = \"()\"\n-\n- if len(name+arguments) > maxwidth:\n- argstr = split_line(name, arguments, maxwidth)\n- else:\n- argstr = name + arguments\n-\n- print >> output, \" \" + argstr + \"\\n\"\n- doc1 = inspect.getdoc(object) \n- if doc1 is None:\n- if hasattr(object,'__init__'):\n- print >> output, inspect.getdoc(object.__init__)\n- else:\n- print >> output, inspect.getdoc(object)\n-\n- elif type(object) is types.InstanceType: ## check for __call__ method\n- print >> output, \"Instance of class: \", object.__class__.__name__\n- print >> output\n- if hasattr(object, '__call__'):\n- arguments = apply(inspect.formatargspec, inspect.getargspec(object.__call__.im_func))\n- arglist = arguments.split(', ')\n- if len(arglist) > 1:\n- arglist[1] = \"(\"+arglist[1]\n- arguments = \", \".join(arglist[1:])\n- else:\n- arguments = \"()\"\n-\n- name = \"\"\n- if len(name+arguments) > maxwidth:\n- argstr = split_line(name, arguments, maxwidth)\n- else:\n- argstr = name + arguments\n-\n- print >> output, \" \" + argstr + \"\\n\"\n- doc = inspect.getdoc(object.__call__)\n- if doc is not None:\n- print >> output, inspect.getdoc(object.__call__)\n- print >> output, inspect.getdoc(object)\n- \n- else:\n- print >> output, inspect.getdoc(object)\n- \n- elif inspect.ismethod(object):\n- name = object.__name__\n- arguments = apply(inspect.formatargspec, inspect.getargspec(object.im_func))\n- arglist = arguments.split(', ')\n- if len(arglist) > 1:\n- arglist[1] = \"(\"+arglist[1]\n- arguments = \", \".join(arglist[1:])\n- else:\n- arguments = \"()\"\n-\n- if len(name+arguments) > maxwidth:\n- argstr = split_line(name, arguments, maxwidth)\n- else:\n- argstr = name + arguments\n-\n- print >> output, \" \" + argstr + \"\\n\"\n- print >> output, inspect.getdoc(object)\n- \n- elif hasattr(object, '__doc__'):\n- print >> output, inspect.getdoc(object)\n- \n-\n-def source(object, output=sys.stdout):\n- if inspect.isroutine(object):\n- print >> output, \"In file: %s\\n\" % inspect.getsourcefile(object)\n- print >> output, inspect.getsource(object)\n- else:\n- print >> output, \"Not available for this object.\"\n", + "added_lines": 0, + "deleted_lines": 186, + "source_code": null, + "source_code_before": "import inspect\nimport types\nimport sys, os\n\n# NOTE: pydoc defines a help function which works simliarly to this\n# except it uses a pager to take over the screen.\n\n# combine name and arguments and split to multiple lines of\n# width characters. End lines on a comma and begin argument list\n# indented with the rest of the arguments.\ndef split_line(name, arguments, width):\n firstwidth = len(name)\n k = firstwidth\n newstr = name\n sepstr = \", \"\n arglist = arguments.split(sepstr)\n for argument in arglist:\n if k == firstwidth:\n addstr = \"\"\n else:\n addstr = sepstr\n k = k + len(argument) + len(addstr)\n if k > width:\n k = firstwidth + 1 + len(argument)\n newstr = newstr + \",\\n\" + \" \"*(firstwidth+2) + argument\n else:\n newstr = newstr + addstr + argument\n return newstr\n\n_namedict = None\n_dictlist = None\n\n# Traverse all module directories underneath globals to see if something is defined\ndef makenamedict():\n import scipy\n thedict = {'scipy':scipy.__dict__}\n dictlist = ['scipy']\n totraverse = [scipy.__dict__]\n while 1:\n if len(totraverse) == 0:\n break\n thisdict = totraverse.pop(0)\n for x in thisdict.keys():\n if isinstance(thisdict[x],types.ModuleType):\n modname = thisdict[x].__name__\n if modname not in dictlist:\n moddict = thisdict[x].__dict__\n dictlist.append(modname)\n totraverse.append(moddict)\n thedict[modname] = moddict\n return thedict, dictlist\n\n\ndef help(object=None,maxwidth=76,output=sys.stdout,):\n \"\"\"Get help information for a function, class, or module.\n \n Example:\n >>> from scipy import * \n >>> help(polyval)\n polyval(p, x)\n \n Evaluate the polymnomial p at x.\n \n Description: \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 global _namedict, _dictlist\n if object is None: \n help(help)\n elif isinstance(object, types.StringType):\n if _namedict is None:\n _namedict, _dictlist = makenamedict()\n numfound = 0\n objlist = []\n for namestr in _dictlist:\n try:\n obj = _namedict[namestr][object]\n if id(obj) in objlist:\n print >> output, \"\\n *** Repeat reference found in %s *** \" % namestr\n else:\n objlist.append(id(obj))\n print >> output, \" *** Found in %s ***\" % namestr\n help(obj)\n print >> output, \"-\"*maxwidth\n numfound += 1\n except KeyError:\n pass\n if numfound == 0:\n print >> output, \"Help for %s not found.\" % object\n else:\n print >> output, \"\\n *** Total of %d references found. ***\" % numfound\n \n elif inspect.isfunction(object):\n name = object.func_name\n arguments = apply(inspect.formatargspec, inspect.getargspec(object))\n\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n print >> output, inspect.getdoc(object)\n\n elif inspect.isclass(object): \n name = object.__name__\n if hasattr(object, '__init__'):\n arguments = apply(inspect.formatargspec, inspect.getargspec(object.__init__.im_func)) \n arglist = arguments.split(', ')\n if len(arglist) > 1:\n arglist[1] = \"(\"+arglist[1]\n arguments = \", \".join(arglist[1:])\n else:\n arguments = \"()\"\n else:\n arguments = \"()\"\n\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n doc1 = inspect.getdoc(object) \n if doc1 is None:\n if hasattr(object,'__init__'):\n print >> output, inspect.getdoc(object.__init__)\n else:\n print >> output, inspect.getdoc(object)\n\n elif type(object) is types.InstanceType: ## check for __call__ method\n print >> output, \"Instance of class: \", object.__class__.__name__\n print >> output\n if hasattr(object, '__call__'):\n arguments = apply(inspect.formatargspec, inspect.getargspec(object.__call__.im_func))\n arglist = arguments.split(', ')\n if len(arglist) > 1:\n arglist[1] = \"(\"+arglist[1]\n arguments = \", \".join(arglist[1:])\n else:\n arguments = \"()\"\n\n name = \"\"\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n doc = inspect.getdoc(object.__call__)\n if doc is not None:\n print >> output, inspect.getdoc(object.__call__)\n print >> output, inspect.getdoc(object)\n \n else:\n print >> output, inspect.getdoc(object)\n \n elif inspect.ismethod(object):\n name = object.__name__\n arguments = apply(inspect.formatargspec, inspect.getargspec(object.im_func))\n arglist = arguments.split(', ')\n if len(arglist) > 1:\n arglist[1] = \"(\"+arglist[1]\n arguments = \", \".join(arglist[1:])\n else:\n arguments = \"()\"\n\n if len(name+arguments) > maxwidth:\n argstr = split_line(name, arguments, maxwidth)\n else:\n argstr = name + arguments\n\n print >> output, \" \" + argstr + \"\\n\"\n print >> output, inspect.getdoc(object)\n \n elif hasattr(object, '__doc__'):\n print >> output, inspect.getdoc(object)\n \n\ndef source(object, output=sys.stdout):\n if inspect.isroutine(object):\n print >> output, \"In file: %s\\n\" % inspect.getsourcefile(object)\n print >> output, inspect.getsource(object)\n else:\n print >> output, \"Not available for this object.\"\n", + "methods": [], + "methods_before": [ + { + "name": "split_line", + "long_name": "split_line( name , arguments , width )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 4, + "token_count": 104, + "parameters": [ + "name", + "arguments", + "width" + ], + "start_line": 11, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "makenamedict", + "long_name": "makenamedict( )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 6, + "token_count": 113, + "parameters": [], + "start_line": 34, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "help", + "long_name": "help( object = None , maxwidth = 76 , output = sys . stdout , )", + "filename": "helpmod.py", + "nloc": 98, + "complexity": 25, + "token_count": 734, + "parameters": [ + "object", + "maxwidth", + "output" + ], + "start_line": 54, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 125, + "top_nesting_level": 0 + }, + { + "name": "source", + "long_name": "source( object , output = sys . stdout )", + "filename": "helpmod.py", + "nloc": 6, + "complexity": 2, + "token_count": 51, + "parameters": [ + "object", + "output" + ], + "start_line": 181, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "split_line", + "long_name": "split_line( name , arguments , width )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 4, + "token_count": 104, + "parameters": [ + "name", + "arguments", + "width" + ], + "start_line": 11, + "end_line": 28, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "help", + "long_name": "help( object = None , maxwidth = 76 , output = sys . stdout , )", + "filename": "helpmod.py", + "nloc": 98, + "complexity": 25, + "token_count": 734, + "parameters": [ + "object", + "maxwidth", + "output" + ], + "start_line": 54, + "end_line": 178, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 125, + "top_nesting_level": 0 + }, + { + "name": "source", + "long_name": "source( object , output = sys . stdout )", + "filename": "helpmod.py", + "nloc": 6, + "complexity": 2, + "token_count": 51, + "parameters": [ + "object", + "output" + ], + "start_line": 181, + "end_line": 186, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 6, + "top_nesting_level": 0 + }, + { + "name": "makenamedict", + "long_name": "makenamedict( )", + "filename": "helpmod.py", + "nloc": 18, + "complexity": 6, + "token_count": 113, + "parameters": [], + "start_line": 34, + "end_line": 51, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + } + ], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "import inspect", + "import types", + "import sys, os", + "", + "# NOTE: pydoc defines a help function which works simliarly to this", + "# except it uses a pager to take over the screen.", + "", + "# combine name and arguments and split to multiple lines of", + "# width characters. End lines on a comma and begin argument list", + "# indented with the rest of the arguments.", + "def split_line(name, arguments, width):", + " firstwidth = len(name)", + " k = firstwidth", + " newstr = name", + " sepstr = \", \"", + " arglist = arguments.split(sepstr)", + " for argument in arglist:", + " if k == firstwidth:", + " addstr = \"\"", + " else:", + " addstr = sepstr", + " k = k + len(argument) + len(addstr)", + " if k > width:", + " k = firstwidth + 1 + len(argument)", + " newstr = newstr + \",\\n\" + \" \"*(firstwidth+2) + argument", + " else:", + " newstr = newstr + addstr + argument", + " return newstr", + "", + "_namedict = None", + "_dictlist = None", + "", + "# Traverse all module directories underneath globals to see if something is defined", + "def makenamedict():", + " import scipy", + " thedict = {'scipy':scipy.__dict__}", + " dictlist = ['scipy']", + " totraverse = [scipy.__dict__]", + " while 1:", + " if len(totraverse) == 0:", + " break", + " thisdict = totraverse.pop(0)", + " for x in thisdict.keys():", + " if isinstance(thisdict[x],types.ModuleType):", + " modname = thisdict[x].__name__", + " if modname not in dictlist:", + " moddict = thisdict[x].__dict__", + " dictlist.append(modname)", + " totraverse.append(moddict)", + " thedict[modname] = moddict", + " return thedict, dictlist", + "", + "", + "def help(object=None,maxwidth=76,output=sys.stdout,):", + " \"\"\"Get help information for a function, class, or module.", + "", + " Example:", + " >>> from scipy import *", + " >>> help(polyval)", + " polyval(p, x)", + "", + " Evaluate the polymnomial p at x.", + "", + " Description:", + " If p is of length N, this function returns the value:", + " p[0]*(x**N-1) + p[1]*(x**N-2) + ... + p[N-2]*x + p[N-1]", + " \"\"\"", + " global _namedict, _dictlist", + " if object is None:", + " help(help)", + " elif isinstance(object, types.StringType):", + " if _namedict is None:", + " _namedict, _dictlist = makenamedict()", + " numfound = 0", + " objlist = []", + " for namestr in _dictlist:", + " try:", + " obj = _namedict[namestr][object]", + " if id(obj) in objlist:", + " print >> output, \"\\n *** Repeat reference found in %s *** \" % namestr", + " else:", + " objlist.append(id(obj))", + " print >> output, \" *** Found in %s ***\" % namestr", + " help(obj)", + " print >> output, \"-\"*maxwidth", + " numfound += 1", + " except KeyError:", + " pass", + " if numfound == 0:", + " print >> output, \"Help for %s not found.\" % object", + " else:", + " print >> output, \"\\n *** Total of %d references found. ***\" % numfound", + "", + " elif inspect.isfunction(object):", + " name = object.func_name", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object))", + "", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " print >> output, inspect.getdoc(object)", + "", + " elif inspect.isclass(object):", + " name = object.__name__", + " if hasattr(object, '__init__'):", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object.__init__.im_func))", + " arglist = arguments.split(', ')", + " if len(arglist) > 1:", + " arglist[1] = \"(\"+arglist[1]", + " arguments = \", \".join(arglist[1:])", + " else:", + " arguments = \"()\"", + " else:", + " arguments = \"()\"", + "", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " doc1 = inspect.getdoc(object)", + " if doc1 is None:", + " if hasattr(object,'__init__'):", + " print >> output, inspect.getdoc(object.__init__)", + " else:", + " print >> output, inspect.getdoc(object)", + "", + " elif type(object) is types.InstanceType: ## check for __call__ method", + " print >> output, \"Instance of class: \", object.__class__.__name__", + " print >> output", + " if hasattr(object, '__call__'):", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object.__call__.im_func))", + " arglist = arguments.split(', ')", + " if len(arglist) > 1:", + " arglist[1] = \"(\"+arglist[1]", + " arguments = \", \".join(arglist[1:])", + " else:", + " arguments = \"()\"", + "", + " name = \"\"", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " doc = inspect.getdoc(object.__call__)", + " if doc is not None:", + " print >> output, inspect.getdoc(object.__call__)", + " print >> output, inspect.getdoc(object)", + "", + " else:", + " print >> output, inspect.getdoc(object)", + "", + " elif inspect.ismethod(object):", + " name = object.__name__", + " arguments = apply(inspect.formatargspec, inspect.getargspec(object.im_func))", + " arglist = arguments.split(', ')", + " if len(arglist) > 1:", + " arglist[1] = \"(\"+arglist[1]", + " arguments = \", \".join(arglist[1:])", + " else:", + " arguments = \"()\"", + "", + " if len(name+arguments) > maxwidth:", + " argstr = split_line(name, arguments, maxwidth)", + " else:", + " argstr = name + arguments", + "", + " print >> output, \" \" + argstr + \"\\n\"", + " print >> output, inspect.getdoc(object)", + "", + " elif hasattr(object, '__doc__'):", + " print >> output, inspect.getdoc(object)", + "", + "", + "def source(object, output=sys.stdout):", + " if inspect.isroutine(object):", + " print >> output, \"In file: %s\\n\" % inspect.getsourcefile(object)", + " print >> output, inspect.getsource(object)", + " else:", + " print >> output, \"Not available for this object.\"" + ] + } + }, + { + "old_path": "scipy_base/utility.py", + "new_path": null, + "filename": "utility.py", + "extension": "py", + "change_type": "DELETE", + "diff": "@@ -1,865 +0,0 @@\n-import Numeric\n-import types\n-import cPickle\n-import sys\n-\n-from Numeric import *\n-from fastumath import *\n-\n-ScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n-\n-__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n- 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n- 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n- 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n- 'dsplit','array_kind','array_precision','array_type','common_type',\n- 'trim_zeros','cast']\n-\n-\n-\n-toChar = lambda x: Numeric.array(x, Numeric.Character)\n-toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\n-toInt16 = lambda x: Numeric.array(x, Numeric.Int16)\n-toInt32 = lambda x: Numeric.array(x, Numeric.Int32)\n-toInt = lambda x: Numeric.array(x, Numeric.Int)\n-toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\n-toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\n-toComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\n-toComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n-\n-cast = {Numeric.Character: toChar,\n- Numeric.Int8: toInt8,\n- Numeric.Int16: toInt16,\n- Numeric.Int32: toInt32,\n- Numeric.Int: toInt,\n- Numeric.Float32: toFloat32,\n- Numeric.Float64: toFloat64,\n- Numeric.Complex32: toComplex32,\n- Numeric.Complex64: toComplex64}\n-\n-class 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 complex\n- number, then the stop is not inclusive.\n-\n- However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n- part of it's magnitude is interpreted as specifying the number of points to\n- create between the start and stop values, where the stop value\n- IS INCLUSIVE.\n-\n- Example:\n-\n- >>> grid = nd_grid()\n- >>> grid[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- >>> grid[-1:1:5j]\n- array([-1. , -0.5, 0. , 0.5, 1. ])\n- \"\"\"\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- 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-\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-\n-grid = nd_grid()\n-\n-class concatenator:\n- \"\"\"An object which 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 = linspace(start, stop, num=size, 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-\n-r_=concatenator(0)\n-c_=concatenator(-1)\n-\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-\n-class _index_expression_class:\n-\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-\n-index_exp = _index_expression_class()\n-\n-# End contribution from Konrad.\n-\n-def 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- 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-def r1array(x):\n- \"\"\"Ensure x is at least 1-dimensional.\n- \"\"\"\n- if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n- x = [x]\n- elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n- x.shape = (1,)\n- return Numeric.asarray(x)\n-\n-def r2array(x):\n- \"\"\"Ensure x is at least 2-dimensional.\n- \"\"\"\n- if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n- return Numeric.asarray([[x]])\n- else:\n- temp = Numeric.asarray(x)\n- if len(temp.shape) == 1:\n- if temp.shape[0] == 0:\n- temp.shape = (0,) + temp.shape\n- else:\n- temp.shape = (1,) + temp.shape\n- return temp\n-\n-\n-_namefromtype = {'c' : 'character',\n- '1' : 'signed char',\n- 'b' : 'unsigned char',\n- 's' : 'short',\n- 'i' : 'integer',\n- 'l' : 'long integer',\n- 'f' : 'float',\n- 'd' : 'double',\n- 'F' : 'complex float',\n- 'D' : 'complex double',\n- 'O' : 'object'\n- }\n-\n-def typename(char):\n- \"\"\"Return an english name for the given typecode character.\n- \"\"\"\n- return _namefromtype[char]\n-\n-def who(vardict=None):\n- \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n- \"\"\"\n- if vardict is None:\n- print \"Pass in a dictionary: who(globals())\"\n- return\n- sta = []\n- cache = {}\n- for name in vardict.keys():\n- if isinstance(vardict[name],Numeric.ArrayType):\n- var = vardict[name]\n- idv = id(var)\n- if idv in cache.keys():\n- namestr = name + \" (%s)\" % cache[idv]\n- original=0\n- else:\n- cache[idv] = name\n- namestr = name\n- original=1\n- shapestr = \" x \".join(map(str, var.shape))\n- bytestr = str(var.itemsize()*Numeric.product(var.shape))\n- sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n-\n- maxname = 0\n- maxshape = 0\n- maxbyte = 0\n- totalbytes = 0\n- for k in range(len(sta)):\n- val = sta[k]\n- if maxname < len(val[0]):\n- maxname = len(val[0])\n- if maxshape < len(val[1]):\n- maxshape = len(val[1])\n- if maxbyte < len(val[2]):\n- maxbyte = len(val[2])\n- if val[4]:\n- totalbytes += int(val[2])\n-\n- max = Numeric.maximum\n- if len(sta) > 0:\n- sp1 = max(10,maxname)\n- sp2 = max(10,maxshape)\n- sp3 = max(10,maxbyte)\n- prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n- print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n- \n- for k in range(len(sta)):\n- val = sta[k]\n- print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n- val[1], ' '*(sp2-len(val[1])+5),\n- val[2], ' '*(sp3-len(val[2])+5),\n- val[3])\n- print \"\\nUpper bound on total bytes = %d\" % totalbytes\n- return\n- \n-def objsave(file, allglobals, *args):\n- \"\"\"Pickle the part of a dictionary containing the argument list\n- into file string.\n-\n- Syntax: objsave(file, globals(), obj1, obj2, ... )\n- \"\"\"\n- fid = open(file,'w')\n- savedict = {}\n- for key in allglobals.keys():\n- inarglist = 0\n- for obj in args:\n- if allglobals[key] is obj:\n- inarglist = 1\n- break\n- if inarglist:\n- savedict[key] = obj\n- cPickle.dump(savedict,fid,1)\n- fid.close()\n- \n-def objload(file, allglobals):\n- \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n-\n- Syntax: objload(file, globals())\n- \"\"\"\n- fid = open(file,'r')\n- savedict = cPickle.load(fid)\n- allglobals.update(savedict)\n- fid.close()\n-\n-def isscalar(num):\n- if isinstance(num, ArrayType):\n- return len(num.shape) == 0 and num.typecode() != 'O'\n- return type(num) in ScalarType\n-\n-def all_mat(args):\n- return map(Matrix.Matrix,args)\n-\n- \n-# Selector function\n-\n-def 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-def atleast_1d(tup):\n- \"\"\" Force a sequence of arrays to each be at least 1D.\n-\n- Description:\n- Force a sequence of arrays to each be at least 1D. If an array\n- in the sequence is 0D, the array is converted to a single\n- row of values. Otherwise, the array is unaltered.\n- Arguments:\n- tup -- sequence of arrays.\n- Returns:\n- tuple containing input arrays converted to at least 1D arrays.\n- \"\"\"\n- new_tup = []\n- for ary in tup:\n- if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n- else: new_tup.append(ary)\n- return tuple(new_tup)\n-\n-def atleast_2d(tup):\n- \"\"\" Force a sequence of arrays to each be at least 2D.\n-\n- Description:\n- Force a sequence of arrays to each be at least 2D. If an array\n- in the sequence is 0D or 1D, the array is converted to a single\n- row of values. Otherwise, the array is unaltered.\n- Arguments:\n- tup -- sequence of arrays.\n- Returns:\n- tuple containing input arrays converted to at least 2D arrays.\n- \"\"\"\n- new_tup = []\n- for ary in tup:\n- if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n- if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n- else: new_tup.append(ary)\n- return tuple(new_tup)\n-\n-def atleast_3d(tup):\n- \"\"\" Force a sequence of arrays to each be at least 3D.\n-\n- Description:\n- Force a sequence of arrays to each be at least 3D. If an array\n- in the sequence is 0D or 1D, the array is converted to a single\n- 1xNx1 array of values where N is the orginal length of the array.\n- If the array is 2D, the array is converted to a single MxNx1\n- array of values where MxN is the orginal shape of the array.\n- Otherwise, the array is unaltered.\n- Arguments:\n- tup -- sequence of arrays.\n- Returns:\n- tuple containing input arrays converted to at least 2D arrays.\n- \"\"\"\n- new_tup = []\n- for ary in tup:\n- if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n- if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n- elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n- else: new_tup.append(ary)\n- return tuple(new_tup)\n-\n-def vstack(tup):\n- \"\"\" Stack arrays in sequence vertically (row wise)\n-\n- Description:\n- Take a sequence of arrays and stack them veritcally\n- to make a single array. All arrays in the sequence\n- must have the same shape along all but the first axis. \n- vstack will rebuild arrays divided by vsplit.\n- Arguments:\n- tup -- sequence of arrays. All arrays must have the same \n- shape.\n- Examples:\n- >>> import scipy\n- >>> a = array((1,2,3))\n- >>> b = array((2,3,4))\n- >>> scipy.vstack((a,b))\n- array([[1, 2, 3],\n- [2, 3, 4]])\n- >>> a = array([[1],[2],[3]])\n- >>> b = array([[2],[3],[4]])\n- >>> scipy.vstack((a,b))\n- array([[1],\n- [2],\n- [3],\n- [2],\n- [3],\n- [4]])\n-\n- \"\"\"\n- return Numeric.concatenate(atleast_2d(tup),0)\n-\n-def hstack(tup):\n- \"\"\" Stack arrays in sequence horizontally (column wise)\n-\n- Description:\n- Take a sequence of arrays and stack them horizontally\n- to make a single array. All arrays in the sequence\n- must have the same shape along all but the second axis.\n- hstack will rebuild arrays divided by hsplit.\n- Arguments:\n- tup -- sequence of arrays. All arrays must have the same \n- shape.\n- Examples:\n- >>> import scipy\n- >>> a = array((1,2,3))\n- >>> b = array((2,3,4))\n- >>> scipy.hstack((a,b))\n- array([1, 2, 3, 2, 3, 4])\n- >>> a = array([[1],[2],[3]])\n- >>> b = array([[2],[3],[4]])\n- >>> scipy.hstack((a,b))\n- array([[1, 2],\n- [2, 3],\n- [3, 4]])\n-\n- \"\"\"\n- return Numeric.concatenate(atleast_1d(tup),1)\n-\n-def column_stack(tup):\n- \"\"\" Stack 1D arrays as columns into a 2D array\n-\n- Description:\n- Take a sequence of 1D arrays and stack them as columns\n- to make a single 2D array. All arrays in the sequence\n- must have the same length.\n- Arguments:\n- tup -- sequence of 1D arrays. All arrays must have the same \n- length.\n- Examples:\n- >>> import scipy\n- >>> a = array((1,2,3))\n- >>> b = array((2,3,4))\n- >>> scipy.vstack((a,b))\n- array([[1, 2],\n- [2, 3],\n- [3, 4]])\n-\n- \"\"\"\n- arrays = map(Numeric.transpose,atleast_2d(tup))\n- return Numeric.concatenate(arrays,1)\n- \n-def dstack(tup):\n- \"\"\" Stack arrays in sequence depth wise (along third dimension)\n-\n- Description:\n- Take a sequence of arrays and stack them along the third axis.\n- All arrays in the sequence must have the same shape along all \n- but the third axis. This is a simple way to stack 2D arrays \n- (images) into a single 3D array for processing.\n- dstack will rebuild arrays divided by dsplit.\n- Arguments:\n- tup -- sequence of arrays. All arrays must have the same \n- shape.\n- Examples:\n- >>> import scipy\n- >>> a = array((1,2,3))\n- >>> b = array((2,3,4))\n- >>> scipy.dstack((a,b))\n- array([ [[1, 2],\n- [2, 3],\n- [3, 4]]])\n- >>> a = array([[1],[2],[3]])\n- >>> b = array([[2],[3],[4]])\n- >>> scipy.dstack((a,b))\n- array([[ [1, 2]],\n- [ [2, 3]],\n- [ [3, 4]]])\n- \"\"\"\n- return Numeric.concatenate(atleast_3d(tup),2)\n-\n-def replace_zero_by_x_arrays(sub_arys):\n- for i in range(len(sub_arys)):\n- if len(Numeric.shape(sub_arys[i])) == 0:\n- sub_arys[i] = Numeric.array([])\n- elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n- sub_arys[i] = Numeric.array([]) \n- return sub_arys\n- \n-def array_split(ary,indices_or_sections,axis = 0):\n- \"\"\" Divide an array into a list of sub-arrays.\n-\n- Description:\n- Divide ary into a list of sub-arrays along the\n- specified axis. If indices_or_sections is an integer,\n- ary is divided into that many equally sized arrays.\n- If it is impossible to make an equal split, each of the\n- leading arrays in the list have one additional member. If\n- indices_or_sections is a list of sorted integers, its\n- entries define the indexes where ary is split.\n-\n- Arguments:\n- ary -- N-D array.\n- Array to be divided into sub-arrays.\n- indices_or_sections -- integer or 1D array.\n- If integer, defines the number of (close to) equal sized\n- sub-arrays. If it is a 1D array of sorted indices, it\n- defines the indexes at which ary is divided. Any empty\n- list results in a single sub-array equal to the original\n- array.\n- axis -- integer. default=0.\n- Specifies the axis along which to split ary.\n- Caveats:\n- Currently, the default for axis is 0. This\n- means a 2D array is divided into multiple groups\n- of rows. This seems like the appropriate default, but\n- we've agreed most other functions should default to\n- axis=-1. Perhaps we should use axis=-1 for consistency.\n- However, we could also make the argument that SciPy\n- works on \"rows\" by default. sum() sums up rows of\n- values. split() will split data into rows. Opinions?\n- \"\"\"\n- try:\n- Ntotal = ary.shape[axis]\n- except AttributeError:\n- Ntotal = len(ary)\n- try: # handle scalar case.\n- Nsections = len(indices_or_sections) + 1\n- div_points = [0] + list(indices_or_sections) + [Ntotal]\n- except TypeError: #indices_or_sections is a scalar, not an array.\n- Nsections = int(indices_or_sections)\n- if Nsections <= 0:\n- raise ValueError, 'number sections must be larger than 0.'\n- Neach_section,extras = divmod(Ntotal,Nsections)\n- section_sizes = [0] + \\\n- extras * [Neach_section+1] + \\\n- (Nsections-extras) * [Neach_section]\n- div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n-\n- sub_arys = []\n- sary = Numeric.swapaxes(ary,axis,0)\n- for i in range(Nsections):\n- st = div_points[i]; end = div_points[i+1]\n- sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n-\n- # there is a wierd issue with array slicing that allows\n- # 0x10 arrays and other such things. The following cluge is needed\n- # to get around this issue.\n- sub_arys = replace_zero_by_x_arrays(sub_arys)\n- # end cluge.\n-\n- return sub_arys\n-\n-def split(ary,indices_or_sections,axis=0):\n- \"\"\" Divide an array into a list of sub-arrays.\n-\n- Description:\n- Divide ary into a list of sub-arrays along the\n- specified axis. If indices_or_sections is an integer,\n- ary is divided into that many equally sized arrays.\n- If it is impossible to make an equal split, an error is \n- raised. This is the only way this function differs from\n- the array_split() function. If indices_or_sections is a \n- list of sorted integers, its entries define the indexes\n- where ary is split.\n-\n- Arguments:\n- ary -- N-D array.\n- Array to be divided into sub-arrays.\n- indices_or_sections -- integer or 1D array.\n- If integer, defines the number of (close to) equal sized\n- sub-arrays. If it is a 1D array of sorted indices, it\n- defines the indexes at which ary is divided. Any empty\n- list results in a single sub-array equal to the original\n- array.\n- axis -- integer. default=0.\n- Specifies the axis along which to split ary.\n- Caveats:\n- Currently, the default for axis is 0. This\n- means a 2D array is divided into multiple groups\n- of rows. This seems like the appropriate default, but\n- we've agreed most other functions should default to\n- axis=-1. Perhaps we should use axis=-1 for consistency.\n- However, we could also make the argument that SciPy\n- works on \"rows\" by default. sum() sums up rows of\n- values. split() will split data into rows. Opinions?\n- \"\"\"\n- try: len(indices_or_sections)\n- except TypeError:\n- sections = indices_or_sections\n- N = ary.shape[axis]\n- if N % sections:\n- raise ValueError, 'array split does not result in an equal division'\n- res = array_split(ary,indices_or_sections,axis)\n- return res\n-\n-def hsplit(ary,indices_or_sections):\n- \"\"\" Split ary into multiple columns of sub-arrays\n-\n- Description:\n- Split a single array into multiple sub arrays. The array is\n- divided into groups of columns. If indices_or_sections is\n- an integer, ary is divided into that many equally sized sub arrays.\n- If it is impossible to make the sub-arrays equally sized, the\n- operation throws a ValueError exception. See array_split and\n- split for other options on indices_or_sections. \n- Arguments:\n- ary -- N-D array.\n- Array to be divided into sub-arrays.\n- indices_or_sections -- integer or 1D array.\n- If integer, defines the number of (close to) equal sized\n- sub-arrays. If it is a 1D array of sorted indices, it\n- defines the indexes at which ary is divided. Any empty\n- list results in a single sub-array equal to the original\n- array.\n- Returns:\n- sequence of sub-arrays. The returned arrays have the same \n- number of dimensions as the input array.\n- Related:\n- hstack, split, array_split, vsplit, dsplit. \n- Examples:\n- >>> import scipy\n- >>> a= array((1,2,3,4))\n- >>> scipy.hsplit(a,2)\n- [array([1, 2]), array([3, 4])]\n- >>> a = array([[1,2,3,4],[1,2,3,4]])\n- [array([[1, 2],\n- [1, 2]]), array([[3, 4],\n- [3, 4]])]\n- \n- \"\"\"\n- if len(Numeric.shape(ary)) == 0:\n- raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n- if len(ary.shape) > 1:\n- return split(ary,indices_or_sections,1)\n- else:\n- return split(ary,indices_or_sections,0)\n- \n-def vsplit(ary,indices_or_sections):\n- \"\"\" Split ary into multiple rows of sub-arrays\n-\n- Description:\n- Split a single array into multiple sub arrays. The array is\n- divided into groups of rows. If indices_or_sections is\n- an integer, ary is divided into that many equally sized sub arrays.\n- If it is impossible to make the sub-arrays equally sized, the\n- operation throws a ValueError exception. See array_split and\n- split for other options on indices_or_sections.\n- Arguments:\n- ary -- N-D array.\n- Array to be divided into sub-arrays.\n- indices_or_sections -- integer or 1D array.\n- If integer, defines the number of (close to) equal sized\n- sub-arrays. If it is a 1D array of sorted indices, it\n- defines the indexes at which ary is divided. Any empty\n- list results in a single sub-array equal to the original\n- array.\n- Returns:\n- sequence of sub-arrays. The returned arrays have the same \n- number of dimensions as the input array. \n- Caveats:\n- How should we handle 1D arrays here? I am currently raising\n- an error when I encounter them. Any better approach? \n- \n- Should we reduce the returned array to their minium dimensions\n- by getting rid of any dimensions that are 1?\n- Related:\n- vstack, split, array_split, hsplit, dsplit.\n- Examples:\n- import scipy\n- >>> a = array([[1,2,3,4],\n- ... [1,2,3,4]])\n- >>> scipy.vsplit(a)\n- [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n- \n- \"\"\"\n- if len(Numeric.shape(ary)) < 2:\n- raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n- return split(ary,indices_or_sections,0)\n-\n-def dsplit(ary,indices_or_sections):\n- \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n-\n- Description:\n- Split a single array into multiple sub arrays. The array is\n- divided into groups along the 3rd axis. If indices_or_sections is\n- an integer, ary is divided into that many equally sized sub arrays.\n- If it is impossible to make the sub-arrays equally sized, the\n- operation throws a ValueError exception. See array_split and\n- split for other options on indices_or_sections. \n- Arguments:\n- ary -- N-D array.\n- Array to be divided into sub-arrays.\n- indices_or_sections -- integer or 1D array.\n- If integer, defines the number of (close to) equal sized\n- sub-arrays. If it is a 1D array of sorted indices, it\n- defines the indexes at which ary is divided. Any empty\n- list results in a single sub-array equal to the original\n- array.\n- Returns:\n- sequence of sub-arrays. The returned arrays have the same \n- number of dimensions as the input array.\n- Caveats:\n- See vsplit caveats. \n- Related:\n- dstack, split, array_split, hsplit, vsplit.\n- Examples:\n- >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n- [array([ [[1, 2],\n- [1, 2]]]), array([ [[3, 4],\n- [3, 4]]])]\n- \n- \"\"\"\n- if len(Numeric.shape(ary)) < 3:\n- raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n- return split(ary,indices_or_sections,2)\n-\n- \n-# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n-\n-#determine the \"minimum common type code\" for a group of arrays.\n-array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\n-array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\n-array_type = [['f', 'd'], ['F', 'D']]\n-def common_type(*arrays):\n- kind = 0\n- precision = 0\n- for a in arrays:\n- t = a.typecode()\n- kind = max(kind, array_kind[t])\n- precision = max(precision, array_precision[t])\n- return array_type[kind][precision]\n-\n-def trim_zeros(filt,trim='fb'):\n- \"\"\"Trim the leading and trailing zeros from a 1D array.\n- \n- Example:\n- >>> 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- \"\"\"\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-\n- \n-##def test(level=10):\n-## from scipy_base.testing import module_test\n-## module_test(__name__,__file__,level=level)\n-\n-##def test_suite(level=1):\n-## from scipy_base.testing import module_test_suite\n-## return module_test_suite(__name__,__file__,level=level)\n-\n-\n-\n-\n", + "added_lines": 0, + "deleted_lines": 865, + "source_code": null, + "source_code_before": "import Numeric\nimport types\nimport cPickle\nimport sys\n\nfrom Numeric import *\nfrom fastumath import *\n\nScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]\n\n__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',\n 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',\n 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',\n 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',\n 'dsplit','array_kind','array_precision','array_type','common_type',\n 'trim_zeros','cast']\n\n\n\ntoChar = lambda x: Numeric.array(x, Numeric.Character)\ntoInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte\ntoInt16 = lambda x: Numeric.array(x, Numeric.Int16)\ntoInt32 = lambda x: Numeric.array(x, Numeric.Int32)\ntoInt = lambda x: Numeric.array(x, Numeric.Int)\ntoFloat32 = lambda x: Numeric.array(x, Numeric.Float32)\ntoFloat64 = lambda x: Numeric.array(x, Numeric.Float64)\ntoComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)\ntoComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)\n\ncast = {Numeric.Character: toChar,\n Numeric.Int8: toInt8,\n Numeric.Int16: toInt16,\n Numeric.Int32: toInt32,\n Numeric.Int: toInt,\n Numeric.Float32: toFloat32,\n Numeric.Float64: toFloat64,\n Numeric.Complex32: toComplex32,\n Numeric.Complex64: toComplex64}\n\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 complex\n number, then the stop is not inclusive.\n\n However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer\n part of it's magnitude is interpreted as specifying the number of points to\n create between the start and stop values, where the stop value\n IS INCLUSIVE.\n\n Example:\n\n >>> grid = nd_grid()\n >>> grid[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 >>> grid[-1:1:5j]\n array([-1. , -0.5, 0. , 0.5, 1. ])\n \"\"\"\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 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\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\ngrid = nd_grid()\n\nclass concatenator:\n \"\"\"An object which 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 = linspace(start, stop, num=size, 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\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\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\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 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\ndef r1array(x):\n \"\"\"Ensure x is at least 1-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n x = [x]\n elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):\n x.shape = (1,)\n return Numeric.asarray(x)\n\ndef r2array(x):\n \"\"\"Ensure x is at least 2-dimensional.\n \"\"\"\n if type(x) in [type(1.0), type(1L), type(1), type(1j)]:\n return Numeric.asarray([[x]])\n else:\n temp = Numeric.asarray(x)\n if len(temp.shape) == 1:\n if temp.shape[0] == 0:\n temp.shape = (0,) + temp.shape\n else:\n temp.shape = (1,) + temp.shape\n return temp\n\n\n_namefromtype = {'c' : 'character',\n '1' : 'signed char',\n 'b' : 'unsigned char',\n 's' : 'short',\n 'i' : 'integer',\n 'l' : 'long integer',\n 'f' : 'float',\n 'd' : 'double',\n 'F' : 'complex float',\n 'D' : 'complex double',\n 'O' : 'object'\n }\n\ndef typename(char):\n \"\"\"Return an english name for the given typecode character.\n \"\"\"\n return _namefromtype[char]\n\ndef who(vardict=None):\n \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).\n \"\"\"\n if vardict is None:\n print \"Pass in a dictionary: who(globals())\"\n return\n sta = []\n cache = {}\n for name in vardict.keys():\n if isinstance(vardict[name],Numeric.ArrayType):\n var = vardict[name]\n idv = id(var)\n if idv in cache.keys():\n namestr = name + \" (%s)\" % cache[idv]\n original=0\n else:\n cache[idv] = name\n namestr = name\n original=1\n shapestr = \" x \".join(map(str, var.shape))\n bytestr = str(var.itemsize()*Numeric.product(var.shape))\n sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])\n\n maxname = 0\n maxshape = 0\n maxbyte = 0\n totalbytes = 0\n for k in range(len(sta)):\n val = sta[k]\n if maxname < len(val[0]):\n maxname = len(val[0])\n if maxshape < len(val[1]):\n maxshape = len(val[1])\n if maxbyte < len(val[2]):\n maxbyte = len(val[2])\n if val[4]:\n totalbytes += int(val[2])\n\n max = Numeric.maximum\n if len(sta) > 0:\n sp1 = max(10,maxname)\n sp2 = max(10,maxshape)\n sp3 = max(10,maxbyte)\n prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')\n print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"\n \n for k in range(len(sta)):\n val = sta[k]\n print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),\n val[1], ' '*(sp2-len(val[1])+5),\n val[2], ' '*(sp3-len(val[2])+5),\n val[3])\n print \"\\nUpper bound on total bytes = %d\" % totalbytes\n return\n \ndef objsave(file, allglobals, *args):\n \"\"\"Pickle the part of a dictionary containing the argument list\n into file string.\n\n Syntax: objsave(file, globals(), obj1, obj2, ... )\n \"\"\"\n fid = open(file,'w')\n savedict = {}\n for key in allglobals.keys():\n inarglist = 0\n for obj in args:\n if allglobals[key] is obj:\n inarglist = 1\n break\n if inarglist:\n savedict[key] = obj\n cPickle.dump(savedict,fid,1)\n fid.close()\n \ndef objload(file, allglobals):\n \"\"\"Load a previously pickled dictionary and insert into given dictionary.\n\n Syntax: objload(file, globals())\n \"\"\"\n fid = open(file,'r')\n savedict = cPickle.load(fid)\n allglobals.update(savedict)\n fid.close()\n\ndef isscalar(num):\n if isinstance(num, ArrayType):\n return len(num.shape) == 0 and num.typecode() != 'O'\n return type(num) in ScalarType\n\ndef all_mat(args):\n return map(Matrix.Matrix,args)\n\n \n# Selector function\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\ndef atleast_1d(tup):\n \"\"\" Force a sequence of arrays to each be at least 1D.\n\n Description:\n Force a sequence of arrays to each be at least 1D. If an array\n in the sequence is 0D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 1D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_2d(tup):\n \"\"\" Force a sequence of arrays to each be at least 2D.\n\n Description:\n Force a sequence of arrays to each be at least 2D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n row of values. Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef atleast_3d(tup):\n \"\"\" Force a sequence of arrays to each be at least 3D.\n\n Description:\n Force a sequence of arrays to each be at least 3D. If an array\n in the sequence is 0D or 1D, the array is converted to a single\n 1xNx1 array of values where N is the orginal length of the array.\n If the array is 2D, the array is converted to a single MxNx1\n array of values where MxN is the orginal shape of the array.\n Otherwise, the array is unaltered.\n Arguments:\n tup -- sequence of arrays.\n Returns:\n tuple containing input arrays converted to at least 2D arrays.\n \"\"\"\n new_tup = []\n for ary in tup:\n if len(ary.shape) == 0: ary = Numeric.array([ary[0]])\n if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])\n elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])\n else: new_tup.append(ary)\n return tuple(new_tup)\n\ndef vstack(tup):\n \"\"\" Stack arrays in sequence vertically (row wise)\n\n Description:\n Take a sequence of arrays and stack them veritcally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the first axis. \n vstack will rebuild arrays divided by vsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2, 3],\n [2, 3, 4]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.vstack((a,b))\n array([[1],\n [2],\n [3],\n [2],\n [3],\n [4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_2d(tup),0)\n\ndef hstack(tup):\n \"\"\" Stack arrays in sequence horizontally (column wise)\n\n Description:\n Take a sequence of arrays and stack them horizontally\n to make a single array. All arrays in the sequence\n must have the same shape along all but the second axis.\n hstack will rebuild arrays divided by hsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.hstack((a,b))\n array([1, 2, 3, 2, 3, 4])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.hstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n return Numeric.concatenate(atleast_1d(tup),1)\n\ndef column_stack(tup):\n \"\"\" Stack 1D arrays as columns into a 2D array\n\n Description:\n Take a sequence of 1D arrays and stack them as columns\n to make a single 2D array. All arrays in the sequence\n must have the same length.\n Arguments:\n tup -- sequence of 1D arrays. All arrays must have the same \n length.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.vstack((a,b))\n array([[1, 2],\n [2, 3],\n [3, 4]])\n\n \"\"\"\n arrays = map(Numeric.transpose,atleast_2d(tup))\n return Numeric.concatenate(arrays,1)\n \ndef dstack(tup):\n \"\"\" Stack arrays in sequence depth wise (along third dimension)\n\n Description:\n Take a sequence of arrays and stack them along the third axis.\n All arrays in the sequence must have the same shape along all \n but the third axis. This is a simple way to stack 2D arrays \n (images) into a single 3D array for processing.\n dstack will rebuild arrays divided by dsplit.\n Arguments:\n tup -- sequence of arrays. All arrays must have the same \n shape.\n Examples:\n >>> import scipy\n >>> a = array((1,2,3))\n >>> b = array((2,3,4))\n >>> scipy.dstack((a,b))\n array([ [[1, 2],\n [2, 3],\n [3, 4]]])\n >>> a = array([[1],[2],[3]])\n >>> b = array([[2],[3],[4]])\n >>> scipy.dstack((a,b))\n array([[ [1, 2]],\n [ [2, 3]],\n [ [3, 4]]])\n \"\"\"\n return Numeric.concatenate(atleast_3d(tup),2)\n\ndef replace_zero_by_x_arrays(sub_arys):\n for i in range(len(sub_arys)):\n if len(Numeric.shape(sub_arys[i])) == 0:\n sub_arys[i] = Numeric.array([])\n elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):\n sub_arys[i] = Numeric.array([]) \n return sub_arys\n \ndef array_split(ary,indices_or_sections,axis = 0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, each of the\n leading arrays in the list have one additional member. If\n indices_or_sections is a list of sorted integers, its\n entries define the indexes where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try:\n Ntotal = ary.shape[axis]\n except AttributeError:\n Ntotal = len(ary)\n try: # handle scalar case.\n Nsections = len(indices_or_sections) + 1\n div_points = [0] + list(indices_or_sections) + [Ntotal]\n except TypeError: #indices_or_sections is a scalar, not an array.\n Nsections = int(indices_or_sections)\n if Nsections <= 0:\n raise ValueError, 'number sections must be larger than 0.'\n Neach_section,extras = divmod(Ntotal,Nsections)\n section_sizes = [0] + \\\n extras * [Neach_section+1] + \\\n (Nsections-extras) * [Neach_section]\n div_points = Numeric.add.accumulate(Numeric.array(section_sizes))\n\n sub_arys = []\n sary = Numeric.swapaxes(ary,axis,0)\n for i in range(Nsections):\n st = div_points[i]; end = div_points[i+1]\n sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))\n\n # there is a wierd issue with array slicing that allows\n # 0x10 arrays and other such things. The following cluge is needed\n # to get around this issue.\n sub_arys = replace_zero_by_x_arrays(sub_arys)\n # end cluge.\n\n return sub_arys\n\ndef split(ary,indices_or_sections,axis=0):\n \"\"\" Divide an array into a list of sub-arrays.\n\n Description:\n Divide ary into a list of sub-arrays along the\n specified axis. If indices_or_sections is an integer,\n ary is divided into that many equally sized arrays.\n If it is impossible to make an equal split, an error is \n raised. This is the only way this function differs from\n the array_split() function. If indices_or_sections is a \n list of sorted integers, its entries define the indexes\n where ary is split.\n\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n axis -- integer. default=0.\n Specifies the axis along which to split ary.\n Caveats:\n Currently, the default for axis is 0. This\n means a 2D array is divided into multiple groups\n of rows. This seems like the appropriate default, but\n we've agreed most other functions should default to\n axis=-1. Perhaps we should use axis=-1 for consistency.\n However, we could also make the argument that SciPy\n works on \"rows\" by default. sum() sums up rows of\n values. split() will split data into rows. Opinions?\n \"\"\"\n try: len(indices_or_sections)\n except TypeError:\n sections = indices_or_sections\n N = ary.shape[axis]\n if N % sections:\n raise ValueError, 'array split does not result in an equal division'\n res = array_split(ary,indices_or_sections,axis)\n return res\n\ndef hsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple columns of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of columns. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Related:\n hstack, split, array_split, vsplit, dsplit. \n Examples:\n >>> import scipy\n >>> a= array((1,2,3,4))\n >>> scipy.hsplit(a,2)\n [array([1, 2]), array([3, 4])]\n >>> a = array([[1,2,3,4],[1,2,3,4]])\n [array([[1, 2],\n [1, 2]]), array([[3, 4],\n [3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) == 0:\n raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'\n if len(ary.shape) > 1:\n return split(ary,indices_or_sections,1)\n else:\n return split(ary,indices_or_sections,0)\n \ndef vsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple rows of sub-arrays\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups of rows. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections.\n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array. \n Caveats:\n How should we handle 1D arrays here? I am currently raising\n an error when I encounter them. Any better approach? \n \n Should we reduce the returned array to their minium dimensions\n by getting rid of any dimensions that are 1?\n Related:\n vstack, split, array_split, hsplit, dsplit.\n Examples:\n import scipy\n >>> a = array([[1,2,3,4],\n ... [1,2,3,4]])\n >>> scipy.vsplit(a)\n [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 2:\n raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'\n return split(ary,indices_or_sections,0)\n\ndef dsplit(ary,indices_or_sections):\n \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)\n\n Description:\n Split a single array into multiple sub arrays. The array is\n divided into groups along the 3rd axis. If indices_or_sections is\n an integer, ary is divided into that many equally sized sub arrays.\n If it is impossible to make the sub-arrays equally sized, the\n operation throws a ValueError exception. See array_split and\n split for other options on indices_or_sections. \n Arguments:\n ary -- N-D array.\n Array to be divided into sub-arrays.\n indices_or_sections -- integer or 1D array.\n If integer, defines the number of (close to) equal sized\n sub-arrays. If it is a 1D array of sorted indices, it\n defines the indexes at which ary is divided. Any empty\n list results in a single sub-array equal to the original\n array.\n Returns:\n sequence of sub-arrays. The returned arrays have the same \n number of dimensions as the input array.\n Caveats:\n See vsplit caveats. \n Related:\n dstack, split, array_split, hsplit, vsplit.\n Examples:\n >>> a = array([[[1,2,3,4],[1,2,3,4]]])\n [array([ [[1, 2],\n [1, 2]]]), array([ [[3, 4],\n [3, 4]]])]\n \n \"\"\"\n if len(Numeric.shape(ary)) < 3:\n raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'\n return split(ary,indices_or_sections,2)\n\n \n# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.\n\n#determine the \"minimum common type code\" for a group of arrays.\narray_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}\narray_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}\narray_type = [['f', 'd'], ['F', 'D']]\ndef common_type(*arrays):\n kind = 0\n precision = 0\n for a in arrays:\n t = a.typecode()\n kind = max(kind, array_kind[t])\n precision = max(precision, array_precision[t])\n return array_type[kind][precision]\n\ndef trim_zeros(filt,trim='fb'):\n \"\"\"Trim the leading and trailing zeros from a 1D array.\n \n Example:\n >>> 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 \"\"\"\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\n \n##def test(level=10):\n## from scipy_base.testing import module_test\n## module_test(__name__,__file__,level=level)\n\n##def test_suite(level=1):\n## from scipy_base.testing import module_test_suite\n## return module_test_suite(__name__,__file__,level=level)\n\n\n\n\n", + "methods": [], + "methods_before": [ + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 70, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 113, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 116, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 124, + "end_line": 125, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 31, + "complexity": 11, + "token_count": 253, + "parameters": [ + "self", + "key" + ], + "start_line": 126, + "end_line": 156, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 31, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 158, + "end_line": 159, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 161, + "end_line": 162, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 194, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "self" + ], + "start_line": 200, + "end_line": 201, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , start , stop )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 203, + "end_line": 206, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 212, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 225, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 234, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 262, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 267, + "end_line": 320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 322, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 341, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 351, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 356, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 362, + "end_line": 408, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 410, + "end_line": 426, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 428, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 447, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 470, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 501, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 528, + "end_line": 549, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 551, + "end_line": 578, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 580, + "end_line": 586, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 588, + "end_line": 650, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 652, + "end_line": 693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 695, + "end_line": 735, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 737, + "end_line": 777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 779, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 823, + "end_line": 830, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 832, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "vsplit", + "long_name": "vsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 737, + "end_line": 777, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "disp", + "long_name": "disp( mesg , device = None , linefeed = 1 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 51, + "parameters": [ + "mesg", + "device", + "linefeed" + ], + "start_line": 212, + "end_line": 222, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "objsave", + "long_name": "objsave( file , allglobals , * args )", + "filename": "utility.py", + "nloc": 13, + "complexity": 5, + "token_count": 76, + "parameters": [ + "file", + "allglobals", + "args" + ], + "start_line": 322, + "end_line": 339, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "__init__", + "long_name": "__init__( self , axis = 0 )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "self", + "axis" + ], + "start_line": 124, + "end_line": 125, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , i , j )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "self", + "i", + "j" + ], + "start_line": 113, + "end_line": 114, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "split", + "long_name": "split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 9, + "complexity": 3, + "token_count": 53, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 652, + "end_line": 693, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 0 + }, + { + "name": "r2array", + "long_name": "r2array( x )", + "filename": "utility.py", + "nloc": 11, + "complexity": 4, + "token_count": 105, + "parameters": [ + "x" + ], + "start_line": 234, + "end_line": 246, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "common_type", + "long_name": "common_type( * arrays )", + "filename": "utility.py", + "nloc": 8, + "complexity": 2, + "token_count": 54, + "parameters": [ + "arrays" + ], + "start_line": 823, + "end_line": 830, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "__getslice__", + "long_name": "__getslice__( self , start , stop )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "start", + "stop" + ], + "start_line": 203, + "end_line": 206, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 1 + }, + { + "name": "typename", + "long_name": "typename( char )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 11, + "parameters": [ + "char" + ], + "start_line": 262, + "end_line": 265, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "select", + "long_name": "select( condlist , choicelist , default = 0 )", + "filename": "utility.py", + "nloc": 18, + "complexity": 7, + "token_count": 165, + "parameters": [ + "condlist", + "choicelist", + "default" + ], + "start_line": 362, + "end_line": 408, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 47, + "top_nesting_level": 0 + }, + { + "name": "column_stack", + "long_name": "column_stack( tup )", + "filename": "utility.py", + "nloc": 3, + "complexity": 1, + "token_count": 28, + "parameters": [ + "tup" + ], + "start_line": 528, + "end_line": 549, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "replace_zero_by_x_arrays", + "long_name": "replace_zero_by_x_arrays( sub_arys )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 81, + "parameters": [ + "sub_arys" + ], + "start_line": 580, + "end_line": 586, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 7, + "top_nesting_level": 0 + }, + { + "name": "hstack", + "long_name": "hstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 501, + "end_line": 526, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 26, + "top_nesting_level": 0 + }, + { + "name": "isscalar", + "long_name": "isscalar( num )", + "filename": "utility.py", + "nloc": 4, + "complexity": 3, + "token_count": 37, + "parameters": [ + "num" + ], + "start_line": 351, + "end_line": 354, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 4, + "top_nesting_level": 0 + }, + { + "name": "dstack", + "long_name": "dstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 551, + "end_line": 578, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 28, + "top_nesting_level": 0 + }, + { + "name": "objload", + "long_name": "objload( file , allglobals )", + "filename": "utility.py", + "nloc": 5, + "complexity": 1, + "token_count": 35, + "parameters": [ + "file", + "allglobals" + ], + "start_line": 341, + "end_line": 349, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "atleast_2d", + "long_name": "atleast_2d( tup )", + "filename": "utility.py", + "nloc": 7, + "complexity": 4, + "token_count": 72, + "parameters": [ + "tup" + ], + "start_line": 428, + "end_line": 445, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 18, + "top_nesting_level": 0 + }, + { + "name": "atleast_3d", + "long_name": "atleast_3d( tup )", + "filename": "utility.py", + "nloc": 8, + "complexity": 5, + "token_count": 97, + "parameters": [ + "tup" + ], + "start_line": 447, + "end_line": 468, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 22, + "top_nesting_level": 0 + }, + { + "name": "all_mat", + "long_name": "all_mat( args )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 14, + "parameters": [ + "args" + ], + "start_line": 356, + "end_line": 357, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 0 + }, + { + "name": "array_split", + "long_name": "array_split( ary , indices_or_sections , axis = 0 )", + "filename": "utility.py", + "nloc": 24, + "complexity": 5, + "token_count": 190, + "parameters": [ + "ary", + "indices_or_sections", + "axis" + ], + "start_line": 588, + "end_line": 650, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 63, + "top_nesting_level": 0 + }, + { + "name": "r1array", + "long_name": "r1array( x )", + "filename": "utility.py", + "nloc": 6, + "complexity": 4, + "token_count": 79, + "parameters": [ + "x" + ], + "start_line": 225, + "end_line": 232, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 8, + "top_nesting_level": 0 + }, + { + "name": "hsplit", + "long_name": "hsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 7, + "complexity": 3, + "token_count": 55, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 695, + "end_line": 735, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 41, + "top_nesting_level": 0 + }, + { + "name": "dsplit", + "long_name": "dsplit( ary , indices_or_sections )", + "filename": "utility.py", + "nloc": 4, + "complexity": 2, + "token_count": 34, + "parameters": [ + "ary", + "indices_or_sections" + ], + "start_line": 779, + "end_line": 814, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 36, + "top_nesting_level": 0 + }, + { + "name": "who", + "long_name": "who( vardict = None )", + "filename": "utility.py", + "nloc": 49, + "complexity": 12, + "token_count": 420, + "parameters": [ + "vardict" + ], + "start_line": 267, + "end_line": 320, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 54, + "top_nesting_level": 0 + }, + { + "name": "vstack", + "long_name": "vstack( tup )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 18, + "parameters": [ + "tup" + ], + "start_line": 470, + "end_line": 499, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 30, + "top_nesting_level": 0 + }, + { + "name": "__len__", + "long_name": "__len__( self )", + "filename": "utility.py", + "nloc": 2, + "complexity": 1, + "token_count": 7, + "parameters": [ + "self" + ], + "start_line": 116, + "end_line": 117, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 1 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , item )", + "filename": "utility.py", + "nloc": 5, + "complexity": 2, + "token_count": 28, + "parameters": [ + "self", + "item" + ], + "start_line": 194, + "end_line": 198, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 5, + "top_nesting_level": 1 + }, + { + "name": "trim_zeros", + "long_name": "trim_zeros( filt , trim = 'fb' )", + "filename": "utility.py", + "nloc": 12, + "complexity": 9, + "token_count": 87, + "parameters": [ + "filt", + "trim" + ], + "start_line": 832, + "end_line": 852, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 21, + "top_nesting_level": 0 + }, + { + "name": "atleast_1d", + "long_name": "atleast_1d( tup )", + "filename": "utility.py", + "nloc": 6, + "complexity": 3, + "token_count": 54, + "parameters": [ + "tup" + ], + "start_line": 410, + "end_line": 426, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 17, + "top_nesting_level": 0 + }, + { + "name": "__getitem__", + "long_name": "__getitem__( self , key )", + "filename": "utility.py", + "nloc": 42, + "complexity": 14, + "token_count": 368, + "parameters": [ + "self", + "key" + ], + "start_line": 70, + "end_line": 111, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 42, + "top_nesting_level": 1 + } + ], + "nloc": null, + "complexity": null, + "token_count": null, + "diff_parsed": { + "added": [], + "deleted": [ + "import Numeric", + "import types", + "import cPickle", + "import sys", + "", + "from Numeric import *", + "from fastumath import *", + "", + "ScalarType = [types.IntType, types.LongType, types.FloatType, types.ComplexType]", + "", + "__all__ = ['grid','r_','c_','index_exp','disp','r1array','r2array','typename',", + " 'who','objsave','objload','isscalar','all_mat','select','atleast_1d',", + " 'atleast_2d','atleast_3d','vstack','hstack','column_stack','dstack',", + " 'replace_zero_by_x_arrays','array_split','split','hsplit','vsplit',", + " 'dsplit','array_kind','array_precision','array_type','common_type',", + " 'trim_zeros','cast']", + "", + "", + "", + "toChar = lambda x: Numeric.array(x, Numeric.Character)", + "toInt8 = lambda x: Numeric.array(x, Numeric.Int8)# or use variable names such as Byte", + "toInt16 = lambda x: Numeric.array(x, Numeric.Int16)", + "toInt32 = lambda x: Numeric.array(x, Numeric.Int32)", + "toInt = lambda x: Numeric.array(x, Numeric.Int)", + "toFloat32 = lambda x: Numeric.array(x, Numeric.Float32)", + "toFloat64 = lambda x: Numeric.array(x, Numeric.Float64)", + "toComplex32 = lambda x: Numeric.array(x, Numeric.Complex32)", + "toComplex64 = lambda x: Numeric.array(x, Numeric.Complex64)", + "", + "cast = {Numeric.Character: toChar,", + " Numeric.Int8: toInt8,", + " Numeric.Int16: toInt16,", + " Numeric.Int32: toInt32,", + " Numeric.Int: toInt,", + " Numeric.Float32: toFloat32,", + " Numeric.Float64: toFloat64,", + " Numeric.Complex32: toComplex32,", + " Numeric.Complex64: toComplex64}", + "", + "class nd_grid:", + " \"\"\"Construct a \"meshgrid\" in N-dimensions.", + "", + " grid = nd_grid() creates an instance which will return a mesh-grid", + " when indexed. The dimension and number of the output arrays are equal", + " to the number of indexing dimensions. If the step length is not a complex", + " number, then the stop is not inclusive.", + "", + " However, if the step length is a COMPLEX NUMBER (e.g. 5j), then the integer", + " part of it's magnitude is interpreted as specifying the number of points to", + " create between the start and stop values, where the stop value", + " IS INCLUSIVE.", + "", + " Example:", + "", + " >>> grid = nd_grid()", + " >>> grid[0:5,0:5]", + " array([[[0, 0, 0, 0, 0],", + " [1, 1, 1, 1, 1],", + " [2, 2, 2, 2, 2],", + " [3, 3, 3, 3, 3],", + " [4, 4, 4, 4, 4]],", + " [[0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4],", + " [0, 1, 2, 3, 4]]])", + " >>> grid[-1:1:5j]", + " array([-1. , -0.5, 0. , 0.5, 1. ])", + " \"\"\"", + " def __getitem__(self,key):", + " try:", + "\t size = []", + " typecode = Numeric.Int", + "\t for k in range(len(key)):", + "\t step = key[k].step", + " start = key[k].start", + " if start is None: start = 0", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " size.append(int(abs(step)))", + " typecode = Numeric.Float", + " else:", + " size.append(int((key[k].stop - start)/(step*1.0)))", + " if isinstance(step,types.FloatType) or \\", + " isinstance(start, types.FloatType) or \\", + " isinstance(key[k].stop, types.FloatType):", + " typecode = Numeric.Float", + " nn = Numeric.indices(size,typecode)", + "\t for k in range(len(size)):", + " step = key[k].step", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " step = int(abs(step))", + " step = (key[k].stop - key[k].start)/float(step-1)", + " nn[k] = (nn[k]*step+key[k].start)", + "\t return nn", + " except (IndexError, TypeError):", + " step = key.step", + " stop = key.stop", + " start = key.start", + " if start is None: start = 0", + " if type(step) is type(1j):", + " step = abs(step)", + " length = int(step)", + " step = (key.stop-start)/float(step-1)", + " stop = key.stop+step", + " return Numeric.arange(0,length,1,Numeric.Float)*step + start", + " else:", + " return Numeric.arange(start, stop, step)", + "", + " def __getslice__(self,i,j):", + " return Numeric.arange(i,j)", + "", + " def __len__(self):", + " return 0", + "", + "grid = nd_grid()", + "", + "class concatenator:", + " \"\"\"An object which translates slice objects to concatenation along an axis.", + " \"\"\"", + " def __init__(self, axis=0):", + " self.axis = axis", + " def __getitem__(self,key):", + " if type(key) is not types.TupleType:", + " key = (key,)", + " objs = []", + " for k in range(len(key)):", + " if type(key[k]) is types.SliceType:", + " typecode = Numeric.Int", + "\t step = key[k].step", + " start = key[k].start", + " stop = key[k].stop", + " if start is None: start = 0", + " if step is None:", + " step = 1", + " if type(step) is type(1j):", + " size = int(abs(step))", + " typecode = Numeric.Float", + " endpoint = 1", + " else:", + " size = int((stop - start)/(step*1.0))", + " endpoint = 0", + " if isinstance(step,types.FloatType) or \\", + " isinstance(start, types.FloatType) or \\", + " isinstance(stop, types.FloatType):", + " typecode = Numeric.Float", + " newobj = linspace(start, stop, num=size, endpoint=endpoint)", + " elif type(key[k]) in ScalarType:", + " newobj = Numeric.asarray([key[k]])", + " else:", + " newobj = key[k]", + " objs.append(newobj)", + " return Numeric.concatenate(tuple(objs),axis=self.axis)", + "", + " def __getslice__(self,i,j):", + " return Numeric.arange(i,j)", + "", + " def __len__(self):", + " return 0", + "", + "r_=concatenator(0)", + "c_=concatenator(-1)", + "", + "", + "# A nicer way to build up index tuples for arrays.", + "#", + "# You can do all this with slice() plus a few special objects,", + "# but there's a lot to remember. This version is simpler because", + "# it uses the standard array indexing syntax.", + "#", + "# Written by Konrad Hinsen ", + "# last revision: 1999-7-23", + "#", + "# Cosmetic changes by T. Oliphant 2001", + "#", + "#", + "# This module provides a convenient method for constructing", + "# array indices algorithmically. It provides one importable object,", + "# 'index_expression'.", + "#", + "# For any index combination, including slicing and axis insertion,", + "# 'a[indices]' is the same as 'a[index_expression[indices]]' for any", + "# array 'a'. However, 'index_expression[indices]' can be used anywhere", + "# in Python code and returns a tuple of slice objects that can be", + "# used in the construction of complex index expressions.", + "", + "class _index_expression_class:", + "", + " maxint = sys.maxint", + "", + " def __getitem__(self, item):", + " if type(item) != type(()):", + " return (item,)", + " else:", + " return item", + "", + " def __len__(self):", + " return self.maxint", + "", + " def __getslice__(self, start, stop):", + " if stop == self.maxint:", + " stop = None", + " return self[start:stop:None]", + "", + "index_exp = _index_expression_class()", + "", + "# End contribution from Konrad.", + "", + "def disp(mesg, device=None, linefeed=1):", + " \"\"\"Display a message to device (default is sys.stdout) with(out) linefeed.", + " \"\"\"", + " if device is None:", + " device = sys.stdout", + " if linefeed:", + " device.write('%s\\n' % mesg)", + " else:", + " device.write('%s' % mesg)", + " device.flush()", + " return", + "", + "", + "def r1array(x):", + " \"\"\"Ensure x is at least 1-dimensional.", + " \"\"\"", + " if type(x) in [type(1.0), type(1L), type(1), type(1j)]:", + " x = [x]", + " elif (type(x) is Numeric.ArrayType) and (len(x.shape) == 0):", + " x.shape = (1,)", + " return Numeric.asarray(x)", + "", + "def r2array(x):", + " \"\"\"Ensure x is at least 2-dimensional.", + " \"\"\"", + " if type(x) in [type(1.0), type(1L), type(1), type(1j)]:", + " return Numeric.asarray([[x]])", + " else:", + " temp = Numeric.asarray(x)", + " if len(temp.shape) == 1:", + " if temp.shape[0] == 0:", + " temp.shape = (0,) + temp.shape", + " else:", + " temp.shape = (1,) + temp.shape", + " return temp", + "", + "", + "_namefromtype = {'c' : 'character',", + " '1' : 'signed char',", + " 'b' : 'unsigned char',", + " 's' : 'short',", + " 'i' : 'integer',", + " 'l' : 'long integer',", + " 'f' : 'float',", + " 'd' : 'double',", + " 'F' : 'complex float',", + " 'D' : 'complex double',", + " 'O' : 'object'", + " }", + "", + "def typename(char):", + " \"\"\"Return an english name for the given typecode character.", + " \"\"\"", + " return _namefromtype[char]", + "", + "def who(vardict=None):", + " \"\"\"Print the Numeric arrays in the given dictionary (or globals() if None).", + " \"\"\"", + " if vardict is None:", + " print \"Pass in a dictionary: who(globals())\"", + " return", + " sta = []", + " cache = {}", + " for name in vardict.keys():", + " if isinstance(vardict[name],Numeric.ArrayType):", + " var = vardict[name]", + " idv = id(var)", + " if idv in cache.keys():", + " namestr = name + \" (%s)\" % cache[idv]", + " original=0", + " else:", + " cache[idv] = name", + " namestr = name", + " original=1", + " shapestr = \" x \".join(map(str, var.shape))", + " bytestr = str(var.itemsize()*Numeric.product(var.shape))", + " sta.append([namestr, shapestr, bytestr, _namefromtype[var.typecode()], original])", + "", + " maxname = 0", + " maxshape = 0", + " maxbyte = 0", + " totalbytes = 0", + " for k in range(len(sta)):", + " val = sta[k]", + " if maxname < len(val[0]):", + " maxname = len(val[0])", + " if maxshape < len(val[1]):", + " maxshape = len(val[1])", + " if maxbyte < len(val[2]):", + " maxbyte = len(val[2])", + " if val[4]:", + " totalbytes += int(val[2])", + "", + " max = Numeric.maximum", + " if len(sta) > 0:", + " sp1 = max(10,maxname)", + " sp2 = max(10,maxshape)", + " sp3 = max(10,maxbyte)", + " prval = \"Name %s Shape %s Bytes %s Type\" % (sp1*' ', sp2*' ', sp3*' ')", + " print prval + \"\\n\" + \"=\"*(len(prval)+5) + \"\\n\"", + "", + " for k in range(len(sta)):", + " val = sta[k]", + " print \"%s %s %s %s %s %s %s\" % (val[0], ' '*(sp1-len(val[0])+4),", + " val[1], ' '*(sp2-len(val[1])+5),", + " val[2], ' '*(sp3-len(val[2])+5),", + " val[3])", + " print \"\\nUpper bound on total bytes = %d\" % totalbytes", + " return", + "", + "def objsave(file, allglobals, *args):", + " \"\"\"Pickle the part of a dictionary containing the argument list", + " into file string.", + "", + " Syntax: objsave(file, globals(), obj1, obj2, ... )", + " \"\"\"", + " fid = open(file,'w')", + " savedict = {}", + " for key in allglobals.keys():", + " inarglist = 0", + " for obj in args:", + " if allglobals[key] is obj:", + " inarglist = 1", + " break", + " if inarglist:", + " savedict[key] = obj", + " cPickle.dump(savedict,fid,1)", + " fid.close()", + "", + "def objload(file, allglobals):", + " \"\"\"Load a previously pickled dictionary and insert into given dictionary.", + "", + " Syntax: objload(file, globals())", + " \"\"\"", + " fid = open(file,'r')", + " savedict = cPickle.load(fid)", + " allglobals.update(savedict)", + " fid.close()", + "", + "def isscalar(num):", + " if isinstance(num, ArrayType):", + " return len(num.shape) == 0 and num.typecode() != 'O'", + " return type(num) in ScalarType", + "", + "def all_mat(args):", + " return map(Matrix.Matrix,args)", + "", + "", + "# Selector function", + "", + "def select(condlist, choicelist, default=0):", + " \"\"\"Returns an array comprised from different elements of choicelist", + " depending on the list of conditions.", + "", + " condlist is a list of condition arrays containing ones or zeros", + "", + " choicelist is a list of choice matrices (of the \"same\" size as the", + " arrays in condlist). The result array has the \"same\" size as the", + " arrays in choicelist. If condlist is [c0,...,cN-1] then choicelist", + " must be of length N. The elements of the choicelist can then be", + " represented as [v0,...,vN-1]. The default choice if none of the", + " conditions are met is given as the default argument.", + "", + " The conditions are tested in order and the first one statisfied is", + " used to select the choice. In other words, the elements of the", + " output array are found from the following tree (notice the order of", + " the conditions matters):", + "", + " if c0: v0", + " elif c1: v1", + " elif c2: v2", + " ...", + " elif cN-1: vN-1", + " else: default", + "", + " Note, that one of the condition arrays must be large enough to handle", + " the largest array in the choice list.", + " \"\"\"", + " n = len(condlist)", + " n2 = len(choicelist)", + " if n2 != n:", + " raise ValueError, \"List of cases, must be same length as the list of conditions.\"", + " choicelist.insert(0,default)", + " S = 0", + " pfac = 1", + " for k in range(1,n+1):", + " S += k * pfac * asarray(condlist[k-1])", + " if k < n:", + " pfac *= (1-asarray(condlist[k-1]))", + " # handle special case of a 1-element condition but", + " # a multi-element choice", + " if type(S) in ScalarType or max(asarray(S).shape)==1:", + " pfac = asarray(1)", + " for k in range(n2+1):", + " pfac = pfac + asarray(choicelist[k])", + " S = S*ones(asarray(pfac).shape)", + " return choose(S, tuple(choicelist))", + "", + "def atleast_1d(tup):", + " \"\"\" Force a sequence of arrays to each be at least 1D.", + "", + " Description:", + " Force a sequence of arrays to each be at least 1D. If an array", + " in the sequence is 0D, the array is converted to a single", + " row of values. Otherwise, the array is unaltered.", + " Arguments:", + " tup -- sequence of arrays.", + " Returns:", + " tuple containing input arrays converted to at least 1D arrays.", + " \"\"\"", + " new_tup = []", + " for ary in tup:", + " if len(ary.shape) == 0: new_tup.append(Numeric.array([ary[0]]))", + " else: new_tup.append(ary)", + " return tuple(new_tup)", + "", + "def atleast_2d(tup):", + " \"\"\" Force a sequence of arrays to each be at least 2D.", + "", + " Description:", + " Force a sequence of arrays to each be at least 2D. If an array", + " in the sequence is 0D or 1D, the array is converted to a single", + " row of values. Otherwise, the array is unaltered.", + " Arguments:", + " tup -- sequence of arrays.", + " Returns:", + " tuple containing input arrays converted to at least 2D arrays.", + " \"\"\"", + " new_tup = []", + " for ary in tup:", + " if len(ary.shape) == 0: ary = Numeric.array([ary[0]])", + " if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:])", + " else: new_tup.append(ary)", + " return tuple(new_tup)", + "", + "def atleast_3d(tup):", + " \"\"\" Force a sequence of arrays to each be at least 3D.", + "", + " Description:", + " Force a sequence of arrays to each be at least 3D. If an array", + " in the sequence is 0D or 1D, the array is converted to a single", + " 1xNx1 array of values where N is the orginal length of the array.", + " If the array is 2D, the array is converted to a single MxNx1", + " array of values where MxN is the orginal shape of the array.", + " Otherwise, the array is unaltered.", + " Arguments:", + " tup -- sequence of arrays.", + " Returns:", + " tuple containing input arrays converted to at least 2D arrays.", + " \"\"\"", + " new_tup = []", + " for ary in tup:", + " if len(ary.shape) == 0: ary = Numeric.array([ary[0]])", + " if len(ary.shape) == 1: new_tup.append(ary[NewAxis,:,NewAxis])", + " elif len(ary.shape) == 2: new_tup.append(ary[:,:,NewAxis])", + " else: new_tup.append(ary)", + " return tuple(new_tup)", + "", + "def vstack(tup):", + " \"\"\" Stack arrays in sequence vertically (row wise)", + "", + " Description:", + " Take a sequence of arrays and stack them veritcally", + " to make a single array. All arrays in the sequence", + " must have the same shape along all but the first axis.", + " vstack will rebuild arrays divided by vsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.vstack((a,b))", + " array([[1, 2, 3],", + " [2, 3, 4]])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.vstack((a,b))", + " array([[1],", + " [2],", + " [3],", + " [2],", + " [3],", + " [4]])", + "", + " \"\"\"", + " return Numeric.concatenate(atleast_2d(tup),0)", + "", + "def hstack(tup):", + " \"\"\" Stack arrays in sequence horizontally (column wise)", + "", + " Description:", + " Take a sequence of arrays and stack them horizontally", + " to make a single array. All arrays in the sequence", + " must have the same shape along all but the second axis.", + " hstack will rebuild arrays divided by hsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.hstack((a,b))", + " array([1, 2, 3, 2, 3, 4])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.hstack((a,b))", + " array([[1, 2],", + " [2, 3],", + " [3, 4]])", + "", + " \"\"\"", + " return Numeric.concatenate(atleast_1d(tup),1)", + "", + "def column_stack(tup):", + " \"\"\" Stack 1D arrays as columns into a 2D array", + "", + " Description:", + " Take a sequence of 1D arrays and stack them as columns", + " to make a single 2D array. All arrays in the sequence", + " must have the same length.", + " Arguments:", + " tup -- sequence of 1D arrays. All arrays must have the same", + " length.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.vstack((a,b))", + " array([[1, 2],", + " [2, 3],", + " [3, 4]])", + "", + " \"\"\"", + " arrays = map(Numeric.transpose,atleast_2d(tup))", + " return Numeric.concatenate(arrays,1)", + "", + "def dstack(tup):", + " \"\"\" Stack arrays in sequence depth wise (along third dimension)", + "", + " Description:", + " Take a sequence of arrays and stack them along the third axis.", + " All arrays in the sequence must have the same shape along all", + " but the third axis. This is a simple way to stack 2D arrays", + " (images) into a single 3D array for processing.", + " dstack will rebuild arrays divided by dsplit.", + " Arguments:", + " tup -- sequence of arrays. All arrays must have the same", + " shape.", + " Examples:", + " >>> import scipy", + " >>> a = array((1,2,3))", + " >>> b = array((2,3,4))", + " >>> scipy.dstack((a,b))", + " array([ [[1, 2],", + " [2, 3],", + " [3, 4]]])", + " >>> a = array([[1],[2],[3]])", + " >>> b = array([[2],[3],[4]])", + " >>> scipy.dstack((a,b))", + " array([[ [1, 2]],", + " [ [2, 3]],", + " [ [3, 4]]])", + " \"\"\"", + " return Numeric.concatenate(atleast_3d(tup),2)", + "", + "def replace_zero_by_x_arrays(sub_arys):", + " for i in range(len(sub_arys)):", + " if len(Numeric.shape(sub_arys[i])) == 0:", + " sub_arys[i] = Numeric.array([])", + " elif Numeric.sometrue(Numeric.equal(Numeric.shape(sub_arys[i]),0)):", + " sub_arys[i] = Numeric.array([])", + " return sub_arys", + "", + "def array_split(ary,indices_or_sections,axis = 0):", + " \"\"\" Divide an array into a list of sub-arrays.", + "", + " Description:", + " Divide ary into a list of sub-arrays along the", + " specified axis. If indices_or_sections is an integer,", + " ary is divided into that many equally sized arrays.", + " If it is impossible to make an equal split, each of the", + " leading arrays in the list have one additional member. If", + " indices_or_sections is a list of sorted integers, its", + " entries define the indexes where ary is split.", + "", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " axis -- integer. default=0.", + " Specifies the axis along which to split ary.", + " Caveats:", + " Currently, the default for axis is 0. This", + " means a 2D array is divided into multiple groups", + " of rows. This seems like the appropriate default, but", + " we've agreed most other functions should default to", + " axis=-1. Perhaps we should use axis=-1 for consistency.", + " However, we could also make the argument that SciPy", + " works on \"rows\" by default. sum() sums up rows of", + " values. split() will split data into rows. Opinions?", + " \"\"\"", + " try:", + " Ntotal = ary.shape[axis]", + " except AttributeError:", + " Ntotal = len(ary)", + " try: # handle scalar case.", + " Nsections = len(indices_or_sections) + 1", + " div_points = [0] + list(indices_or_sections) + [Ntotal]", + " except TypeError: #indices_or_sections is a scalar, not an array.", + " Nsections = int(indices_or_sections)", + " if Nsections <= 0:", + " raise ValueError, 'number sections must be larger than 0.'", + " Neach_section,extras = divmod(Ntotal,Nsections)", + " section_sizes = [0] + \\", + " extras * [Neach_section+1] + \\", + " (Nsections-extras) * [Neach_section]", + " div_points = Numeric.add.accumulate(Numeric.array(section_sizes))", + "", + " sub_arys = []", + " sary = Numeric.swapaxes(ary,axis,0)", + " for i in range(Nsections):", + " st = div_points[i]; end = div_points[i+1]", + " sub_arys.append(Numeric.swapaxes(sary[st:end],axis,0))", + "", + " # there is a wierd issue with array slicing that allows", + " # 0x10 arrays and other such things. The following cluge is needed", + " # to get around this issue.", + " sub_arys = replace_zero_by_x_arrays(sub_arys)", + " # end cluge.", + "", + " return sub_arys", + "", + "def split(ary,indices_or_sections,axis=0):", + " \"\"\" Divide an array into a list of sub-arrays.", + "", + " Description:", + " Divide ary into a list of sub-arrays along the", + " specified axis. If indices_or_sections is an integer,", + " ary is divided into that many equally sized arrays.", + " If it is impossible to make an equal split, an error is", + " raised. This is the only way this function differs from", + " the array_split() function. If indices_or_sections is a", + " list of sorted integers, its entries define the indexes", + " where ary is split.", + "", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " axis -- integer. default=0.", + " Specifies the axis along which to split ary.", + " Caveats:", + " Currently, the default for axis is 0. This", + " means a 2D array is divided into multiple groups", + " of rows. This seems like the appropriate default, but", + " we've agreed most other functions should default to", + " axis=-1. Perhaps we should use axis=-1 for consistency.", + " However, we could also make the argument that SciPy", + " works on \"rows\" by default. sum() sums up rows of", + " values. split() will split data into rows. Opinions?", + " \"\"\"", + " try: len(indices_or_sections)", + " except TypeError:", + " sections = indices_or_sections", + " N = ary.shape[axis]", + " if N % sections:", + " raise ValueError, 'array split does not result in an equal division'", + " res = array_split(ary,indices_or_sections,axis)", + " return res", + "", + "def hsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple columns of sub-arrays", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups of columns. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Related:", + " hstack, split, array_split, vsplit, dsplit.", + " Examples:", + " >>> import scipy", + " >>> a= array((1,2,3,4))", + " >>> scipy.hsplit(a,2)", + " [array([1, 2]), array([3, 4])]", + " >>> a = array([[1,2,3,4],[1,2,3,4]])", + " [array([[1, 2],", + " [1, 2]]), array([[3, 4],", + " [3, 4]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) == 0:", + " raise ValueError, 'hsplit only works on arrays of 1 or more dimensions'", + " if len(ary.shape) > 1:", + " return split(ary,indices_or_sections,1)", + " else:", + " return split(ary,indices_or_sections,0)", + "", + "def vsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple rows of sub-arrays", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups of rows. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Caveats:", + " How should we handle 1D arrays here? I am currently raising", + " an error when I encounter them. Any better approach?", + "", + " Should we reduce the returned array to their minium dimensions", + " by getting rid of any dimensions that are 1?", + " Related:", + " vstack, split, array_split, hsplit, dsplit.", + " Examples:", + " import scipy", + " >>> a = array([[1,2,3,4],", + " ... [1,2,3,4]])", + " >>> scipy.vsplit(a)", + " [array([ [1, 2, 3, 4]]), array([ [1, 2, 3, 4]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) < 2:", + " raise ValueError, 'vsplit only works on arrays of 2 or more dimensions'", + " return split(ary,indices_or_sections,0)", + "", + "def dsplit(ary,indices_or_sections):", + " \"\"\" Split ary into multiple sub-arrays along the 3rd axis (depth)", + "", + " Description:", + " Split a single array into multiple sub arrays. The array is", + " divided into groups along the 3rd axis. If indices_or_sections is", + " an integer, ary is divided into that many equally sized sub arrays.", + " If it is impossible to make the sub-arrays equally sized, the", + " operation throws a ValueError exception. See array_split and", + " split for other options on indices_or_sections.", + " Arguments:", + " ary -- N-D array.", + " Array to be divided into sub-arrays.", + " indices_or_sections -- integer or 1D array.", + " If integer, defines the number of (close to) equal sized", + " sub-arrays. If it is a 1D array of sorted indices, it", + " defines the indexes at which ary is divided. Any empty", + " list results in a single sub-array equal to the original", + " array.", + " Returns:", + " sequence of sub-arrays. The returned arrays have the same", + " number of dimensions as the input array.", + " Caveats:", + " See vsplit caveats.", + " Related:", + " dstack, split, array_split, hsplit, vsplit.", + " Examples:", + " >>> a = array([[[1,2,3,4],[1,2,3,4]]])", + " [array([ [[1, 2],", + " [1, 2]]]), array([ [[3, 4],", + " [3, 4]]])]", + "", + " \"\"\"", + " if len(Numeric.shape(ary)) < 3:", + " raise ValueError, 'vsplit only works on arrays of 3 or more dimensions'", + " return split(ary,indices_or_sections,2)", + "", + "", + "# note: Got rid of keyed_split stuff here. Perhaps revisit this in the future.", + "", + "#determine the \"minimum common type code\" for a group of arrays.", + "array_kind = {'i':0, 'l': 0, 'f': 0, 'd': 0, 'F': 1, 'D': 1}", + "array_precision = {'i': 1, 'l': 1, 'f': 0, 'd': 1, 'F': 0, 'D': 1}", + "array_type = [['f', 'd'], ['F', 'D']]", + "def common_type(*arrays):", + " kind = 0", + " precision = 0", + " for a in arrays:", + " t = a.typecode()", + " kind = max(kind, array_kind[t])", + " precision = max(precision, array_precision[t])", + " return array_type[kind][precision]", + "", + "def trim_zeros(filt,trim='fb'):", + " \"\"\"Trim the leading and trailing zeros from a 1D array.", + "", + " Example:", + " >>> import scipy", + " >>> a = array((0,0,0,1,2,3,2,1,0))", + " >>> scipy.trim_zeros(a)", + " array([1, 2, 3, 2, 1])", + "", + " \"\"\"", + " first = 0", + " if 'f' in trim or 'F' in trim:", + " for i in filt:", + " if i != 0.: break", + " else: first = first + 1", + " last = len(filt)", + " if 'b' in trim or 'B' in trim:", + " for i in filt[::-1]:", + " if i != 0.: break", + " else: last = last - 1", + " return filt[first:last]", + "", + "", + "##def test(level=10):", + "## from scipy_base.testing import module_test", + "## module_test(__name__,__file__,level=level)", + "", + "##def test_suite(level=1):", + "## from scipy_base.testing import module_test_suite", + "## return module_test_suite(__name__,__file__,level=level)", + "", + "", + "", + "" + ] + } + } + ] + }, + { + "hash": "409b2139e54c5060c739d04b84c25b41c90c4ee6", + "msg": "added temp fix for Travis O's machine", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-03T00:14:31+00:00", + "author_timezone": 0, + "committer_date": "2002-04-03T00:14:31+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "3438848f9c2214395da97c53f3e71ef237262615" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/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_base/ieee_754.py", + "new_path": "scipy_base/ieee_754.py", + "filename": "ieee_754.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -65,7 +65,11 @@ def isnan(x):\n \n NAN = PINF - PINF\n if not isnan(NAN):\n- raise ValueError(\"This machine doesn't have NaNs, \"\n+ if NAN != NAN:\n+ def isnan(x):\n+ return x!= x\n+ else:\n+ raise ValueError(\"This machine doesn't have NaNs, \"\n \"'overflows' to a finite number, \"\n \"suffers a novel way of implementing C comparisons, \"\n \"or is 754-conformant but is using \" \n", + "added_lines": 5, + "deleted_lines": 1, + "source_code": "\"\"\"Module ieee: exports a few useful IEEE-754 constants and functions.\n\nPINF positive infinity\nMINF minus infinity\nNAN a generic quiet NaN\nPZERO positive zero\nMZERO minus zero\n\nisnan(x)\n Return true iff x is a NaN.\n\"\"\"\n\ndef _make_inf():\n x = 2.0\n x2 = x * x\n i = 0\n while i < 100 and x != x2:\n x = x2\n x2 = x * x\n i = i + 1\n if x != x2:\n raise ValueError(\"This machine's floats go on forever!\")\n return x\n\n# NaN-testing.\n#\n# The usual method (x != x) doesn't work.\n# Python forces all comparisons thru a 3-outcome cmp protocol; unordered\n# isn't a possible outcome. The float cmp outcome is essentially defined\n# by this C expression (combining some cross-module implementation\n# details, and where px and py are pointers to C double):\n# px == py ? 0 : *px < *py ? -1 : *px > *py ? 1 : 0\n# Comparing x to itself thus always yields 0 by the first clause, and so x\n# != x is never true. If px and py point to distinct NaN objects, a\n# strange thing happens: 1. On scrupulous 754 implementations, *px < *py\n# returns false, and so\n# does *px > *py. Python therefore returns 0, i.e. \"equal\"!\n# 2. On Pentium HW, an unordered outcome sets an otherwise-impossible\n# combination of condition codes, including both the \"less than\" and\n# \"equal to\" flags. Microsoft C generates naive code that accepts the\n# \"less than\" flag at face value, and so the *px < *py clause returns\n# true, and Python returns -1, i.e. \"not equal\".\n# So with a proper C 754 implementation Python returns the wrong result,\n# and under MS's improper 754 implementation Python yields the right\n# result -- both by accident. It's unclear who should be shot .\n#\n# Anyway, the point of all that was to convince you it's tricky getting\n# the right answer in a portable way!\n\ndef isnan(x):\n \"\"\"x -> true iff x is a NaN.\"\"\"\n # multiply by 1.0 to create a distinct object (x < x *always*\n # false in Python, due to object identity forcing equality)\n if x * 1.0 < x:\n # it's a NaN and this is MS C on a Pentium\n return 1\n # Else it's non-NaN, or NaN on a non-MS+Pentium combo.\n # If it's non-NaN, then x == 1.0 and x == 2.0 can't both be true, \n # so we return false. If it is NaN, then assuming a good 754 C \n # implementation Python maps both unordered outcomes to true. \n return 1.0 == x == 2.0\n\nPINF = _make_inf()\nMINF = -PINF\n\nNAN = PINF - PINF\nif not isnan(NAN):\n if NAN != NAN:\n def isnan(x):\n return x!= x\n else:\n raise ValueError(\"This machine doesn't have NaNs, \"\n \"'overflows' to a finite number, \"\n \"suffers a novel way of implementing C comparisons, \"\n \"or is 754-conformant but is using \" \n \"a goofy rounding mode.\")\nPZERO = 0.0\nMZERO = -PZERO", + "source_code_before": "\"\"\"Module ieee: exports a few useful IEEE-754 constants and functions.\n\nPINF positive infinity\nMINF minus infinity\nNAN a generic quiet NaN\nPZERO positive zero\nMZERO minus zero\n\nisnan(x)\n Return true iff x is a NaN.\n\"\"\"\n\ndef _make_inf():\n x = 2.0\n x2 = x * x\n i = 0\n while i < 100 and x != x2:\n x = x2\n x2 = x * x\n i = i + 1\n if x != x2:\n raise ValueError(\"This machine's floats go on forever!\")\n return x\n\n# NaN-testing.\n#\n# The usual method (x != x) doesn't work.\n# Python forces all comparisons thru a 3-outcome cmp protocol; unordered\n# isn't a possible outcome. The float cmp outcome is essentially defined\n# by this C expression (combining some cross-module implementation\n# details, and where px and py are pointers to C double):\n# px == py ? 0 : *px < *py ? -1 : *px > *py ? 1 : 0\n# Comparing x to itself thus always yields 0 by the first clause, and so x\n# != x is never true. If px and py point to distinct NaN objects, a\n# strange thing happens: 1. On scrupulous 754 implementations, *px < *py\n# returns false, and so\n# does *px > *py. Python therefore returns 0, i.e. \"equal\"!\n# 2. On Pentium HW, an unordered outcome sets an otherwise-impossible\n# combination of condition codes, including both the \"less than\" and\n# \"equal to\" flags. Microsoft C generates naive code that accepts the\n# \"less than\" flag at face value, and so the *px < *py clause returns\n# true, and Python returns -1, i.e. \"not equal\".\n# So with a proper C 754 implementation Python returns the wrong result,\n# and under MS's improper 754 implementation Python yields the right\n# result -- both by accident. It's unclear who should be shot .\n#\n# Anyway, the point of all that was to convince you it's tricky getting\n# the right answer in a portable way!\n\ndef isnan(x):\n \"\"\"x -> true iff x is a NaN.\"\"\"\n # multiply by 1.0 to create a distinct object (x < x *always*\n # false in Python, due to object identity forcing equality)\n if x * 1.0 < x:\n # it's a NaN and this is MS C on a Pentium\n return 1\n # Else it's non-NaN, or NaN on a non-MS+Pentium combo.\n # If it's non-NaN, then x == 1.0 and x == 2.0 can't both be true, \n # so we return false. If it is NaN, then assuming a good 754 C \n # implementation Python maps both unordered outcomes to true. \n return 1.0 == x == 2.0\n\nPINF = _make_inf()\nMINF = -PINF\n\nNAN = PINF - PINF\nif not isnan(NAN):\n raise ValueError(\"This machine doesn't have NaNs, \"\n \"'overflows' to a finite number, \"\n \"suffers a novel way of implementing C comparisons, \"\n \"or is 754-conformant but is using \" \n \"a goofy rounding mode.\")\nPZERO = 0.0\nMZERO = -PZERO", + "methods": [ + { + "name": "_make_inf", + "long_name": "_make_inf( )", + "filename": "ieee_754.py", + "nloc": 11, + "complexity": 4, + "token_count": 51, + "parameters": [], + "start_line": 13, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isnan", + "long_name": "isnan( x )", + "filename": "ieee_754.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 50, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + }, + { + "name": "isnan", + "long_name": "isnan( x )", + "filename": "ieee_754.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "x" + ], + "start_line": 69, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + } + ], + "methods_before": [ + { + "name": "_make_inf", + "long_name": "_make_inf( )", + "filename": "ieee_754.py", + "nloc": 11, + "complexity": 4, + "token_count": 51, + "parameters": [], + "start_line": 13, + "end_line": 23, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 11, + "top_nesting_level": 0 + }, + { + "name": "isnan", + "long_name": "isnan( x )", + "filename": "ieee_754.py", + "nloc": 4, + "complexity": 2, + "token_count": 27, + "parameters": [ + "x" + ], + "start_line": 50, + "end_line": 61, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 12, + "top_nesting_level": 0 + } + ], + "changed_methods": [ + { + "name": "isnan", + "long_name": "isnan( x )", + "filename": "ieee_754.py", + "nloc": 2, + "complexity": 1, + "token_count": 9, + "parameters": [ + "x" + ], + "start_line": 69, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 2, + "top_nesting_level": 2 + } + ], + "nloc": 41, + "complexity": 7, + "token_count": 137, + "diff_parsed": { + "added": [ + " if NAN != NAN:", + " def isnan(x):", + " return x!= x", + " else:", + " raise ValueError(\"This machine doesn't have NaNs, \"" + ], + "deleted": [ + " raise ValueError(\"This machine doesn't have NaNs, \"" + ] + } + } + ] + }, + { + "hash": "19cf0563affa96f821e0ec02af68996dd34ef0a6", + "msg": "fixed import from utility -> type_check error", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-03T00:20:22+00:00", + "author_timezone": 0, + "committer_date": "2002-04-03T00:20:22+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "409b2139e54c5060c739d04b84c25b41c90c4ee6" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/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/limits.py", + "new_path": "scipy_base/limits.py", + "filename": "limits.py", + "extension": "py", + "change_type": "MODIFY", + "diff": "@@ -7,7 +7,7 @@\n \"\"\"\n \n import Numeric\n-from utility import toFloat32, toFloat64\n+from type_check import toFloat32, toFloat64\n \n __all__ = ['epsilon','tiny','float_epsilon','float_tiny','float_min',\n 'float_max','float_precision','float_resolution',\n", + "added_lines": 1, + "deleted_lines": 1, + "source_code": "\"\"\" This really needs some work...\n\n Calculate machine limits for Float32 and Float64.\n Actually, max and min are hard coded - and wrong!\n They are close, however.\n\n\"\"\"\n\nimport Numeric\nfrom type_check import toFloat32, toFloat64\n\n__all__ = ['epsilon','tiny','float_epsilon','float_tiny','float_min',\n 'float_max','float_precision','float_resolution',\n 'double_epsilon','double_tiny','double_min','double_max',\n 'double_precision','double_resolution']\n\ndef epsilon(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n elif typecode == Numeric.Float64: cast = toFloat64\n one = cast(1.0)\n x = cast(1.0)\n while one+x > one:\n x = x * cast(.5)\n x = x * cast(2.0)\n return x\n\ndef tiny(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n if typecode == Numeric.Float64: cast = toFloat64\n zero = cast(0.0)\n d1 = cast(1.0)\n d2 = cast(1.0)\n while d1 > zero:\n d2 = d1\n d1 = d1 * cast(.5)\n return d2\n\n \n\nfloat_epsilon = epsilon(Numeric.Float32)\nfloat_tiny = tiny(Numeric.Float32)\n#not correct\nfloat_min = -3.402823e38\nfloat_max = 3.402823e38\nfloat_precision = 6\nfloat_resolution = 10.0**(-float_precision)\n\n# hard coded - taken from Norbert's Fortran code.\n# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\ndouble_epsilon = epsilon(Numeric.Float64)\ndouble_tiny = tiny(Numeric.Float64)\n\n# not quite right...\ndouble_min = -1.797683134862318e308\ndouble_max = 1.797683134862318e308\ndouble_precision = 15\ndouble_resolution = 10.0**(-double_precision)\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": "\"\"\" This really needs some work...\n\n Calculate machine limits for Float32 and Float64.\n Actually, max and min are hard coded - and wrong!\n They are close, however.\n\n\"\"\"\n\nimport Numeric\nfrom utility import toFloat32, toFloat64\n\n__all__ = ['epsilon','tiny','float_epsilon','float_tiny','float_min',\n 'float_max','float_precision','float_resolution',\n 'double_epsilon','double_tiny','double_min','double_max',\n 'double_precision','double_resolution']\n\ndef epsilon(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n elif typecode == Numeric.Float64: cast = toFloat64\n one = cast(1.0)\n x = cast(1.0)\n while one+x > one:\n x = x * cast(.5)\n x = x * cast(2.0)\n return x\n\ndef tiny(typecode):\n if typecode == Numeric.Float32: cast = toFloat32\n if typecode == Numeric.Float64: cast = toFloat64\n zero = cast(0.0)\n d1 = cast(1.0)\n d2 = cast(1.0)\n while d1 > zero:\n d2 = d1\n d1 = d1 * cast(.5)\n return d2\n\n \n\nfloat_epsilon = epsilon(Numeric.Float32)\nfloat_tiny = tiny(Numeric.Float32)\n#not correct\nfloat_min = -3.402823e38\nfloat_max = 3.402823e38\nfloat_precision = 6\nfloat_resolution = 10.0**(-float_precision)\n\n# hard coded - taken from Norbert's Fortran code.\n# INTEGER, PARAMETER :: kind_DBLE = KIND(0D0) ! 8 (HP-UX)\n# INTEGER, PARAMETER :: prec_DBLE = PRECISION(0D0) ! 15\n# INTEGER, PARAMETER :: range_DBLE = RANGE(0D0) ! 307\n# REAL(kind_DBLE), PARAMETER :: eps_DBLE = EPSILON(0D0) ! 2.22e-16\n# REAL(kind_DBLE), PARAMETER :: tiny_DBLE = TINY(0D0) ! 2.23e-308\n# REAL(kind_DBLE), PARAMETER :: huge_DBLE = HUGE(0D0) ! 1.80e+308\ndouble_epsilon = epsilon(Numeric.Float64)\ndouble_tiny = tiny(Numeric.Float64)\n\n# not quite right...\ndouble_min = -1.797683134862318e308\ndouble_max = 1.797683134862318e308\ndouble_precision = 15\ndouble_resolution = 10.0**(-double_precision)\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "methods": [ + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 17, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 27, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 64, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [ + { + "name": "epsilon", + "long_name": "epsilon( typecode )", + "filename": "limits.py", + "nloc": 9, + "complexity": 4, + "token_count": 69, + "parameters": [ + "typecode" + ], + "start_line": 17, + "end_line": 25, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "tiny", + "long_name": "tiny( typecode )", + "filename": "limits.py", + "nloc": 10, + "complexity": 4, + "token_count": 68, + "parameters": [ + "typecode" + ], + "start_line": 27, + "end_line": 36, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 10, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 64, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "limits.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "changed_methods": [], + "nloc": 55, + "complexity": 10, + "token_count": 329, + "diff_parsed": { + "added": [ + "from type_check import toFloat32, toFloat64" + ], + "deleted": [ + "from utility import toFloat32, toFloat64" + ] + } + } + ] + }, + { + "hash": "b6c68d69358a03fb22f25f40014cff97aed5e15c", + "msg": "added transform files -- they can be moved to fft whenever", + "author": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "committer": { + "name": "Eric Jones", + "email": "eric@enthought.com" + }, + "author_date": "2002-04-03T02:58:40+00:00", + "author_timezone": 0, + "committer_date": "2002-04-03T02:58:40+00:00", + "committer_timezone": 0, + "branches": [ + "main" + ], + "in_main_branch": true, + "merge": false, + "parents": [ + "19cf0563affa96f821e0ec02af68996dd34ef0a6" + ], + "project_name": "repo_copy", + "project_path": "/tmp/tmp6f3_d89l/repo_copy", + "deletions": 0, + "insertions": 76, + "lines": 76, + "files": 1, + "dmm_unit_size": 1.0, + "dmm_unit_complexity": 1.0, + "dmm_unit_interfacing": 0.8421052631578947, + "modified_files": [ + { + "old_path": null, + "new_path": "scipy_base/transform_base.py", + "filename": "transform_base.py", + "extension": "py", + "change_type": "ADD", + "diff": "@@ -0,0 +1,76 @@\n+import Numeric\n+\n+\n+def fftshift(x,axes=None):\n+ \"\"\" Shift the result of an FFT operation.\n+\n+ Return a shifted version of x (useful for obtaining centered spectra).\n+ This function swaps \"half-spaces\" for all axes listed (defaults to all)\n+ \"\"\"\n+ ndim = len(x.shape)\n+ if axes == None:\n+ axes = range(ndim)\n+ y = x\n+ for k in axes:\n+ N = x.shape[k]\n+ p2 = int(Numeric.ceil(N/2.0))\n+ mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n+ y = Numeric.take(y,mylist,k)\n+ return y\n+\n+def ifftshift(x,axes=None):\n+ \"\"\" Reverse the effect of fftshift.\n+ \"\"\"\n+ ndim = len(x.shape)\n+ if axes == None:\n+ axes = range(ndim)\n+ y = x\n+ for k in axes:\n+ N = x.shape[k]\n+ p2 = int(Numeric.floor(N/2.0))\n+ mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n+ y = Numeric.take(y,mylist,k)\n+ return y\n+\n+def fftfreq(N,sample=1.0):\n+ \"\"\" FFT sample frequencies\n+ \n+ Return the frequency bins in cycles/unit (with zero at the start) given a\n+ window length N and a sample spacing.\n+ \"\"\"\n+ N = int(N)\n+ sample = float(sample)\n+ return Numeric.concatenate((Numeric.arange(0,(N-1)/2+1,1,'d'),Numeric.arange(-(N-1)/2,0,1,'d')))/N/sample\n+\n+def cont_ft(gn,fr,delta=1.0,n=None):\n+ \"\"\" Compute the (scaled) DFT of gn at frequencies fr.\n+\n+ If the gn are alias-free samples of a continuous time function then the\n+ correct value for the spacing, delta, will give the properly scaled,\n+ continuous Fourier spectrum.\n+ \n+ The DFT is obtained when delta=1.0\n+ \"\"\"\n+ if n is None:\n+ n = Numeric.arange(len(gn))\n+ dT = delta\n+ trans_kernel = Numeric.exp(-2j*Numeric.pi*fr[:,Numeric.NewAxis]*dT*n)\n+ return dT*Numeric.dot(trans_kernel,gn)\n+\n+#-----------------------------------------------------------------------------\n+# Test Routines\n+#-----------------------------------------------------------------------------\n+\n+def test(level=10):\n+ from scipy_base.testing import module_test\n+ module_test(__name__,__file__,level=level)\n+\n+def test_suite(level=1):\n+ from scipy_base.testing import module_test_suite\n+ return module_test_suite(__name__,__file__,level=level)\n+\n+if __name__ == '__main__':\n+ print 'float epsilon:',float_epsilon\n+ print 'float tiny:',float_tiny\n+ print 'double epsilon:',double_epsilon\n+ print 'double tiny:',double_tiny\n", + "added_lines": 76, + "deleted_lines": 0, + "source_code": "import Numeric\n\n\ndef fftshift(x,axes=None):\n \"\"\" Shift the result of an FFT operation.\n\n Return a shifted version of x (useful for obtaining centered spectra).\n This function swaps \"half-spaces\" for all axes listed (defaults to all)\n \"\"\"\n ndim = len(x.shape)\n if axes == None:\n axes = range(ndim)\n y = x\n for k in axes:\n N = x.shape[k]\n p2 = int(Numeric.ceil(N/2.0))\n mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n y = Numeric.take(y,mylist,k)\n return y\n\ndef ifftshift(x,axes=None):\n \"\"\" Reverse the effect of fftshift.\n \"\"\"\n ndim = len(x.shape)\n if axes == None:\n axes = range(ndim)\n y = x\n for k in axes:\n N = x.shape[k]\n p2 = int(Numeric.floor(N/2.0))\n mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))\n y = Numeric.take(y,mylist,k)\n return y\n\ndef fftfreq(N,sample=1.0):\n \"\"\" FFT sample frequencies\n \n Return the frequency bins in cycles/unit (with zero at the start) given a\n window length N and a sample spacing.\n \"\"\"\n N = int(N)\n sample = float(sample)\n return Numeric.concatenate((Numeric.arange(0,(N-1)/2+1,1,'d'),Numeric.arange(-(N-1)/2,0,1,'d')))/N/sample\n\ndef cont_ft(gn,fr,delta=1.0,n=None):\n \"\"\" Compute the (scaled) DFT of gn at frequencies fr.\n\n If the gn are alias-free samples of a continuous time function then the\n correct value for the spacing, delta, will give the properly scaled,\n continuous Fourier spectrum.\n \n The DFT is obtained when delta=1.0\n \"\"\"\n if n is None:\n n = Numeric.arange(len(gn))\n dT = delta\n trans_kernel = Numeric.exp(-2j*Numeric.pi*fr[:,Numeric.NewAxis]*dT*n)\n return dT*Numeric.dot(trans_kernel,gn)\n\n#-----------------------------------------------------------------------------\n# Test Routines\n#-----------------------------------------------------------------------------\n\ndef test(level=10):\n from scipy_base.testing import module_test\n module_test(__name__,__file__,level=level)\n\ndef test_suite(level=1):\n from scipy_base.testing import module_test_suite\n return module_test_suite(__name__,__file__,level=level)\n\nif __name__ == '__main__':\n print 'float epsilon:',float_epsilon\n print 'float tiny:',float_tiny\n print 'double epsilon:',double_epsilon\n print 'double tiny:',double_tiny\n", + "source_code_before": null, + "methods": [ + { + "name": "fftshift", + "long_name": "fftshift( x , axes = None )", + "filename": "transform_base.py", + "nloc": 11, + "complexity": 3, + "token_count": 98, + "parameters": [ + "x", + "axes" + ], + "start_line": 4, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "ifftshift", + "long_name": "ifftshift( x , axes = None )", + "filename": "transform_base.py", + "nloc": 11, + "complexity": 3, + "token_count": 98, + "parameters": [ + "x", + "axes" + ], + "start_line": 21, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + }, + { + "name": "fftfreq", + "long_name": "fftfreq( N , sample = 1 . 0 )", + "filename": "transform_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 76, + "parameters": [ + "N", + "sample" + ], + "start_line": 35, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "cont_ft", + "long_name": "cont_ft( gn , fr , delta = 1 . 0 , n = None )", + "filename": "transform_base.py", + "nloc": 6, + "complexity": 2, + "token_count": 74, + "parameters": [ + "gn", + "fr", + "delta", + "n" + ], + "start_line": 45, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "transform_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 64, + "end_line": 66, + "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": "transform_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + } + ], + "methods_before": [], + "changed_methods": [ + { + "name": "fftfreq", + "long_name": "fftfreq( N , sample = 1 . 0 )", + "filename": "transform_base.py", + "nloc": 4, + "complexity": 1, + "token_count": 76, + "parameters": [ + "N", + "sample" + ], + "start_line": 35, + "end_line": 43, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 9, + "top_nesting_level": 0 + }, + { + "name": "test_suite", + "long_name": "test_suite( level = 1 )", + "filename": "transform_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 24, + "parameters": [ + "level" + ], + "start_line": 68, + "end_line": 70, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "fftshift", + "long_name": "fftshift( x , axes = None )", + "filename": "transform_base.py", + "nloc": 11, + "complexity": 3, + "token_count": 98, + "parameters": [ + "x", + "axes" + ], + "start_line": 4, + "end_line": 19, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 16, + "top_nesting_level": 0 + }, + { + "name": "test", + "long_name": "test( level = 10 )", + "filename": "transform_base.py", + "nloc": 3, + "complexity": 1, + "token_count": 23, + "parameters": [ + "level" + ], + "start_line": 64, + "end_line": 66, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 3, + "top_nesting_level": 0 + }, + { + "name": "cont_ft", + "long_name": "cont_ft( gn , fr , delta = 1 . 0 , n = None )", + "filename": "transform_base.py", + "nloc": 6, + "complexity": 2, + "token_count": 74, + "parameters": [ + "gn", + "fr", + "delta", + "n" + ], + "start_line": 45, + "end_line": 58, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 14, + "top_nesting_level": 0 + }, + { + "name": "ifftshift", + "long_name": "ifftshift( x , axes = None )", + "filename": "transform_base.py", + "nloc": 11, + "complexity": 3, + "token_count": 98, + "parameters": [ + "x", + "axes" + ], + "start_line": 21, + "end_line": 33, + "fan_in": 0, + "fan_out": 0, + "general_fan_out": 0, + "length": 13, + "top_nesting_level": 0 + } + ], + "nloc": 44, + "complexity": 11, + "token_count": 422, + "diff_parsed": { + "added": [ + "import Numeric", + "", + "", + "def fftshift(x,axes=None):", + " \"\"\" Shift the result of an FFT operation.", + "", + " Return a shifted version of x (useful for obtaining centered spectra).", + " This function swaps \"half-spaces\" for all axes listed (defaults to all)", + " \"\"\"", + " ndim = len(x.shape)", + " if axes == None:", + " axes = range(ndim)", + " y = x", + " for k in axes:", + " N = x.shape[k]", + " p2 = int(Numeric.ceil(N/2.0))", + " mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))", + " y = Numeric.take(y,mylist,k)", + " return y", + "", + "def ifftshift(x,axes=None):", + " \"\"\" Reverse the effect of fftshift.", + " \"\"\"", + " ndim = len(x.shape)", + " if axes == None:", + " axes = range(ndim)", + " y = x", + " for k in axes:", + " N = x.shape[k]", + " p2 = int(Numeric.floor(N/2.0))", + " mylist = Numeric.concatenate((Numeric.arange(p2,N),Numeric.arange(p2)))", + " y = Numeric.take(y,mylist,k)", + " return y", + "", + "def fftfreq(N,sample=1.0):", + " \"\"\" FFT sample frequencies", + "", + " Return the frequency bins in cycles/unit (with zero at the start) given a", + " window length N and a sample spacing.", + " \"\"\"", + " N = int(N)", + " sample = float(sample)", + " return Numeric.concatenate((Numeric.arange(0,(N-1)/2+1,1,'d'),Numeric.arange(-(N-1)/2,0,1,'d')))/N/sample", + "", + "def cont_ft(gn,fr,delta=1.0,n=None):", + " \"\"\" Compute the (scaled) DFT of gn at frequencies fr.", + "", + " If the gn are alias-free samples of a continuous time function then the", + " correct value for the spacing, delta, will give the properly scaled,", + " continuous Fourier spectrum.", + "", + " The DFT is obtained when delta=1.0", + " \"\"\"", + " if n is None:", + " n = Numeric.arange(len(gn))", + " dT = delta", + " trans_kernel = Numeric.exp(-2j*Numeric.pi*fr[:,Numeric.NewAxis]*dT*n)", + " return dT*Numeric.dot(trans_kernel,gn)", + "", + "#-----------------------------------------------------------------------------", + "# Test Routines", + "#-----------------------------------------------------------------------------", + "", + "def test(level=10):", + " from scipy_base.testing import module_test", + " module_test(__name__,__file__,level=level)", + "", + "def test_suite(level=1):", + " from scipy_base.testing import module_test_suite", + " return module_test_suite(__name__,__file__,level=level)", + "", + "if __name__ == '__main__':", + " print 'float epsilon:',float_epsilon", + " print 'float tiny:',float_tiny", + " print 'double epsilon:',double_epsilon", + " print 'double tiny:',double_tiny" + ], + "deleted": [] + } + } + ] + } +] \ No newline at end of file